/* ==========================================================
   NexusVectors Admin — styles. Same palette as the main site
   (Trust Blue) but tuned for dense data-entry / table screens.
   ========================================================== */

:root {
    --c-bg:        #f5f8fd;
    --c-surface:   #ffffff;
    --c-ink:       #0a2540;
    --c-ink-soft:  #4b5b73;
    --c-line:      #e6ecf3;
    --c-brand:     #2b6cff;
    --c-brand-dk:  #1448b8;
    --c-brand-2:   #3ee0c8;
    --c-accent:    #1448b8;
    --c-success:   #14a07a;
    --c-warn:      #d68a00;
    --c-danger:    #c33a3a;

    --radius:      12px;
    --radius-sm:   8px;
    --shadow-sm:   0 1px 2px rgba(10,37,64,.06);
    --shadow:      0 8px 24px rgba(10,37,64,.08);
    --shadow-lg:   0 16px 40px rgba(10,37,64,.12);

    --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    --font-ar: "Tajawal", "Plus Jakarta Sans", system-ui, Tahoma, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; padding: 0;
    font-family: var(--font);
    color: var(--c-ink);
    background: var(--c-bg);
    line-height: 1.55;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}
html[lang="ar"] body, html[dir="rtl"] body { font-family: var(--font-ar); }

a { color: var(--c-brand); text-decoration: none; }
a:hover { color: var(--c-brand-dk); }
img, svg { max-width: 100%; display: block; }
hr { border: 0; border-top: 1px solid var(--c-line); margin: 24px 0; }

