/* =====================================================================
   A2 Life — back office

   Structural class names match the member portal (sidebar / shell /
   topbar / content / nav-link / card / table), so the two apps feel the
   same to work in. The palette deliberately does not: the member portal
   is green, this is slate and amber. A member of staff with both open
   should never have to read the page to know which one they are in.
   ===================================================================== */

:root {
    --slate-900: #14202b;
    --slate-800: #1b2c3a;
    --slate-700: #24394a;
    --slate-600: #33506a;
    --slate-500: #4a6d8c;

    --amber-600: #b7791f;
    --amber-500: #d69e2e;
    --amber-100: #fdf3dd;

    --ink:    #1a2a35;
    --muted:  #6b7f8d;
    --line:   #e0e7ec;
    --bg:     #f3f6f8;
    --card:   #ffffff;

    --ok:      #1b8a4b;
    --ok-bg:   #e7f5ec;
    --warn:    #b7791f;
    --warn-bg: #fdf3dd;
    --danger:  #c62828;
    --danger-bg: #fdeaea;
    --info:    #2b6cb0;
    --info-bg: #e8f1fa;

    --sidebar-w: 256px;
    --topbar-h:  60px;
    --radius:    11px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14.5px;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--slate-600); }

h1, h2, h3, h4 { margin: 0; font-weight: 800; letter-spacing: -.01em; }

/* ══ Sign in ═══════════════════════════════════════════════════════ */

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px 16px;
    background: linear-gradient(160deg, var(--slate-800), var(--slate-900) 60%, #0d1720);
}

.login-wrap { width: 100%; max-width: 380px; }

.login-card {
    background: var(--card);
    border-radius: 16px;
    padding: 30px 26px 24px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .3);
}

.login-head { text-align: center; margin-bottom: 22px; }

.login-mark {
    width: 54px; height: 54px;
    display: grid; place-items: center;
    margin: 0 auto 12px;
    border-radius: 15px;
    background: linear-gradient(145deg, var(--slate-700), var(--slate-900));
    color: var(--amber-500);
    font-size: 22px;
}

.login-head h1 { font-size: 20px; }
.login-head p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .09em;
}

.login-foot {
    margin: 18px 0 0;
    text-align: center;
    font-size: 12px;
    line-height: 1.55;
    color: var(--muted);
}

.login-note {
    margin: 16px 0 0;
    text-align: center;
    font-size: 13px;
}
.login-note a { color: rgba(255, 255, 255, .72); }

/* ══ Sidebar ═══════════════════════════════════════════════════════ */

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--slate-800), var(--slate-900));
    display: flex;
    flex-direction: column;
    z-index: 40;
}

.sidebar-brand {
    padding: 0 18px;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, .09);
    flex-shrink: 0;
}
.sidebar-brand a {
    display: flex;
    align-items: center;
    gap: 11px;
    text-decoration: none;
    color: #fff;
}

.brand-mark {
    width: 34px; height: 34px;
    display: grid; place-items: center;
    border-radius: 9px;
    background: rgba(255, 255, 255, .1);
    color: var(--amber-500);
    font-size: 15px;
    flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text strong { font-size: 15px; }
.brand-text small {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .5);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 10px 0 18px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .22) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .2);
    border-radius: 3px;
}

.sidebar-nav ul { list-style: none; margin: 0; padding: 0; }

.nav-link {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    border: 0;
    background: none;
    font: inherit;
    font-size: 13.8px;
    font-weight: 600;
    text-align: left;
    text-decoration: none;
    color: rgba(255, 255, 255, .78);
    cursor: pointer;
    transition: background .15s, color .15s;
}
.nav-link > span:first-of-type { flex: 1; min-width: 0; }
.nav-link > i:first-child { width: 17px; text-align: center; font-size: 14px; opacity: .8; }

.nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }

.nav-link.is-active {
    background: rgba(255, 255, 255, .11);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--amber-500);
}
.nav-link.is-active > i:first-child { opacity: 1; color: var(--amber-500); }

.nav-signout:hover { background: rgba(198, 40, 40, .35); color: #fff; }

.nav-caret {
    font-size: 10px;
    opacity: .5;
    transition: transform .2s;
}
.nav-group.is-open .nav-caret { transform: rotate(90deg); }

.submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height .25s ease;
    background: rgba(0, 0, 0, .18);
}
.nav-group.is-open .submenu { max-height: 340px; }

