/*
 * Styles for the operating pages: the member area (shop, orders, activation,
 * wallet, statements) and the staff console. It sits on top of style.css and
 * admin.css and adds only what those two do not already provide: status chips,
 * flash messages, form rows inside panels, money columns, code display and the
 * calculation breakdowns that make a commission traceable on screen.
 */

/* ------------------------------------------------------------------ chips */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    background: #eef1f5;
    color: #6b7686;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .02em;
    white-space: nowrap;
}
.chip-good { background: #e2fff0; color: #087a40; }
.chip-warn { background: #fff0d6; color: #8b6928; }
.chip-info { background: #e8f0fc; color: #2b4d7e; }
.chip-bad { background: #fce8e7; color: #9a4844; }
.chip-mute { background: #eef1f5; color: #6b7686; }

/* ------------------------------------------------------------------ flash */
.portal-flash {
    margin: 0 0 16px;
    padding: 12px 15px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
}
.portal-flash-ok { border-color: #bfe8d0; background: #edfaf3; color: #0d6a3c; }
.portal-flash-err { border-color: #f0cdc8; background: #fdf2f0; color: #8b3c2a; }

/* ------------------------------------------------------------------ money */
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.money-out { color: #9a4844; }
.money-in { color: #0d6a3c; }

/* ------------------------------------------------------- layout helpers */
.portal-stack { display: grid; gap: 16px; }
.portal-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.portal-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.portal-stack > *, .portal-grid-2 > *, .portal-grid-3 > * { min-width: 0; }
.portal-head-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }

/* ------------------------------------------------------------- summary tiles */
.portal-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
    gap: 13px;
}
.portal-tile {
    padding: 17px 18px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fff;
}
.portal-tile span { display: block; color: #6e737c; font-size: 11px; font-weight: 600; }
.portal-tile .product-tile-image { display: block; width: 100%; margin: 0 0 12px; border-radius: 9px; aspect-ratio: 8 / 11; object-fit: contain; background: #eef1f6; }
.portal-tile strong { display: block; margin-top: 8px; font-family: Manrope, sans-serif; font-size: 23px; letter-spacing: -.03em; }
.portal-tile small { display: block; margin-top: 4px; color: #898d94; font-size: 10px; line-height: 1.5; }
.portal-tile.is-good strong { color: #0d6a3c; }
.portal-tile.is-warn strong { color: #8b6928; }

/* ---------------------------------------------------------------- forms */
.portal-form { display: grid; gap: 14px; }
.portal-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.portal-form label,
.portal-field { display: block; color: #343c4b; font-size: 11px; font-weight: 700; }
.portal-form input[type="text"],
.portal-form input[type="email"],
.portal-form input[type="number"],
.portal-form input[type="tel"],
.portal-form select,
.portal-form textarea,
.portal-field input,
.portal-field select,
.portal-field textarea {
    width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    border: 1px solid #dce0e5;
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    font-size: 13px;
    font-family: inherit;
}
.portal-form select, .portal-field select { height: 42px; padding: 0 10px; }
.portal-form textarea { min-height: 78px; resize: vertical; }
.portal-form input:focus, .portal-form select:focus, .portal-form textarea:focus,
.portal-field input:focus, .portal-field select:focus, .portal-field textarea:focus {
    border-color: #667690;
    box-shadow: 0 0 0 3px rgba(102, 118, 144, .12);
    outline: 0;
}
.portal-hint { color: #858991; font-size: 10.5px; font-weight: 400; line-height: 1.5; }

/* --------------------------------------------------------- profile photos */
.dash-avatar-photo {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    border: 1px solid rgba(255,255,255,.28);
    border-radius: 9px;
    background: #fff;
    object-fit: contain;
}
.member-avatar-image {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 11px;
    background: #fff;
    object-fit: contain;
}
.avatar-photo { overflow: hidden; border-radius: 12px; background: #fff; }
.profile-photo-content { display: flex; align-items: center; gap: 20px; }
.profile-photo-preview {
    flex: 0 0 auto;
    width: 112px;
    height: 112px;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 1px solid #dce5f0;
    border-radius: 14px;
    background: #fff;
    color: var(--green);
    font-family: Manrope, sans-serif;
    font-size: 32px;
    font-weight: 800;
}
.profile-photo-preview img { display: block; width: 100%; height: 100%; border-radius: 12px; object-fit: contain; }
.profile-photo-controls { min-width: 0; flex: 1 1 auto; }
.profile-photo-controls form { margin: 0 0 10px; }
.profile-photo-controls input[type="file"] {
    height: auto;
    min-height: 42px;
    padding: 8px;
    text-transform: none;
}
.profile-photo-controls .account-hint { margin: 0 0 12px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.profile-photo-remove { border: 1px solid #d8b8b8; color: #8b3c3c; }
.profile-photo-preview img[hidden] { display: none; }
.profile-photo-capture { margin-left: 8px; }
.profile-photo-modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(9, 18, 33, .72);
}
.profile-photo-modal[hidden] { display: none; }
.profile-photo-modal-card {
    width: 100%;
    max-width: 460px;
    padding: 16px;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 24px 60px rgba(9, 18, 33, .35);
}
.profile-photo-modal-card video {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    border-radius: 10px;
    background: #0b1220;
    object-fit: cover;
}
.profile-photo-modal-actions { display: flex; gap: 10px; margin-top: 14px; }

/* --------------------------------------------------------- action rows */
.portal-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.portal-actions form { margin: 0; }
.portal-inline-form { display: flex; align-items: flex-end; gap: 9px; flex-wrap: wrap; }
.portal-inline-form .portal-field { flex: 1 1 160px; }

/* ------------------------------------------------------------ code display */
.code-display {
    display: inline-block;
    padding: 14px 18px;
    border: 1px dashed #c7d5e8;
    border-radius: 9px;
    background: #f7fafe;
    color: #1e3f70;
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: .16em;
}
.code-chip-lg { padding: 7px 12px; border-radius: 5px; background: #f2f6fc; border: 1px solid #d4e0f0; color: #2b4d7e; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; font-weight: 700; letter-spacing: .12em; }

/* ------------------------------------------------- calculation breakdowns */
.calc-box { margin-top: 9px; padding: 11px 13px; border: 1px solid #e4ebf4; border-radius: 7px; background: #f8fafd; }
.calc-box h4 { margin: 0 0 8px; color: #6b7686; font-size: 9.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.calc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 6px 14px; margin: 0; }
.calc-grid div { display: flex; justify-content: space-between; gap: 10px; font-size: 11px; }
.calc-grid dt { color: #7b8698; }
.calc-grid dd { margin: 0; color: #33415a; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- receipt */
.receipt-head { display: flex; justify-content: space-between; gap: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.receipt-head .receipt-no { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 15px; font-weight: 700; color: var(--ink); }
.receipt-total { display: flex; justify-content: space-between; align-items: baseline; margin-top: 14px; padding-top: 14px; border-top: 2px solid var(--ink); font-size: 20px; font-weight: 700; }

/* ---------------------------------------------------------------- tables */
.portal-table-note { margin: 10px 0 0; color: #858991; font-size: 10.5px; }
.portal-table td .sub { display: block; margin-top: 3px; color: #8b939f; font-size: 10px; }
.portal-right { text-align: right; }

/* ------------------------------------------------------------------ misc */
.portal-note {
    margin: 0 0 16px;
    padding: 11px 14px;
    border: 1px solid #dbe6f4;
    border-radius: 8px;
    background: #f5f9fe;
    color: #41536f;
    font-size: 11.5px;
    line-height: 1.6;
}
.portal-checklist { margin: 0; padding: 0; list-style: none; display: grid; gap: 7px; }
.portal-checklist li { display: flex; align-items: flex-start; gap: 9px; font-size: 12px; color: #4b5563; }
.portal-checklist .tick { flex: 0 0 auto; width: 17px; height: 17px; display: grid; place-items: center; border-radius: 50%; background: #e6ebf2; color: #7b8698; font-size: 10px; font-weight: 700; }
.portal-checklist li.is-done .tick { background: #d8f6e6; color: #0d6a3c; }
.portal-checklist li.is-done { color: #0d6a3c; font-weight: 600; }

.passup-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 0 0 16px;
}
.passup-genealogy .genealogy-tree { min-height: 76px; }

@media (max-width: 760px) {
    .portal-grid-2, .portal-grid-3, .portal-form-row { grid-template-columns: 1fr; }
    .passup-summary { grid-template-columns: 1fr; }
    .dashboard-head { flex-direction: column; align-items: flex-start; gap: 12px; padding-top: 34px; }
    .profile-photo-content { align-items: flex-start; flex-direction: column; }
    .profile-photo-controls { width: 100%; }
}

/* Keep dense package inventory and history readable on narrow screens. Each
   table row becomes a labeled card, so expandable terms and action forms never
   compete for the width of a seven-column desktop table. */
@media (max-width: 760px) {
    .package-center-table {
        display: block;
        width: 100%;
        min-width: 0;
    }
    .package-center-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        clip-path: inset(50%);
    }
    .package-center-table tbody {
        display: block;
    }
    .package-center-table tr {
        display: block;
        min-width: 0;
        margin: 0 0 12px;
        padding: 5px 12px;
        border: 1px solid #e2eaf4;
        border-radius: 8px;
        background: #fff;
    }
    .package-center-table tr:last-child { margin-bottom: 0; }
    .package-center-table td {
        display: grid;
        grid-template-columns: minmax(6.25rem, 34%) minmax(0, 1fr);
        align-items: start;
        gap: 8px;
        min-width: 0;
        padding: 10px 0;
        border-top: 0;
        border-bottom: 1px solid #edf0f4;
        overflow-wrap: anywhere;
        text-align: left;
    }
    .package-center-table td:last-child { border-bottom: 0; }
    .package-center-table td::before {
        content: attr(data-label);
        color: #6e737c;
        font-size: 12px;
        font-weight: 700;
        line-height: 1.45;
    }
    .package-center-table td > * { min-width: 0; max-width: 100%; }
    .package-center-table .code-chip-lg {
        display: inline-block;
        max-width: 100%;
        overflow-wrap: anywhere;
        word-break: break-word;
        letter-spacing: .06em;
    }
    .package-center-table details { min-width: 0; }
    .package-center-table details summary {
        cursor: pointer;
        line-height: 1.45;
        overflow-wrap: anywhere;
    }
    .package-center-table details small {
        display: block;
        margin-top: 6px;
        line-height: 1.45;
        overflow-wrap: anywhere;
    }
    .package-center-table .portal-form-inline {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        width: 100%;
        gap: 8px;
    }
    .package-center-table .portal-form-inline input[type="text"] { min-width: 0; }
    .package-center-table .portal-form-inline .button { justify-self: start; }
    .package-center-table .admin-num { text-align: left; }
}

/* ------------------------------------------------------------------------
   Legibility for the member pages.
   This file is loaded only by the signed-in member area, on top of
   style.css, so these sizes apply there and nowhere else. The smaller type is
   lifted for older readers on phones, and every field reaches 16px, the width
   at which iOS stops zooming the page when a field is tapped.
   ------------------------------------------------------------------------ */
.chip { font-size: 12.5px; }
.portal-flash { font-size: 14px; }
.portal-tile span { font-size: 13.5px; }
.portal-tile small,
.portal-table-note,
.portal-table td .sub { font-size: 13px; }
.portal-form label,
.portal-field { font-size: 13px; }
.portal-form input[type="text"],
.portal-form input[type="email"],
.portal-form input[type="number"],
.portal-form input[type="tel"],
.portal-form select,
.portal-form textarea,
.portal-field input,
.portal-field select,
.portal-field textarea { font-size: 16px; }
.portal-hint { font-size: 13px; }
.portal-note { font-size: 13.5px; }
.portal-checklist li { font-size: 14px; }
.portal-checklist .tick { font-size: 12px; }
.code-chip-lg { font-size: 14px; }
.calc-box h4 { font-size: 12px; }
.calc-grid div { font-size: 13.5px; }
