/* ==========================================================================
   CopyThat admin panel
   Self-contained stylesheet (no CDN) so the panel works offline.
   ========================================================================== */

:root {
    --bg: #f4f6fb;
    --panel: #ffffff;
    --ink: #0f172a;
    --ink-soft: #334155;
    --muted: #6b7280;
    --line: #e5e9f2;
    --brand: #4f46e5;
    --brand-dark: #4338ca;
    --brand-soft: #eef2ff;
    --good: #047857;
    --good-soft: #ecfdf5;
    --warn: #b45309;
    --warn-soft: #fffbeb;
    --bad: #b91c1c;
    --bad-soft: #fef2f2;
    --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .04);
    --radius: 14px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    background: var(--bg);
    color: var(--ink);
    font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }

h1, h2, h3, h4 { margin: 0; color: var(--ink); font-weight: 650; letter-spacing: -.01em; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }

/* ---------------------------------------------------------------- Shell -- */

.admin-shell { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 248px;
    display: flex;
    flex-direction: column;
    gap: 26px;
    padding: 22px 16px;
    background: #0f172a;
    color: #cbd5e1;
    z-index: 20;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 0 6px; }
.brand-mark {
    width: 38px; height: 38px; border-radius: 11px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, #6366f1, #4338ca);
    color: #fff; font-weight: 800; font-size: 15px; letter-spacing: -.04em;
    box-shadow: 0 6px 16px rgba(79, 70, 229, .4);
}
.brand-name { color: #fff; font-weight: 700; font-size: 16px; line-height: 1.1; }
.brand-name span { display: block; color: #94a3b8; font-size: 10px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; margin-top: 3px; }

.side-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.side-label { color: #64748b; font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; padding: 0 10px 8px; }
.side-link {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 10px;
    color: #cbd5e1; font-weight: 550; font-size: 13.5px;
    border-left: 3px solid transparent;
    transition: background .15s ease, color .15s ease;
}
.side-link:hover { background: rgba(148, 163, 184, .1); color: #fff; }
.side-link.active { background: rgba(99, 102, 241, .18); color: #fff; border-left-color: #818cf8; }
.side-link .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .55; }
.side-link.active .dot { opacity: 1; background: #a5b4fc; }

.side-foot { border-top: 1px solid rgba(148, 163, 184, .16); padding-top: 16px; }
.who { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; padding: 0 4px; min-width: 0; }
.who-avatar {
    width: 34px; height: 34px; flex: none; border-radius: 50%;
    display: grid; place-items: center; background: #1e293b; color: #c7d2fe;
    font-weight: 700; font-size: 13px;
}
.who-text { min-width: 0; }
.who-name { color: #f1f5f9; font-weight: 600; font-size: 13px; }
.who-mail { color: #94a3b8; font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { flex: 1; min-width: 0; margin-left: 248px; display: flex; flex-direction: column; }

.topbar {
    display: flex; align-items: flex-end; justify-content: space-between; gap: 18px;
    padding: 22px 30px 18px;
    background: rgba(255, 255, 255, .82);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(8px);
    position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 21px; }
.topbar .sub { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.content { padding: 24px 30px 40px; }

@media (max-width: 960px) {
    .admin-shell { display: block; }
    .sidebar { position: static; width: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 14px; padding: 14px 18px; }
    .side-nav { flex-direction: row; flex-wrap: wrap; flex: 1 1 100%; gap: 6px; }
    .side-label, .side-foot { display: none; }
    .main { margin-left: 0; }
    .topbar { position: static; padding: 18px; }
    .content { padding: 18px; }
}

/* ---------------------------------------------------------------- Cards -- */

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 15px; }
.card-head .sub { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.card-body { padding: 18px 20px; }
.card-body.flush { padding: 0; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.stat::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--brand); opacity: .85; }
.stat.good::after { background: var(--good); }
.stat.warn::after { background: var(--warn); }
.stat.bad::after { background: var(--bad); }
.stat-label { color: var(--muted); font-size: 11.5px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; }
.stat-value { margin-top: 8px; font-size: 26px; font-weight: 750; letter-spacing: -.02em; }
.stat-foot { margin-top: 6px; color: var(--muted); font-size: 12px; }

.grid-2 { display: grid; grid-template-columns: 1.35fr 1fr; gap: 18px; }
.grid-2 + .grid-2 { margin-top: 18px; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) { .stats-grid { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- Chart -- */

.chart { display: flex; align-items: flex-end; gap: 14px; height: 210px; padding: 10px 4px 0; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; }
.bar-track { width: 100%; flex: 1; display: flex; align-items: flex-end; }
.bar-fill {
    width: 100%; border-radius: 8px 8px 4px 4px;
    background: linear-gradient(180deg, #818cf8, #4f46e5);
    min-height: 6px; transition: height .3s ease;
    position: relative;
}
.bar:hover .bar-fill { background: linear-gradient(180deg, #a5b4fc, #4338ca); }
.bar-label { color: var(--muted); font-size: 11.5px; font-weight: 600; }
.bar-value { color: var(--ink-soft); font-size: 11.5px; font-weight: 650; }

/* --------------------------------------------------------------- Tables -- */

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.table th {
    text-align: left; padding: 11px 16px;
    color: var(--muted); font-size: 10.5px; font-weight: 700;
    letter-spacing: .09em; text-transform: uppercase;
    background: #f8fafc; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.table td { padding: 12px 16px; border-bottom: 1px solid #eef1f7; vertical-align: middle; }
table.table tbody tr:last-child td { border-bottom: 0; }
table.table tbody tr:hover { background: #fafbff; }
.cell-main { font-weight: 600; color: var(--ink); }
.cell-sub { color: var(--muted); font-size: 12px; }
.avatar-row { display: flex; align-items: center; gap: 10px; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%; flex: none;
    display: grid; place-items: center; font-weight: 700; font-size: 12px;
    background: var(--brand-soft); color: var(--brand-dark); text-transform: uppercase;
}

.empty { padding: 40px 18px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); margin-bottom: 4px; }

/* --------------------------------------------------------------- Badges -- */

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 650; letter-spacing: .01em; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.brand { background: var(--brand-soft); color: var(--brand-dark); }
.badge.neutral { background: #f1f5f9; color: #475569; }
.badge.plain::before { display: none; }

/* --------------------------------------------------------------- Buttons -- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 8px 14px; border-radius: 9px; border: 1px solid transparent;
    font-family: inherit; font-size: 13px; font-weight: 600; line-height: 1.2;
    cursor: pointer; transition: background .15s ease, border-color .15s ease, color .15s ease;
    text-decoration: none;
}
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 6px 14px rgba(79, 70, 229, .25); }
.btn-primary:hover { background: var(--brand-dark); color: #fff; }
.btn-outline { background: #fff; border-color: var(--line); color: var(--ink-soft); }
.btn-outline:hover { border-color: #c7d2fe; color: var(--brand-dark); background: #fbfbff; }
.btn-danger { background: #fff; border-color: #fecaca; color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-ghost { background: transparent; color: #cbd5e1; border-color: rgba(148, 163, 184, .3); }
.btn-ghost:hover { background: rgba(148, 163, 184, .12); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form { display: inline; }

/* ---------------------------------------------------------------- Forms -- */

.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label { font-size: 11.5px; font-weight: 650; color: var(--ink-soft); }
.field .hint { color: var(--muted); font-size: 11.5px; }
.input, .select, .textarea {
    width: 100%; padding: 8px 11px; border: 1px solid var(--line); border-radius: 9px;
    background: #fff; color: var(--ink); font-family: inherit; font-size: 13px;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus, .select:focus, .textarea:focus {
    outline: none; border-color: #a5b4fc; box-shadow: 0 0 0 3px rgba(99, 102, 241, .14);
}
.textarea { resize: vertical; min-height: 92px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .span-2 { grid-column: span 2; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } .form-grid .span-2 { grid-column: auto; } }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 6px; }
.error-text { color: var(--bad); font-size: 12px; margin-top: 3px; }

/* --------------------------------------------------------------- Alerts -- */

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: 11px; font-size: 13px; margin-bottom: 16px; border: 1px solid transparent; }
.alert-success { background: var(--good-soft); border-color: #a7f3d0; color: var(--good); }
.alert-error { background: var(--bad-soft); border-color: #fecaca; color: var(--bad); }
.alert ul { margin: 4px 0 0; padding-left: 18px; }
.alert a { color: inherit; font-weight: 650; text-decoration: underline; }

/* ----------------------------------------------------------- Pagination -- */

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.pagination .pages { display: flex; gap: 6px; align-items: center; }
.page-link {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 32px; height: 32px; padding: 0 10px; border-radius: 8px;
    border: 1px solid var(--line); background: #fff; color: var(--ink-soft);
    font-size: 12.5px; font-weight: 600;
}
.page-link:hover { border-color: #c7d2fe; color: var(--brand-dark); }
.page-link.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.page-link.disabled { opacity: .45; pointer-events: none; }
.page-info { color: var(--muted); font-size: 12px; }

/* ------------------------------------------------------------ Dashboard -- */

.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; border-bottom: 1px solid #eef1f7; }
.list-item:last-child { border-bottom: 0; }
.list-item .main-text { font-weight: 600; font-size: 13px; }
.list-item .sub-text { color: var(--muted); font-size: 12px; }
.delta { font-size: 12px; font-weight: 650; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }

/* --------------------------------------------------------------- Detail -- */

.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 800px) { .detail-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .detail-grid { grid-template-columns: 1fr; } }
.detail-item .label { color: var(--muted); font-size: 11px; font-weight: 650; letter-spacing: .07em; text-transform: uppercase; }
.detail-item .value { margin-top: 3px; font-weight: 600; font-size: 14px; }
.receipt-image { max-width: 100%; border-radius: 12px; border: 1px solid var(--line); display: block; }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; }
.thumb { width: 68px; height: 44px; object-fit: cover; border-radius: 7px; border: 1px solid var(--line); display: block; }

/* ----------------------------------------------------------------- Auth -- */

.auth {
    min-height: 100vh; display: grid; place-items: center; padding: 24px;
    background:
        radial-gradient(900px 500px at 12% -10%, rgba(99, 102, 241, .28), transparent 60%),
        radial-gradient(700px 500px at 100% 110%, rgba(14, 165, 233, .18), transparent 55%),
        #0f172a;
}
.auth-card { width: 100%; max-width: 410px; background: #fff; border-radius: 18px; box-shadow: 0 30px 70px rgba(2, 6, 23, .45); padding: 30px; }
.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; }
.auth h1 { font-size: 21px; }
.auth .lead { color: var(--muted); font-size: 13px; margin: 5px 0 22px; }
.auth .field + .field { margin-top: 14px; }
.auth .btn { margin-top: 20px; }
.auth-foot { margin-top: 18px; color: var(--muted); font-size: 11.5px; text-align: center; }
.auth .alert { margin-bottom: 16px; }

/* ------------------------------------------------------------- Print/UX -- */

:focus-visible { outline: 2px solid #818cf8; outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ------------------------------------------------------ Summary strips -- */

.summary-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1px;
    background: var(--line);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
.summary-cell {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 15px 18px;
    background: var(--panel);
    color: inherit;
    transition: background .15s ease;
}
a.summary-cell:hover { background: #fbfbff; color: inherit; }
.summary-label { color: var(--muted); font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.summary-value { font-size: 21px; font-weight: 750; letter-spacing: -.02em; }
.summary-note { color: var(--muted); font-size: 11.5px; }
@media (max-width: 900px) { .summary-strip { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .summary-strip { grid-template-columns: 1fr; } }

/* ------------------------------------------------------ Mini bar lists -- */

.mini-list { display: flex; flex-direction: column; gap: 9px; margin-top: 18px; }
.mini-row { display: grid; grid-template-columns: minmax(110px, 1fr) 2fr auto; align-items: center; gap: 10px; font-size: 12.5px; }
.mini-name { color: var(--ink-soft); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-bar { display: block; height: 8px; border-radius: 999px; background: #eef1f7; overflow: hidden; }
.mini-fill { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #818cf8, #4f46e5); }
.mini-value { color: var(--ink); font-weight: 650; white-space: nowrap; }

.hint { color: var(--muted); font-size: 11.5px; }
.mt-18 { margin-top: 18px; }