.submenu a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px 9px 47px;
    font-size: 13.2px;
    font-weight: 600;
    text-decoration: none;
    color: rgba(255, 255, 255, .62);
}
.submenu a > span:first-child { flex: 1; min-width: 0; }
.submenu a:hover { color: #fff; background: rgba(255, 255, 255, .05); }
.submenu a.is-active { color: var(--amber-500); }

.nav-badge {
    flex-shrink: 0;
    min-width: 20px;
    padding: 1px 6px;
    border-radius: 9px;
    background: var(--amber-500);
    color: var(--slate-900);
    font-size: 11px;
    font-weight: 800;
    text-align: center;
}

.nav-sep {
    height: 1px;
    margin: 10px 18px;
    background: rgba(255, 255, 255, .1);
}

.sidebar-foot {
    padding: 12px 18px;
    border-top: 1px solid rgba(255, 255, 255, .09);
    font-size: 11.5px;
    color: rgba(255, 255, 255, .42);
    flex-shrink: 0;
}

.scrim {
    position: fixed;
    inset: 0;
    background: rgba(12, 22, 30, .5);
    z-index: 39;
}

/* ══ Shell ═════════════════════════════════════════════════════════ */

.shell {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 20px;
    background: var(--card);
    border-bottom: 1px solid var(--line);
}

.topbar-title {
    font-size: 16.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-search {
    position: relative;
    margin-left: auto;
    max-width: 280px;
    flex: 1;
}
.topbar-search i {
    position: absolute;
    left: 11px; top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 12.5px;
    pointer-events: none;
}
.topbar-search input {
    width: 100%;
    padding: 8px 12px 8px 32px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg);
    font: inherit;
    font-size: 13.5px;
}
.topbar-search input:focus {
    outline: none;
    border-color: var(--slate-500);
    background: #fff;
}

.topbar-user { display: flex; align-items: center; gap: 10px; }
.topbar-meta { display: flex; flex-direction: column; line-height: 1.2; text-align: right; }
.topbar-name { font-weight: 700; font-size: 13.5px; }
.topbar-id { font-size: 11.5px; color: var(--muted); font-weight: 700; }

.topbar-avatar {
    width: 36px; height: 36px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--slate-700);
    color: #fff;
    font-size: 12.5px;
    font-weight: 800;
    flex-shrink: 0;
}

.icon-btn {
    display: none;
    width: 36px; height: 36px;
    border: 0;
    border-radius: 8px;
    background: var(--bg);
    color: var(--ink);
    font-size: 15px;
    cursor: pointer;
}

.progress {
    position: fixed;
    top: var(--topbar-h);
    left: var(--sidebar-w);
    height: 2px;
    background: var(--amber-500);
    z-index: 35;
    transition: width .25s ease, opacity .3s ease;
}

.content {
    flex: 1;
    padding: 20px;
    max-width: 1320px;
    width: 100%;
    transition: opacity .12s;
}
.content.is-loading { opacity: .55; }

.footer {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 14px 20px;
    border-top: 1px solid var(--line);
    font-size: 12px;
    color: var(--muted);
}

/* ══ Alerts ════════════════════════════════════════════════════════ */

.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 13.5px;
    font-weight: 600;
}
.alert-success { background: var(--ok-bg);     color: var(--ok);     }
.alert-error   { background: var(--danger-bg); color: var(--danger); }
.alert-info    { background: var(--info-bg);   color: var(--info);   }

/* ══ Cards ═════════════════════════════════════════════════════════ */

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 18px;
}

.card-head {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 13px 16px;
    border-bottom: 1px solid var(--line);
}
.card-head h2 { font-size: 14.5px; }
.card-head .spacer { margin-left: auto; }
.card-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); font-weight: 600; }

.card-body { padding: 16px; }
.card-foot {
    padding: 12px 16px;
    border-top: 1px solid var(--line);
    background: var(--bg);
    border-radius: 0 0 var(--radius) var(--radius);
}

/* ══ Stat tiles ════════════════════════════════════════════════════ */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stat {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 15px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
    transition: border-color .15s, transform .15s;
}
a.stat:hover { border-color: var(--slate-500); transform: translateY(-1px); }