/* ---------- Container ---------- */
.container { max-width: 1180px; margin: 0 auto; padding: 32px 24px 64px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 18px; border-radius: 999px; border: 1px solid transparent;
    font-weight: 700; font-size: 14px; line-height: 1; cursor: pointer;
    font-family: inherit;
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease, color .15s ease, border-color .15s ease;
    white-space: nowrap;
}
.btn-sm    { padding: 7px 14px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-primary {
    background: linear-gradient(135deg, var(--c-brand), var(--c-brand-dk));
    color: #fff;
    box-shadow: 0 6px 14px rgba(43,108,255,.25);
}
.btn-primary:hover { transform: translateY(-1px); color: #fff; box-shadow: 0 10px 20px rgba(43,108,255,.35); }
.btn-ghost {
    background: transparent;
    color: var(--c-ink);
    border-color: var(--c-line);
}
.btn-ghost:hover { color: var(--c-brand); border-color: var(--c-brand); }
.btn-danger {
    background: var(--c-danger);
    color: #fff;
}
.btn-danger:hover { background: #a02d2d; color: #fff; }

/* ---------- Top header ---------- */
.admin-header {
    background: #0a2540;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.08);
    position: sticky; top: 0; z-index: 50;
}
.admin-header-inner {
    max-width: 1180px; margin: 0 auto;
    padding: 14px 24px;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.admin-brand {
    display: inline-flex; align-items: center; gap: 10px;
    color: #fff; font-size: 15px; line-height: 1;
}
.admin-brand strong { font-weight: 800; }
.admin-brand:hover { color: #fff; }
.admin-brand svg { color: #fff; }

.admin-nav {
    display: flex; gap: 24px; flex: 1 1 auto; justify-content: center;
}
.admin-nav a {
    color: #cfd6e2; font-weight: 600; font-size: 14px;
    padding: 6px 0; position: relative;
}
.admin-nav a:hover, .admin-nav a.active { color: #fff; }
.admin-nav a.active::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 2px;
    background: var(--c-brand-2); border-radius: 2px;
}

.admin-user {
    display: inline-flex; align-items: center; gap: 12px;
    color: #cfd6e2; font-size: 13px;
}
.admin-user .btn-ghost { color: #fff; border-color: rgba(255,255,255,.25); }
.admin-user .btn-ghost:hover { color: var(--c-brand-2); border-color: var(--c-brand-2); }

/* ---------- Page head ---------- */
.page-head { margin-bottom: 24px; }
.page-head--with-action {
    display: flex; justify-content: space-between; align-items: flex-end; gap: 16px;
    flex-wrap: wrap;
}
.eyebrow {
    text-transform: uppercase; letter-spacing: .12em;
    font-size: 11px; font-weight: 800; color: var(--c-brand);
    margin: 0 0 6px;
}
.page-head h1 {
    margin: 0 0 6px; font-size: 28px; font-weight: 800; letter-spacing: -.01em;
}
.lede { margin: 0; color: var(--c-ink-soft); font-size: 15px; }

/* ---------- Cards / panels ---------- */
.panel {
    background: var(--c-surface);
    border: 1px solid var(--c-line);
    border-radius: var(--radius);
    padding: 20px 22px;
    margin-bottom: 22px;
    box-shadow: var(--shadow-sm);
}
.panel-head { margin-bottom: 14px; }
.panel-head--with-action {
    display: flex; justify-content: space-between; align-items: flex-end; gap: 12px;
}
.panel-head h2 { margin: 0 0 4px; font-size: 17px; font-weight: 800; }
.panel-head p { margin: 0; color: var(--c-ink-soft); font-size: 13px; }

/* ---------- Summary stat row ---------- */
.stat-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 22px;
}
.stat-card {
    background: var(--c-surface);
    border: 1px solid var(--c-line);
    border-radius: var(--radius);
    padding: 18px 18px 16px;
    box-shadow: var(--shadow-sm);
    border-top: 3px solid var(--c-brand);
}
.stat-card--ok    { border-top-color: var(--c-success); }
.stat-card--warn  { border-top-color: var(--c-warn); }
.stat-card--alert { border-top-color: var(--c-danger); }
.stat-label {
    text-transform: uppercase; letter-spacing: .1em;
    font-size: 11px; font-weight: 700; color: var(--c-ink-soft);
    display: block; margin-bottom: 8px;
}
.stat-value {
    font-size: 22px; font-weight: 800; color: var(--c-ink); letter-spacing: -.01em;
    line-height: 1.1; display: block;
}
.stat-sub { display: block; margin-top: 4px; font-size: 12px; color: var(--c-ink-soft); }
.stat-value--name {
    font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- Per-payer strip ---------- */
.payer-strip {
    display: flex; flex-wrap: wrap; gap: 10px;
    margin-bottom: 18px;
}
.payer-chip {
    background: var(--c-surface);
    border: 1px solid var(--c-line);
    border-radius: 999px;
    padding: 8px 16px;
    display: inline-flex; align-items: center; gap: 10px;
    color: var(--c-ink);
    font-size: 13px;
    transition: border-color .15s ease, transform .15s ease;
}
.payer-chip:hover {
    border-color: var(--c-brand);
    color: var(--c-ink);
    transform: translateY(-1px);
}
.payer-name { font-weight: 600; }
.payer-total { color: var(--c-brand); font-weight: 800; }
.payer-count { color: var(--c-ink-soft); font-size: 11px; }

/* ---------- Filter bar ---------- */
.filter-bar {
    display: flex; flex-wrap: wrap; gap: 8px;
    margin-bottom: 16px;
}
.filter-bar input[type="text"],
.filter-bar select {
    background: var(--c-surface);
    border: 1px solid var(--c-line);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 14px; font-family: inherit;
    color: var(--c-ink);
}
.filter-bar input[type="text"] { flex: 1 1 200px; min-width: 0; }
.filter-clear { font-size: 12px; color: var(--c-ink-soft); align-self: center; }

/* ---------- Tables ---------- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.data-table th, .data-table td {
    padding: 10px 12px;
    text-align: start;
    border-bottom: 1px solid var(--c-line);
    vertical-align: middle;
}
.data-table th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 800;
    color: var(--c-ink-soft);
}
.data-table tbody tr:hover { background: var(--c-bg); }
.data-table tfoot th { color: var(--c-ink); font-size: 13px; padding-top: 14px; }
.data-table .num { text-align: end; font-variant-numeric: tabular-nums; }
.data-table .truncate {
    max-width: 280px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.muted { color: var(--c-ink-soft); }

/* ---------- Pills (status) ---------- */
.pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.pill-paid       { background: rgba(20,160,122,.12); color: var(--c-success); }
.pill-pending    { background: rgba(214,138,0,.14);  color: var(--c-warn); }
.pill-overdue    { background: rgba(195,58,58,.12);  color: var(--c-danger); }
.pill-reimbursed { background: rgba(43,108,255,.12); color: var(--c-brand); }

/* ---------- Spec table (single invoice view) ---------- */
.spec {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.spec th, .spec td {
    padding: 12px 14px;
    text-align: start;
    border-bottom: 1px solid var(--c-line);
}
.spec th {
    width: 30%;
    font-weight: 700;
    color: var(--c-ink-soft);
    background: var(--c-bg);
}
.spec tr:last-child th, .spec tr:last-child td { border-bottom: 0; }

/* ---------- Forms ---------- */
.invoice-form .form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px 22px;
}
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field span:first-child {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--c-ink-soft);
}
.field .req { color: var(--c-danger); }
.field input[type="text"],
.field input[type="number"],
.field input[type="date"],
.field input[type="email"],
.field input[type="password"],
.field input[type="tel"],
.field input[type="file"],
.field select,
.field textarea,
.login-form input {
    background: var(--c-surface);
    border: 1px solid var(--c-line);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 14px; font-family: inherit;
    color: var(--c-ink);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus,
.field select:focus,
.field textarea:focus,
.login-form input:focus {
    outline: none;
    border-color: var(--c-brand);
    box-shadow: 0 0 0 3px rgba(43,108,255,.15);
}
.field textarea { resize: vertical; min-height: 60px; font-family: inherit; }
.field .err { color: var(--c-danger); font-size: 12px; }

.payer-row {
    display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch;
}
.payer-row select,
.payer-row input[type="text"] {
    flex: 1 1 220px; min-width: 0;
}
.payer-row .btn { flex: 0 0 auto; align-self: stretch; }
[hidden] { display: none !important; }

.form-actions {
    display: flex; gap: 10px; margin-top: 22px;
    border-top: 1px solid var(--c-line);
    padding-top: 18px;
}

.danger-zone {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px dashed var(--c-line);
    text-align: end;
}

/* ---------- Flash messages ---------- */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin: 0 auto 16px;
    max-width: 1180px;
    font-size: 14px;
    box-shadow: var(--shadow-sm);
}
main + .flash, .container .flash { margin-bottom: 18px; }
.flash-success { background: #e7f8f1; color: #0f6b54; border: 1px solid #b6e6d4; }
.flash-error   { background: #fbe9e9; color: #8a2424; border: 1px solid #f0bcbc; }
.flash-info    { background: #e7eefb; color: #1b3d8f; border: 1px solid #c2d3ef; }
.flash-warn    { background: #fff5e0; color: #7a5300; border: 1px solid #f0d59a; }

.empty {
    color: var(--c-ink-soft);
    text-align: center;
    padding: 24px 0;
    font-size: 14px;
}
.empty.good { color: var(--c-success); font-weight: 600; }

/* ---------- Edit/View head actions ---------- */
.head-actions { display: flex; gap: 8px; align-items: center; }
.row-actions { display: flex; gap: 10px; white-space: nowrap; }
.row-actions a { font-size: 13px; }

.link-danger {
    background: none; border: 0; padding: 0; cursor: pointer;
    color: var(--c-danger); font: inherit; font-size: 13px;
}
.link-danger:hover { text-decoration: underline; }

.link-restore {
    background: none; border: 0; padding: 0; cursor: pointer;
    color: var(--c-success); font: inherit; font-size: 13px;
}
.link-restore:hover { text-decoration: underline; }

/* Category pill for documents */
.cat-badge {
    display: inline-block; padding: 2px 10px; border-radius: 999px;
    background: rgba(43,108,255,.10); color: var(--c-brand-dk);
    font-size: 12px; font-weight: 600; letter-spacing: .02em;
}

/* Active chip state (payer-chip / category chip) */
.payer-chip.is-active {
    border-color: var(--c-brand); box-shadow: 0 0 0 2px rgba(43,108,255,.18);
}

/* Recycle bin row styling — slightly muted */
.row-trashed td { opacity: .85; }
.row-trashed td:first-child a { color: var(--c-ink-soft); }
.row-trashed td:first-child a:hover { color: var(--c-brand); }

/* Trash counter badge in header */
.badge {
    display: inline-block; min-width: 18px; padding: 1px 6px;
    background: var(--c-danger); color: #fff; border-radius: 999px;
    font-size: 11px; font-weight: 700; line-height: 1.4;
    margin-left: 4px; text-align: center;
}

/* ---------- Attachment radios on edit form ---------- */
.doc-fieldset {
    border: 1px solid var(--c-line);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
}
.doc-fieldset legend {
    padding: 0 6px; font-weight: 700; font-size: 13px; color: var(--c-ink-soft);
    text-transform: uppercase; letter-spacing: .08em;
}
.doc-current { margin: 0 0 10px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.doc-radios {
    display: flex; flex-direction: column; gap: 6px;
    margin: 8px 0 12px;
}
.doc-radios label { font-size: 14px; cursor: pointer; }

/* Multi-file attachment list (invoice + document views/edits) */
.attachment-list {
    list-style: none; padding: 0; margin: 0 0 12px;
    display: flex; flex-direction: column; gap: 6px;
}
.attachment-list li {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    padding: 6px 0;
}
.attachment-list li > label {
    font-size: 13px; color: var(--c-ink-soft); cursor: pointer;
    display: inline-flex; align-items: center; gap: 4px;
}
.field-block { display: block; margin-top: 10px; }
.field-block > span { display: block; font-weight: 600; margin-bottom: 4px; }

/* ---------- Balances: settlement list + net colors ---------- */
.settle-list {
    list-style: none; padding: 0; margin: 0;
    display: flex; flex-direction: column; gap: 8px;
}
.settle-list li {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 12px 14px;
    background: #fffbf2;
    border: 1px solid #f0d59a;
    border-radius: var(--radius-sm);
}
.settle-list .owes { flex: 1 1 auto; }
.settle-list .amt {
    font-size: 16px; color: var(--c-warn); white-space: nowrap;
}

.net-pos  { color: var(--c-success); font-weight: 700; }
.net-neg  { color: var(--c-danger);  font-weight: 700; }
.net-even { color: var(--c-ink-soft); font-weight: 600; }
.net-pos small, .net-neg small {
    display: block; font-weight: 500; font-size: 11px; opacity: .8;
    text-transform: uppercase; letter-spacing: .08em;
}

/* ---------- Footer ---------- */
.admin-footer {
    text-align: center;
    padding: 24px 16px 32px;
    color: var(--c-ink-soft);
    font-size: 12px;
}

/* ---------- Login screen ---------- */
.login-shell {
    min-height: 100vh;
    display: grid; place-items: center;
    padding: 24px;
    background:
      radial-gradient(40% 60% at 20% 30%, rgba(43,108,255,.10), transparent 60%),
      radial-gradient(35% 55% at 80% 20%, rgba(62,224,200,.10), transparent 60%),
      var(--c-bg);
}
.login-card {
    width: 100%; max-width: 400px;
    background: var(--c-surface);
    border: 1px solid var(--c-line);
    border-radius: 16px;
    padding: 32px 28px;
    box-shadow: var(--shadow);
}
.login-brand { text-align: center; margin-bottom: 18px; }
.login-brand svg { margin: 0 auto 6px; }
.login-brand h1 {
    margin: 0; font-size: 20px; font-weight: 800; color: var(--c-ink);
}
.login-brand p { margin: 4px 0 0; color: var(--c-ink-soft); font-size: 13px; }
.login-form {
    display: flex; flex-direction: column; gap: 8px;
}
.login-form label {
    font-size: 12px; font-weight: 700; letter-spacing: .04em;
    text-transform: uppercase; color: var(--c-ink-soft);
    margin-top: 8px;
}
.login-form .btn { margin-top: 18px; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
    .container { padding: 20px 16px 48px; }
    .stat-row { grid-template-columns: 1fr 1fr; }
    .admin-header-inner { padding: 12px 16px; gap: 10px; flex-wrap: wrap; }
    .admin-nav { width: 100%; order: 3; justify-content: flex-start; gap: 14px; overflow-x: auto; }
    .admin-user-name { display: none; }
    .invoice-form .form-grid { grid-template-columns: 1fr; }
    .data-table { font-size: 13px; }
    .data-table .truncate { max-width: 140px; }
    .spec th { width: 38%; }
}
