:root {
  --bg: #f3f0e9;
  --surface: #fffefb;
  --surface-2: #f8f5ef;
  --sidebar: #151310;
  --sidebar-2: #29231b;
  --text: #1e1a15;
  --muted: #71685e;
  --border: #e2dbcf;
  --gold: #b98221;
  --gold-dark: #76500e;
  --gold-soft: #fbf1d9;
  --success: #28704b;
  --success-soft: #e9f5ed;
  --warning: #9b5d12;
  --warning-soft: #fff2d9;
  --danger: #a73e39;
  --danger-soft: #fcedeb;
  --info: #285e7c;
  --info-soft: #eaf3f8;
  --shadow: 0 12px 34px rgba(48, 39, 27, .055), 0 1px 2px rgba(48, 39, 27, .04);
  --radius: 16px;
}

* { box-sizing: border-box; }
html { font-family: Inter, system-ui, sans-serif; color: var(--text); background: var(--bg); }
body { margin: 0; min-height: 100vh; min-height: 100dvh; background: var(--bg); }
button, input, select, textarea { font: inherit; }
button, a { touch-action: manipulation; }
button { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
a { color: var(--gold-dark); font-weight: 600; }
a:hover { color: var(--gold); }
:focus-visible { outline: 3px solid rgba(184, 132, 36, .42); outline-offset: 3px; }
.skip-link { position: fixed; left: 16px; top: -80px; z-index: 200; padding: 10px 14px; border-radius: 8px; background: var(--sidebar); color: #fff; transition: top .16s ease; }
.skip-link:focus { top: 16px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.boot-shell { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.boot-card { width: min(360px, 100%); text-align: center; padding: 38px 30px; }
.boot-logo { width: 72px; height: 72px; object-fit: contain; margin-bottom: 18px; }
.boot-card h1 { margin: 16px 0 8px; font-size: 23px; letter-spacing: -.035em; }
.boot-card p { margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.boot-spinner { width: 26px; height: 26px; margin: 0 auto; border: 3px solid #e2d7c5; border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.login-shell { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 28px; background: #ebe6dc; }
.login-card { position: relative; width: 100%; max-width: 440px; min-width: 0; padding: 42px 40px 34px; border: 1px solid #ded3c2; border-radius: 20px; background: var(--surface); box-shadow: 0 24px 70px rgba(48, 35, 21, .16); overflow: hidden; }
.login-card::before { content: ''; position: absolute; inset: 0 0 auto; height: 5px; background: var(--gold); }
.login-logo { display: block; width: 86px; height: 86px; object-fit: contain; margin: 0 auto 24px; }
.login-card h1 { font-size: 30px; line-height: 1.15; margin: 5px 0 12px; letter-spacing: -.035em; }
.login-card .muted { line-height: 1.65; margin: 0 0 26px; overflow-wrap: anywhere; }
.login-help { text-align: center; color: var(--muted); font-size: 13px; line-height: 1.5; margin: 20px 0 0; overflow-wrap: anywhere; }
.eyebrow { margin: 0 0 6px; text-transform: uppercase; letter-spacing: .13em; font-weight: 750; font-size: 11px; color: var(--gold-dark); }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 252px; padding: 20px 14px 16px; background: var(--sidebar); color: #f8f1e5; display: flex; flex-direction: column; z-index: 40; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 22px; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand img { width: 48px; height: 48px; object-fit: contain; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 18px; letter-spacing: -.02em; }
.brand span { font-size: 11px; color: #bdb2a3; margin-top: 4px; }
.sidebar nav { display: grid; gap: 4px; padding: 19px 0; overflow-y: auto; }
.nav-group { margin: 13px 10px 4px; color: #8e8171; font-size: 10px; text-transform: uppercase; letter-spacing: .13em; font-weight: 750; }
.nav-group:first-child { margin-top: 0; }
.nav-button { min-height: 45px; border: 1px solid transparent; border-radius: 10px; padding: 10px 12px; background: transparent; color: #c9c0b5; display: flex; align-items: center; gap: 12px; text-align: left; font-size: 13px; font-weight: 650; cursor: pointer; transition: background .18s, color .18s, border-color .18s; }
.nav-button:hover { color: #fffaf1; background: rgba(255,255,255,.07); }
.nav-button.active { color: #fffaf1; background: var(--sidebar-2); border-color: rgba(216,169,77,.38); box-shadow: inset 3px 0 var(--gold); }
.nav-button svg { width: 19px; height: 19px; stroke-width: 1.9; flex: 0 0 auto; }
.side-footer { margin-top: auto; border-top: 1px solid rgba(255,255,255,.12); padding: 15px 7px 0; display: grid; gap: 9px; }
.side-footer span { font-size: 11px; color: #a99e91; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-footer .btn { justify-content: flex-start; color: #eadfcf; padding-inline: 6px; }
.sidebar-backdrop { display: none; }

.workspace { margin-left: 252px; min-height: 100vh; }
.topbar { min-height: 78px; position: sticky; top: 0; z-index: 20; background: rgba(248,245,239,.96); display: flex; align-items: center; gap: 17px; padding: 14px 30px; border-bottom: 1px solid var(--border); }
.topbar h1 { margin: 0; font-size: 26px; line-height: 1.15; letter-spacing: -.04em; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.live-indicator { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 650; }
.live-indicator i { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px var(--success-soft); }
.content { padding: 26px 30px 56px; max-width: 1540px; margin: auto; transition: opacity .16s ease; }
.mobile-only { display: none !important; }

.btn { min-height: 44px; border: 1px solid transparent; border-radius: 10px; padding: 10px 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; font-size: 13px; cursor: pointer; transition: background .18s, border-color .18s, color .18s, box-shadow .18s, transform .18s; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .52; cursor: not-allowed; transform: none; }
.btn.is-loading svg, .icon-btn.is-loading svg { animation: spin .8s linear infinite; }
.btn svg, .icon-btn svg { width: 17px; height: 17px; stroke-width: 2; }
.btn-primary { background: var(--gold); color: #fffdf8; border-color: var(--gold); box-shadow: 0 4px 12px rgba(184,132,36,.20); }
.btn-primary:hover { background: var(--gold-dark); border-color: var(--gold-dark); }
.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--surface-2); border-color: #cdbd9f; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-ghost { background: transparent; color: var(--text); }
.btn-wide { width: 100%; min-height: 50px; }
.btn-wide svg { width: 21px; height: 21px; }
.icon-btn { width: 44px; height: 44px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); display: grid; place-items: center; cursor: pointer; color: var(--text); }
.icon-btn:hover { background: var(--surface-2); border-color: #cdbd9f; }

.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.toolbar .search { flex: 1; max-width: 480px; }
.toolbar-actions { margin-left: auto; display: flex; gap: 9px; }
.field { display: grid; gap: 7px; }
.field label { font-size: 12px; font-weight: 700; color: #4f453a; }
.input, .select, .textarea { width: 100%; border: 1px solid #d7ccbb; background: var(--surface); color: var(--text); border-radius: 9px; padding: 11px 13px; min-height: 44px; }
.textarea { min-height: 104px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: #a39789; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--gold); outline: 3px solid rgba(184,132,36,.15); }
.search { position: relative; }
.search svg { position: absolute; left: 13px; top: 13px; width: 18px; color: #a39789; pointer-events: none; }
.search input { padding-left: 42px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 17px; }
.field.full { grid-column: 1 / -1; }
.check-row { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.check-row input { width: 18px; height: 18px; accent-color: var(--gold); }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; margin-bottom: 22px; }
.metric-card, .panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.metric-card { position: relative; min-height: 144px; padding: 19px 19px 18px; overflow: hidden; }
.metric-card::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--gold); }
.metric-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 12px; font-weight: 700; }
.metric-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--gold-soft); color: var(--gold-dark); }
.metric-icon svg { width: 19px; height: 19px; }
.metric-value { display: block; font-size: 28px; letter-spacing: -.045em; margin: 18px 0 5px; }
.metric-note { font-size: 11px; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1.35fr 1fr; gap: 18px; }
.panel { overflow: hidden; }
.panel-header { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.panel-header h2 { font-size: 16px; margin: 0; letter-spacing: -.01em; }
.panel-header p { font-size: 12px; color: var(--muted); margin: 5px 0 0; }
.panel-actions { margin-left: auto; }
.panel-body { padding: 20px; }
.quick-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 11px; }
.quick-action { min-height: 65px; display: flex; align-items: center; gap: 12px; padding: 13px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text); cursor: pointer; text-align: left; transition: border-color .18s, background .18s, transform .18s; }
.quick-action:hover { border-color: #cdbd9f; background: var(--gold-soft); transform: translateY(-1px); }
.quick-action svg { width: 19px; color: var(--gold-dark); flex: 0 0 auto; }

.table-wrap { overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; white-space: nowrap; }
.data-table th { position: sticky; top: 0; z-index: 1; text-align: left; padding: 13px 16px; background: #faf7f1; color: #675d51; font-weight: 750; border-bottom: 1px solid var(--border); }
.data-table td { padding: 14px 16px; border-bottom: 1px solid #eee8de; vertical-align: middle; }
.data-table tr:hover td { background: #fffcf5; }
.data-table tr:last-child td { border-bottom: 0; }
.cell-main { font-weight: 700; color: var(--text); }
.cell-sub { font-size: 11px; color: var(--muted); margin-top: 4px; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.status { display: inline-flex; align-items: center; gap: 5px; padding: 5px 9px; border-radius: 999px; font-size: 10px; font-weight: 750; text-transform: capitalize; background: #f1eee8; color: #655b50; }
.status.active, .status.approved, .status.published, .status.successful, .status.resolved { background: var(--success-soft); color: var(--success); }
.status.submitted, .status.pending, .status.under_review, .status.action_required { background: var(--warning-soft); color: var(--warning); }
.status.suspended, .status.rejected, .status.failed, .status.revoked, .status.blocked { background: var(--danger-soft); color: var(--danger); }
.status.new, .status.changes_requested, .status.escalated { background: var(--info-soft); color: var(--info); }
.row-actions { display: flex; gap: 7px; }
.row-actions .btn { min-height: 36px; padding: 7px 10px; font-size: 11px; }
.avatar-cell { display: flex; align-items: center; gap: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 11px; background: #eee7dc; object-fit: contain; object-position: center; }
.avatar-fallback { display: grid; place-items: center; font-weight: 750; color: var(--gold-dark); }
.pagination { display: flex; justify-content: space-between; align-items: center; padding: 14px 17px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.page-controls { display: flex; align-items: center; gap: 8px; }

.settings-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, .7fr); gap: 18px; align-items: start; }
.section-gap { margin-top: 20px; }
.metrics-compact .metric-card { min-height: 124px; }
.admin-form { display: grid; gap: 20px; }
.field small { color: var(--muted); font-size: 11px; line-height: 1.45; }
.textarea-short { min-height: 78px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); cursor: pointer; }
.switch-row > span { display: grid; gap: 5px; line-height: 1.35; }
.switch-row strong { font-size: 13px; }
.switch-row small { color: var(--muted); font-size: 11px; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch-row i { position: relative; flex: 0 0 auto; width: 46px; height: 26px; border-radius: 999px; background: #c9c2b7; box-shadow: inset 0 1px 3px rgba(45,35,22,.18); transition: background .18s ease; }
.switch-row i::after { content: ''; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(45,35,22,.22); transition: transform .18s ease; }
.switch-row input:checked + i { background: var(--gold); }
.switch-row input:checked + i::after { transform: translateX(20px); }
.switch-row:has(input:focus-visible) { outline: 3px solid rgba(184,132,36,.28); outline-offset: 2px; }
.form-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 2px; }
.form-actions p { display: flex; align-items: center; gap: 7px; margin: 0; color: var(--muted); font-size: 11px; }
.form-actions p svg { width: 16px; height: 16px; color: var(--gold-dark); }
.info-panel { background: var(--sidebar); color: #f7efe3; border-color: #2d271f; box-shadow: 0 18px 50px rgba(31,25,18,.15); }
.info-panel h2 { margin: 15px 0 10px; font-size: 18px; }
.info-panel ol { margin: 0; padding-left: 19px; color: #c9bfb0; font-size: 12px; line-height: 1.65; }
.feature-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: rgba(185,130,33,.18); color: #e6b94f; border: 1px solid rgba(230,185,79,.2); }
.feature-icon svg { width: 22px; height: 22px; }
.mini-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 18px; }
.mini-stats span { display: grid; gap: 3px; padding: 12px; border-radius: 10px; background: rgba(255,255,255,.055); color: #aa9f91; font-size: 10px; }
.mini-stats strong { color: #fff6e7; font-size: 18px; }
.form-error { grid-column: 1 / -1; display: flex; gap: 9px; align-items: flex-start; padding: 12px 13px; border: 1px solid #e8b8b3; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-size: 12px; line-height: 1.45; }
.form-error svg { flex: 0 0 auto; width: 17px; height: 17px; }

.empty { padding: 58px 24px; text-align: center; color: var(--muted); }
.empty svg { width: 36px; height: 36px; margin-bottom: 13px; color: #a39789; }
.empty h3 { color: var(--text); font-size: 16px; margin: 0 0 7px; }
.empty p { max-width: 420px; margin: 0 auto 17px; line-height: 1.55; }
.skeleton { height: 280px; border-radius: var(--radius); background: linear-gradient(90deg, #faf7f1, #eee7db, #faf7f1); background-size: 200% 100%; animation: loading 1.2s infinite; }
.loading-stack { display: grid; gap: 18px; }
.skeleton-title, .skeleton-card { background: linear-gradient(90deg, #faf7f1, #eae3d6, #faf7f1); background-size: 200% 100%; animation: loading 1.2s infinite; }
.skeleton-title { width: 190px; height: 18px; border-radius: 7px; }
.skeleton-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; }
.skeleton-card { height: 142px; border: 1px solid var(--border); border-radius: var(--radius); }
@keyframes loading { to { background-position: -200% 0; } }

.dialog { padding: 0; border: 0; border-radius: 18px; width: min(720px, calc(100% - 28px)); max-height: 90vh; background: var(--surface); color: var(--text); box-shadow: 0 28px 90px rgba(34,27,18,.32); overflow: hidden; }
.dialog::backdrop { background: rgba(35, 27, 18, .56); }
.dialog-card { display: grid; grid-template-rows: auto minmax(0,1fr) auto; max-height: 90vh; }
.dialog-card header, .dialog-card footer { display: flex; align-items: center; padding: 18px 22px; }
.dialog-card header { border-bottom: 1px solid var(--border); }
.dialog-card header h2 { font-size: 20px; margin: 0; letter-spacing: -.025em; }
.dialog-card header .icon-btn { margin-left: auto; }
.dialog-body { padding: 22px; overflow: auto; max-height: 65vh; }
.danger-zone { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 20px; padding: 16px; border: 1px solid #e8b8b3; border-radius: 12px; background: var(--danger-soft); }
.danger-zone h3 { margin: 0 0 6px; color: var(--danger); font-size: 15px; }
.danger-zone p { margin: 0; color: #67433f; font-size: 12px; line-height: 1.55; }
.danger-icon { flex: 0 0 auto; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; background: #fff; color: var(--danger); box-shadow: 0 4px 14px rgba(143,47,37,.12); }
.danger-icon svg { width: 20px; height: 20px; }
.dialog-card footer { justify-content: flex-end; gap: 10px; border-top: 1px solid var(--border); background: var(--surface-2); }
.detail-list { display: grid; grid-template-columns: 155px 1fr; gap: 11px 18px; font-size: 13px; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.json-box { background: #211c17; color: #eee4d5; padding: 15px; border-radius: 10px; overflow: auto; font: 11px/1.6 ui-monospace, monospace; max-height: 280px; }
.toast-region { position: fixed; right: 22px; top: 22px; z-index: 100; display: grid; gap: 9px; }
.toast { min-width: 290px; max-width: 430px; padding: 13px 15px; border-radius: 10px; color: #fff; background: #2b241e; box-shadow: 0 12px 36px rgba(0,0,0,.18); font-size: 13px; line-height: 1.4; animation: toast-in .2s ease; }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }

@media (max-width: 1180px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .skeleton-grid { grid-template-columns: repeat(2, 1fr); }
  .settings-layout { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .mobile-only { display: grid !important; }
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; }
  .sidebar.open { transform: translateX(0); box-shadow: 20px 0 60px rgba(0,0,0,.25); }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 35; display: block; border: 0; background: rgba(35,27,18,.46); opacity: 0; pointer-events: none; transition: opacity .22s ease; }
  .sidebar-backdrop.visible { opacity: 1; pointer-events: auto; }
  .workspace { margin-left: 0; }
  .topbar { min-height: 74px; padding: 12px 17px; }
  .topbar h1 { font-size: 22px; }
  .live-indicator { display: none; }
  .content { padding: 20px 17px 42px; }
  .toolbar { align-items: stretch; flex-wrap: wrap; }
  .toolbar .search { max-width: none; width: 100%; }
  .toolbar-actions { margin-left: 0; width: 100%; overflow: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .form-actions { align-items: stretch; flex-direction: column; }
  .form-actions .btn { width: 100%; }
  .pagination { align-items: flex-start; gap: 12px; flex-direction: column; }
  .login-card { padding: 36px 24px 29px; }
  .data-table { min-width: 780px; }
}
@media (max-width: 520px) {
  html, body { overflow-x: hidden; }
  .login-shell { display: block; width: 100%; padding: 120px 16px 24px; overflow-x: hidden; }
  .login-card { width: 100% !important; max-width: 100% !important; }
  .metrics { grid-template-columns: 1fr; }
  .skeleton-grid { grid-template-columns: 1fr; }
  .quick-grid { grid-template-columns: 1fr; }
  .top-actions .btn { padding-inline: 10px; }
  .detail-list { grid-template-columns: 1fr; gap: 3px; }
  .detail-list dd { margin-bottom: 9px; }
  .dialog { width: calc(100% - 18px); max-height: calc(100dvh - 18px); }
  .dialog-card { max-height: calc(100dvh - 18px); }
  .dialog-card header, .dialog-card footer, .dialog-body { padding-inline: 17px; }
  .dialog-card footer .btn { flex: 1; }
  .switch-row { align-items: flex-start; }
  .toast-region { left: 14px; right: 14px; top: 14px; }
  .toast { min-width: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