.stat-icon {
    width: 42px; height: 42px;
    display: grid; place-items: center;
    border-radius: 11px;
    font-size: 16px;
    flex-shrink: 0;
    background: var(--bg);
    color: var(--slate-600);
}
.stat-icon.is-warn   { background: var(--warn-bg);   color: var(--warn);   }
.stat-icon.is-ok     { background: var(--ok-bg);     color: var(--ok);     }
.stat-icon.is-danger { background: var(--danger-bg); color: var(--danger); }
.stat-icon.is-info   { background: var(--info-bg);   color: var(--info);   }

.stat-body { display: flex; flex-direction: column; min-width: 0; }
.stat-value { font-size: 21px; font-weight: 800; line-height: 1.15; }
.stat-label {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .05em;
}

/* ══ Tables ════════════════════════════════════════════════════════ */

.table-wrap { overflow-x: auto; }

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

table.data th {
    padding: 10px 14px;
    text-align: left;
    white-space: nowrap;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    font-size: 11.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
}

table.data td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: #fafcfd; }

.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

/* Member chip: initials + name + ID, used in every list. */
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who-avatar {
    width: 32px; height: 32px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--slate-700);
    color: #fff;
    font-size: 11.5px;
    font-weight: 800;
    flex-shrink: 0;
}
.who-body { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.who-name { font-weight: 700; }
.who-id { font-size: 11.5px; color: var(--muted); font-weight: 700; }
.who a { text-decoration: none; color: inherit; }
.who a:hover .who-name { color: var(--slate-600); text-decoration: underline; }

/* ══ Pills ═════════════════════════════════════════════════════════ */

.pill {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 800;
    white-space: nowrap;
}
.pill-ok     { background: var(--ok-bg);     color: var(--ok);     }
.pill-warn   { background: var(--warn-bg);   color: var(--warn);   }
.pill-danger { background: var(--danger-bg); color: var(--danger); }
.pill-info   { background: var(--info-bg);   color: var(--info);   }
.pill-mute   { background: var(--bg);        color: var(--muted);  }

/* Small coloured icon badge next to an income stream's label —
   earning-report*.php. Shape only; colour comes inline per stream from
   config/app.php income_types, same as the member-facing version this
   is ported from (member_profile/assets/css/app.css), so it is never
   wrong even though the two apps' palettes otherwise differ. */
.income-dot {
    width: 32px; height: 32px;
    border-radius: 9px;
    display: inline-grid;
    place-items: center;
    font-size: 13px;
    flex-shrink: 0;
    vertical-align: middle;
    margin-right: 6px;
}

/* Level number badge — earning-report-date.php, mirrors the
   member-facing .level-chip but in admin_panel's own info accent
   rather than member_profile's green. */
.level-chip {
    display: inline-grid;
    place-items: center;
    min-width: 26px;
    height: 26px;
    padding: 0 7px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 800;
    color: var(--info);
    background: var(--info-bg);
}

/* ══ Buttons ═══════════════════════════════════════════════════════ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 15px;
    border: 1px solid transparent;
    border-radius: 8px;
    font: inherit;
    font-size: 13.5px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: filter .15s, background .15s;
}
.btn:hover { filter: brightness(.94); }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }

.btn-primary { background: var(--slate-700); color: #fff; }
.btn-ok      { background: var(--ok);        color: #fff; }
.btn-danger  { background: var(--danger);    color: #fff; }
.btn-ghost   { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--bg); filter: none; }

.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn-block { width: 100%; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ══ Forms ═════════════════════════════════════════════════════════ */

.field { display: block; margin-bottom: 14px; }
.field > span {
    display: block;
    margin-bottom: 5px;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--muted);
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    font: inherit;
    font-size: 14px;
    color: var(--ink);
}
.field textarea { min-height: 96px; resize: vertical; }

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--slate-500);
    box-shadow: 0 0 0 3px rgba(74, 109, 140, .13);
}

.field-hint { margin: 5px 0 0; font-size: 12px; color: var(--muted); }

.field-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0 14px;
}

.check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 13.5px;
    font-weight: 600;
}
.check input { width: 16px; height: 16px; accent-color: var(--slate-600); }

