@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600&family=Fira+Sans:wght@400;500;600;700&display=swap');

:root {
    --primary: #1e293b;
    --secondary: #334155;
    --accent: #22c55e;
    --accent-dark: #052e16;
    --background: #0f172a;
    --background-soft: #121c31;
    --card: rgba(27, 35, 54, 0.88);
    --muted: #272f42;
    --text: #f8fafc;
    --text-muted: #aebed2;
    --border: #475569;
    --border-soft: rgba(148, 163, 184, 0.22);
    --danger: #f87171;
    --warning: #fbbf24;
    --ring: #ffffff;
    --radius: 16px;
    --shadow: 0 22px 55px rgba(2, 6, 23, 0.32);
    --font-body: "Fira Sans", system-ui, sans-serif;
    --font-mono: "Fira Code", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { background: var(--background); color: var(--text); font-family: var(--font-body); font-size: 16px; scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 75% -15%, rgba(34, 197, 94, 0.13), transparent 36rem), var(--background); line-height: 1.5; }
h1, h2, h3 { font-family: var(--font-mono); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
a { color: #86efac; text-underline-offset: 3px; }
a:hover { color: #bbf7d0; }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 3px; scroll-margin-top: 78px; }
.skip-link { position: fixed; z-index: 100; top: 12px; left: 12px; padding: 10px 14px; border-radius: 10px; background: #fff; color: #0f172a; transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.muted { color: var(--text-muted); }
.mono { font-family: var(--font-mono); font-size: .86rem; }
.eyebrow { margin: 0 0 7px; color: #86efac; font-family: var(--font-mono); font-size: .72rem; font-weight: 600; letter-spacing: .14em; }

.app-shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; display: flex; flex-direction: column; width: 260px; height: 100vh; padding: 24px 18px; border-right: 1px solid var(--border-soft); background: rgba(15, 23, 42, .83); backdrop-filter: blur(18px); }
.brand { display: flex; align-items: center; gap: 12px; min-height: 44px; color: var(--text); text-decoration: none; }
.brand:hover { color: var(--text); }
.brand-mark { display: block; width: 16px; height: 30px; border-radius: 6px; background: var(--accent); box-shadow: 0 0 26px rgba(34, 197, 94, .5); transform: skew(-10deg); }
.brand span:last-child { display: flex; flex-direction: column; }
.brand strong { letter-spacing: -.02em; }
.brand small { color: var(--text-muted); font-family: var(--font-mono); font-size: .66rem; text-transform: uppercase; letter-spacing: .1em; }
.sidebar nav { display: grid; gap: 6px; margin-top: 42px; }
.sidebar nav a { display: flex; align-items: center; min-height: 46px; padding: 0 14px; border: 1px solid transparent; border-radius: 11px; color: var(--text-muted); font-weight: 500; text-decoration: none; transition: background-color .18s ease, color .18s ease, border-color .18s ease; }
.sidebar nav a:hover { background: rgba(255,255,255,.05); color: var(--text); }
.sidebar nav a.active { border-color: rgba(34, 197, 94, .28); background: rgba(34, 197, 94, .1); color: #bbf7d0; }
.sidebar-footer { display: grid; gap: 12px; margin-top: auto; padding-top: 24px; border-top: 1px solid var(--border-soft); }
.admin-email { overflow: hidden; color: var(--text-muted); font-size: .82rem; text-overflow: ellipsis; }
.main-column { min-width: 0; }
.content { width: min(1480px, 100%); margin: 0 auto; padding: 42px 34px 72px; }
.mobile-header { display: none; }

.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.page-heading h1 { margin: 0; font-size: clamp(2rem, 3vw, 3rem); line-height: 1.08; letter-spacing: -.035em; }
.page-heading p:last-child { margin: 9px 0 0; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 17px; border: 1px solid transparent; border-radius: 10px; cursor: pointer; font-weight: 600; text-decoration: none; transition: transform .16s ease, background-color .16s ease, border-color .16s ease; }
.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(0) scale(.985); }
.button-primary { background: var(--accent); color: var(--accent-dark); }
.button-primary:hover { background: #4ade80; color: var(--accent-dark); }
.button-secondary { border-color: var(--border); background: var(--secondary); color: var(--text); }
.button-secondary:hover { background: #41516a; color: var(--text); }
.button-ghost { border-color: var(--border-soft); background: transparent; color: var(--text-muted); }
.button-ghost:hover { border-color: var(--border); color: var(--text); }
.button-small { min-height: 44px; padding: 0 12px; font-size: .82rem; }
.button-full { width: 100%; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric-card, .panel { border: 1px solid var(--border-soft); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); backdrop-filter: blur(16px); }
.metric-card { position: relative; display: grid; gap: 5px; min-height: 156px; padding: 22px; overflow: hidden; }
.metric-card::after { position: absolute; right: -20px; bottom: -44px; width: 120px; height: 120px; border-radius: 50%; background: rgba(148, 163, 184, .06); content: ""; }
.metric-card.accent { border-color: rgba(34, 197, 94, .34); background: linear-gradient(145deg, rgba(34, 197, 94, .13), var(--card)); }
.metric-card span { color: var(--text-muted); font-size: .84rem; }
.metric-card strong { font-family: var(--font-mono); font-size: 2.35rem; letter-spacing: -.06em; }
.metric-card small { color: var(--text-muted); }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(340px, .75fr); gap: 18px; }
.panel { margin-bottom: 18px; overflow: hidden; }
.narrow-panel { max-width: 920px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 78px; padding: 18px 22px; border-bottom: 1px solid var(--border-soft); }
.panel-heading h2 { margin: 0; font-size: 1.05rem; }
.panel-heading p { margin: 4px 0 0; color: var(--text-muted); font-size: .82rem; }
.panel-heading > a { font-size: .82rem; font-weight: 600; }
.empty-state { padding: 44px 24px; text-align: center; }
.empty-state h1, .empty-state strong { color: var(--text); }
.empty-state p { color: var(--text-muted); }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 13px 18px; color: var(--text-muted); font-size: .7rem; font-weight: 600; letter-spacing: .07em; text-align: left; text-transform: uppercase; }
td { padding: 15px 18px; border-top: 1px solid var(--border-soft); color: #e5edf8; vertical-align: middle; }
td strong { font-size: .9rem; }
.table-subtitle { display: block; margin-top: 3px; color: var(--text-muted); font-family: var(--font-mono); font-size: .68rem; }
.badge { display: inline-flex; align-items: center; min-height: 26px; padding: 3px 9px; border: 1px solid var(--border-soft); border-radius: 999px; background: var(--muted); color: var(--text-muted); font-family: var(--font-mono); font-size: .67rem; font-weight: 600; }
.badge-active { border-color: rgba(34, 197, 94, .35); background: rgba(34, 197, 94, .1); color: #bbf7d0; }
.badge-suspended { border-color: rgba(251, 191, 36, .35); background: rgba(251, 191, 36, .1); color: #fde68a; }
.badge-revoked { border-color: rgba(248, 113, 113, .35); background: rgba(248, 113, 113, .1); color: #fecaca; }
.badge-muted { color: #cbd5e1; }
.hash { display: block; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.context { max-width: 260px; overflow-wrap: anywhere; color: var(--text-muted); }
.row-actions { display: flex; justify-content: flex-end; gap: 8px; }
.row-actions form { margin: 0; }
.mono-button { min-height: 44px; padding: 0 8px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: #cbd5e1; cursor: pointer; font-family: var(--font-mono); font-size: .72rem; }
.mono-button:hover { border-color: var(--border); background: var(--muted); }
.switch { position: relative; width: 52px; height: 44px; padding: 0; border: 1px solid var(--border); border-radius: 999px; background: var(--muted); cursor: pointer; transition: background-color .16s ease; }
.switch span { position: absolute; top: 11px; left: 6px; width: 20px; height: 20px; border-radius: 50%; background: #cbd5e1; transition: transform .16s ease; }
.switch.on { border-color: var(--accent); background: rgba(34, 197, 94, .22); }
.switch.on span { background: var(--accent); transform: translateX(18px); }

.activity-list { padding: 8px 20px 16px; }
.activity-item { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; align-items: start; gap: 10px; padding: 15px 0; border-bottom: 1px solid var(--border-soft); }
.activity-item:last-child { border-bottom: 0; }
.activity-dot { width: 8px; height: 8px; margin-top: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px rgba(34, 197, 94, .5); }
.activity-item strong { display: block; font-size: .8rem; }
.activity-item small { display: block; margin-top: 3px; color: var(--text-muted); font-family: var(--font-mono); font-size: .65rem; }
.activity-item time { color: var(--text-muted); font-family: var(--font-mono); font-size: .59rem; white-space: nowrap; }

.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; padding: 22px; }
.form-stack { display: grid; gap: 18px; margin-top: 28px; }
.form-stack.compact { margin-top: 16px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field-full { grid-column: 1 / -1; }
.field label { color: #e5edf8; font-size: .83rem; font-weight: 600; }
.field label span { color: var(--text-muted); font-size: .72rem; font-weight: 400; }
.field input, .field select, .field textarea, .search-form input { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; background: rgba(15, 23, 42, .72); color: var(--text); }
.field textarea { resize: vertical; }
.field input[type="file"] { padding: 8px; }
.field input::file-selector-button { min-height: 30px; margin-right: 10px; padding: 0 12px; border: 0; border-radius: 6px; background: var(--secondary); color: var(--text); cursor: pointer; }
.field small { color: var(--text-muted); font-size: .72rem; }
.field .field-error { color: #fecaca; }
.field-check { justify-content: end; min-height: 72px; }
.field-check label { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.field-check input { width: 20px; min-height: 20px; accent-color: var(--accent); }
.readonly { display: flex; align-items: center; min-height: 46px; padding: 10px 12px; border: 1px dashed var(--border); border-radius: 9px; color: var(--text-muted); }
.form-actions { display: flex; justify-content: flex-end; padding-top: 4px; }
.search-form { display: flex; gap: 8px; width: min(420px, 100%); }
.search-form input { flex: 1; }
.card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.product-card { padding-bottom: 20px; }
.product-card form { padding: 0 22px; }
.detail-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 18px 22px; margin: 0; }
.detail-list div { padding: 12px; border-radius: 9px; background: rgba(15, 23, 42, .52); }
.detail-list dt { color: var(--text-muted); font-size: .73rem; }
.detail-list dd { margin: 5px 0 0; font-family: var(--font-mono); }
.flash { max-width: 100%; margin-bottom: 18px; padding: 13px 16px; border: 1px solid; border-radius: 10px; }
.flash-success { border-color: rgba(34, 197, 94, .38); background: rgba(34, 197, 94, .1); color: #bbf7d0; }
.flash-error { border-color: rgba(248, 113, 113, .38); background: rgba(248, 113, 113, .1); color: #fecaca; }

.auth-shell { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.auth-card { width: min(440px, 100%); padding: 34px; border: 1px solid var(--border-soft); border-radius: 22px; background: var(--card); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.auth-card-wide { width: min(520px, 100%); }
.auth-card h1 { margin: 0; font-size: 2rem; line-height: 1.15; letter-spacing: -.035em; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 42px; font-weight: 700; }

@media (max-width: 1120px) {
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 780px) {
    .app-shell { display: block; }
    .sidebar { position: fixed; z-index: 50; left: 0; width: min(300px, 86vw); visibility: hidden; transform: translateX(-105%); transition: transform .2s ease, visibility .2s ease; }
    .sidebar.open { visibility: visible; transform: translateX(0); }
    .mobile-header { position: sticky; z-index: 40; top: 0; display: flex; align-items: center; justify-content: space-between; min-height: 66px; padding: 8px 18px; border-bottom: 1px solid var(--border-soft); background: rgba(15, 23, 42, .9); backdrop-filter: blur(16px); }
    .mobile-header .brand { font-size: .9rem; }
    .mobile-header .brand-mark { width: 11px; height: 24px; }
    .menu-button { min-width: 64px; min-height: 44px; border: 1px solid var(--border); border-radius: 9px; background: var(--secondary); color: var(--text); cursor: pointer; }
    .content { padding: 28px 16px 60px; }
    .page-heading { align-items: stretch; flex-direction: column; }
    .search-form { width: 100%; }
    .metric-grid, .form-grid, .card-grid { grid-template-columns: 1fr; }
    .field-full { grid-column: auto; }
    .metric-card { min-height: 138px; }
    .panel-heading { align-items: flex-start; }
    table, thead, tbody, tr, th, td { display: block; }
    thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
    tr { padding: 12px 16px; border-top: 1px solid var(--border-soft); }
    tbody tr:first-child { border-top: 0; }
    td { display: grid; grid-template-columns: minmax(90px, .42fr) minmax(0, 1fr); align-items: center; min-height: 44px; padding: 6px 0; border: 0; text-align: right; }
    td::before { color: var(--text-muted); content: attr(data-label); font-size: .7rem; font-weight: 600; letter-spacing: .04em; text-align: left; text-transform: uppercase; }
    .table-subtitle { text-align: right; }
    .row-actions { flex-wrap: wrap; }
    .hash, .context { max-width: none; }
}

@media (max-width: 430px) {
    .auth-shell { padding: 14px; }
    .auth-card { padding: 26px 20px; }
    .metric-grid { grid-template-columns: 1fr; }
    .search-form { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