/* Filter bar above a list. */
.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
}
.filters .field { margin-bottom: 0; flex: 1 1 160px; min-width: 140px; }
.filters .btn { flex-shrink: 0; }

/* ══ Definition list ═══════════════════════════════════════════════ */

.facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px 20px;
    margin: 0;
}
.facts > div { min-width: 0; }
.facts dt {
    font-size: 11.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    margin-bottom: 3px;
}
.facts dd {
    margin: 0;
    font-weight: 700;
    word-break: break-word;
}

/* ══ Conversation ══════════════════════════════════════════════════ */

.thread { display: flex; flex-direction: column; gap: 12px; }

.msg {
    max-width: 78%;
    padding: 11px 14px;
    border-radius: 12px;
    font-size: 13.8px;
    line-height: 1.55;
}
.msg p { margin: 0; white-space: pre-wrap; }

.msg-from-member {
    align-self: flex-start;
    background: var(--bg);
    border: 1px solid var(--line);
    border-bottom-left-radius: 3px;
}
.msg-from-staff {
    align-self: flex-end;
    background: var(--slate-700);
    color: #fff;
    border-bottom-right-radius: 3px;
}

.msg-meta {
    display: block;
    margin-top: 6px;
    font-size: 11px;
    font-weight: 700;
    opacity: .7;
}
.msg-from-staff a { color: #fff; }

/* ══ Audit trail ═══════════════════════════════════════════════════ */

.trail { list-style: none; margin: 0; padding: 0; }
.trail li {
    position: relative;
    padding: 0 0 16px 22px;
    border-left: 2px solid var(--line);
}
.trail li:last-child { border-left-color: transparent; padding-bottom: 0; }
.trail li::before {
    content: '';
    position: absolute;
    left: -6px; top: 4px;
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--slate-500);
}
.trail li.is-ok::before     { background: var(--ok); }
.trail li.is-danger::before { background: var(--danger); }

.trail-title { font-weight: 700; font-size: 13.8px; }
.trail-meta  { font-size: 12px; color: var(--muted); font-weight: 600; }

/* ══ Pagination ════════════════════════════════════════════════════ */

.pager {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.pager a, .pager span {
    min-width: 32px;
    padding: 5px 9px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--card);
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    color: var(--ink);
}
.pager a:hover { background: var(--bg); }
.pager .is-current { background: var(--slate-700); border-color: var(--slate-700); color: #fff; }
.pager .is-disabled { opacity: .45; }
.pager-info { margin-right: auto; font-size: 12.5px; color: var(--muted); font-weight: 600; }

/* ══ Empty state ═══════════════════════════════════════════════════ */

.empty {
    padding: 44px 20px;
    text-align: center;
    color: var(--muted);
}
.empty i { font-size: 30px; opacity: .35; margin-bottom: 10px; display: block; }
.empty h2 { font-size: 15.5px; color: var(--ink); margin-bottom: 5px; }
.empty p { margin: 0; font-size: 13.5px; }

/* ══ Document preview ══════════════════════════════════════════════ */

.docs { display: flex; gap: 12px; flex-wrap: wrap; }
.doc {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 13px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--card);
    text-decoration: none;
    color: inherit;
    font-size: 13px;
    font-weight: 700;
}
.doc:hover { border-color: var(--slate-500); }
.doc i { color: var(--slate-500); }

/* ══ Responsive ════════════════════════════════════════════════════ */

@media (max-width: 960px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform .22s ease;
    }
    .sidebar.is-open { transform: none; }

    .shell { margin-left: 0; }
    .progress { left: 0; }
    .icon-btn { display: grid; place-items: center; }

    .topbar-search { display: none; }
}

@media (max-width: 620px) {
    .content { padding: 14px; }
    .topbar { padding: 0 14px; gap: 10px; }
    .topbar-meta { display: none; }
    .msg { max-width: 92%; }

    /* A wide table on a phone scrolls inside its own box rather than
       pushing the whole page sideways. */
    .table-wrap { margin: 0 -16px; padding: 0 16px; }
}

@media print {
    .sidebar, .topbar, .footer, .btn, .pager { display: none !important; }
    .shell { margin-left: 0; }
    .card { border-color: #ccc; break-inside: avoid; }
}
