@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Newsreader:opsz,wght@6..72,600&display=swap');

:root {
  color-scheme: light;
  --bg: #f2f5f4;
  --surface: #ffffff;
  --surface-soft: #e9efed;
  --surface-strong: #dce7e4;
  --ink: #142329;
  --muted: #66777c;
  --line: #d7e0de;
  --nav: #fbfcfc;
  --nav-soft: #eaf2f0;
  --nav-ink: #263b40;
  --nav-muted: #718589;
  --nav-line: #d8e4e1;
  --nav-hover: rgba(25, 127, 121, .08);
  --nav-active: #dcefeb;
  --nav-active-ink: #0f625e;
  --nav-avatar: #d9ebe8;
  --toast-bg: #091c25;
  --toast-ink: #eef6f5;
  --teal: #197f79;
  --teal-soft: #d9efeb;
  --gold: #b08748;
  --danger: #b44545;
  --danger-soft: #f9e4e2;
  --warning: #a66d16;
  --warning-soft: #fff1d6;
  --success: #377d5a;
  --shadow: 0 16px 38px rgba(24, 45, 50, .09);
  --radius: 18px;
  --sidebar-width: 270px;
  font-family: "DM Sans", system-ui, sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #08141a;
  --surface: #102229;
  --surface-soft: #152d34;
  --surface-strong: #1c3940;
  --ink: #edf5f2;
  --muted: #9eb0b3;
  --line: #274047;
  --nav: #061116;
  --nav-soft: #10262e;
  --nav-ink: #d8e5e6;
  --nav-muted: #81999e;
  --nav-line: #1b3842;
  --nav-hover: rgba(255, 255, 255, .06);
  --nav-active: #163742;
  --nav-active-ink: #ffffff;
  --nav-avatar: #24444e;
  --toast-bg: #061116;
  --toast-ink: #eef6f5;
  --teal: #5cc2b8;
  --teal-soft: #123d3b;
  --gold: #d4b274;
  --danger: #ed8882;
  --danger-soft: #482727;
  --warning: #e3b05e;
  --warning-soft: #423418;
  --success: #77c59d;
  --shadow: 0 20px 48px rgba(0, 0, 0, .24);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: var(--teal); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--teal) 60%, transparent); outline-offset: 2px; }

.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; color: var(--muted); }
.brand-mark { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; background: linear-gradient(145deg, #1a6f70, #0c2731); color: #e3bf7a; box-shadow: 0 10px 22px rgba(4, 26, 33, .28); }

.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 42%) 1fr; background: #071922; }
.login-panel { padding: clamp(32px, 7vw, 96px); display: flex; flex-direction: column; justify-content: space-between; background: var(--surface); position: relative; z-index: 1; }
.login-brand { display: flex; align-items: center; gap: 13px; font-weight: 700; letter-spacing: -.02em; }
.login-brand .brand-mark { width: 42px; height: 42px; }
.login-copy { max-width: 470px; }
.eyebrow { text-transform: uppercase; letter-spacing: .13em; color: var(--teal); font-size: .72rem; font-weight: 700; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-family: "Newsreader", Georgia, serif; font-size: clamp(2.4rem, 5vw, 4.8rem); line-height: .98; letter-spacing: -.04em; margin-bottom: 22px; }
.login-copy > p { color: var(--muted); font-size: 1.05rem; line-height: 1.65; }
.login-visual { background: linear-gradient(90deg, rgba(7,25,34,.15), rgba(7,25,34,.02)), url('/assets/img/social-preview.jpg') center/cover; position: relative; }
.login-visual::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 40%, rgba(4,15,22,.65)); }
.login-footer { color: var(--muted); font-size: .8rem; }

.app-layout { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-width); background: var(--nav); color: var(--nav-ink); border-right: 1px solid var(--nav-line); padding: 22px 14px 16px; display: flex; flex-direction: column; z-index: 20; box-shadow: 8px 0 30px rgba(24, 45, 50, .035); transition: width .22s, transform .22s, background-color .18s, color .18s, border-color .18s; }
.sidebar-head { display: flex; align-items: center; gap: 12px; padding: 3px 8px 24px; }
.sidebar-title { line-height: 1.05; font-weight: 700; white-space: nowrap; }
.sidebar-title small { display: block; color: var(--nav-muted); font-size: .65rem; letter-spacing: .11em; margin-top: 5px; }
.nav-label { padding: 12px 12px 7px; color: var(--nav-muted); font-size: .66rem; text-transform: uppercase; letter-spacing: .12em; }
.nav { display: grid; gap: 3px; overflow-y: auto; scrollbar-width: thin; }
.nav a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 9px 12px; color: var(--nav-ink); border-radius: 11px; text-decoration: none; font-size: .88rem; white-space: nowrap; transition: background-color .14s, color .14s; }
.nav a i { width: 20px; text-align: center; }
.nav a:hover { background: var(--nav-hover); color: var(--nav-active-ink); }
.nav a.active { background: var(--nav-active); color: var(--nav-active-ink); box-shadow: inset 3px 0 var(--teal); }
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--nav-line); }
.system-meta { display: flex; justify-content: space-between; gap: 8px; padding: 6px 9px 0; color: var(--nav-muted); font-size: .64rem; letter-spacing: .02em; white-space: nowrap; }
.system-version { font-variant-numeric: tabular-nums; }
.user-chip { display: grid; grid-template-columns: 38px minmax(0,1fr) 30px; align-items: center; gap: 9px; padding: 8px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; background: var(--nav-avatar); display: grid; place-items: center; color: var(--gold); font-weight: 700; }
.user-chip strong, .user-chip small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip strong { font-size: .8rem; color: var(--nav-ink); }
.user-chip small { font-size: .68rem; color: var(--nav-muted); margin-top: 2px; }
.sidebar .icon-button { color: var(--nav-muted); }
.sidebar .icon-button:hover { background: var(--nav-soft); color: var(--nav-active-ink); }
.sidebar.collapsed { width: 78px; }
.sidebar.collapsed .sidebar-title, .sidebar.collapsed .nav span, .sidebar.collapsed .nav-label, .sidebar.collapsed .user-meta, .sidebar.collapsed .system-meta { display: none; }
.sidebar.collapsed .sidebar-head { justify-content: center; padding-inline: 0; }
.sidebar.collapsed .nav a { justify-content: center; padding-inline: 0; }
.sidebar.collapsed .user-chip { grid-template-columns: 38px; justify-content: center; }
.app-layout.collapsed { grid-template-columns: 78px minmax(0,1fr); }

.workspace { grid-column: 2; min-width: 0; }
.topbar { min-height: 74px; padding: 12px clamp(18px, 3vw, 42px); display: flex; align-items: center; gap: 14px; position: sticky; top: 0; z-index: 15; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(16px); border-bottom: 1px solid color-mix(in srgb, var(--line) 75%, transparent); }
.icon-button { border: 0; background: transparent; min-width: 38px; height: 38px; border-radius: 10px; cursor: pointer; }
.icon-button:hover { background: var(--surface-soft); }
.search-wrap { flex: 1; max-width: 650px; position: relative; }
.search-wrap > i { position: absolute; left: 15px; top: 12px; color: var(--muted); }
.search { width: 100%; height: 42px; padding: 0 15px 0 42px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 5px; }
.menu-button { display: none; }

.content { padding: 30px clamp(18px, 3vw, 42px) 60px; max-width: 1620px; margin: auto; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 22px; margin-bottom: 26px; }
.page-head h1 { font-family: "DM Sans", sans-serif; font-size: clamp(1.75rem, 3vw, 2.45rem); line-height: 1.1; margin: 0 0 7px; letter-spacing: -.045em; }
.page-head p { color: var(--muted); margin: 0; }
.page-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }
.breadcrumbs { display: flex; gap: 6px; color: var(--muted); font-size: .77rem; margin-bottom: 10px; }

.button { min-height: 42px; display: inline-flex; justify-content: center; align-items: center; gap: 8px; padding: 9px 15px; border: 1px solid transparent; border-radius: 11px; font-weight: 650; font-size: .82rem; cursor: pointer; text-decoration: none; transition: transform .12s, box-shadow .12s, background .12s; }
.button:hover { transform: translateY(-1px); }
.button.primary { background: var(--teal); color: #fff; box-shadow: 0 7px 18px color-mix(in srgb, var(--teal) 26%, transparent); }
[data-theme="dark"] .button.primary { color: #08201f; }
.button.secondary { background: var(--surface); border-color: var(--line); color: var(--ink); }
.button.danger { background: var(--danger-soft); color: var(--danger); }
.button.ghost { background: transparent; color: var(--teal); }
.button.small { min-height: 34px; padding: 6px 10px; font-size: .74rem; }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-bottom: 22px; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.metric::after { content: ""; position: absolute; width: 100px; height: 100px; border: 22px solid var(--teal-soft); border-radius: 50%; right: -48px; top: -46px; }
.metric-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; color: var(--teal); background: var(--teal-soft); margin-bottom: 18px; }
.metric strong { display: block; font-size: 1.8rem; letter-spacing: -.05em; }
.metric span { color: var(--muted); font-size: .78rem; }
.dashboard-grid { display: grid; grid-template-columns: 1.35fr .9fr; gap: 18px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-head { min-height: 65px; padding: 17px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-head h2 { font-size: 1rem; margin: 0; letter-spacing: -.02em; }
.card-body { padding: 20px; }
.stack { display: grid; gap: 12px; }
.empty { min-height: 240px; display: grid; place-content: center; justify-items: center; text-align: center; padding: 28px; color: var(--muted); }
.empty i { font-size: 2rem; color: var(--teal); margin-bottom: 13px; }
.empty strong { color: var(--ink); }
.empty p { margin: 7px 0 0; font-size: .85rem; }

.table-shell { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .82rem; }
th { text-align: left; color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; background: var(--surface-soft); white-space: nowrap; }
th, td { padding: 13px 15px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--teal-soft) 38%, var(--surface)); }
td.actions, th.actions { position: sticky; right: 0; z-index: 2; background: var(--surface); box-shadow: -10px 0 18px -18px var(--ink); text-align: right; white-space: nowrap; }
th.actions { background: var(--surface-soft); }
.truncate { display: inline-block; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 5px 9px; font-size: .7rem; font-weight: 650; white-space: nowrap; }
.badge.success { background: var(--teal-soft); color: var(--success); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.neutral { background: var(--surface-strong); color: var(--muted); }
.amount { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 650; }
.subtle { color: var(--muted); font-size: .75rem; }
.mobile-cards { display: none; }

.filters { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 16px; display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field.grow { flex: 1 1 230px; }
.field label, .field > span { font-size: .74rem; font-weight: 650; }
.field-hint { color: var(--muted); font-size: .69rem; line-height: 1.35; }
.control { width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; background: var(--surface); color: var(--ink); }
textarea.control { min-height: 85px; resize: vertical; }
.control:focus { border-color: var(--teal); outline: 3px solid color-mix(in srgb, var(--teal) 14%, transparent); }
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 15px; }
.span-12 { grid-column: span 12; }.span-8 { grid-column: span 8; }.span-6 { grid-column: span 6; }.span-4 { grid-column: span 4; }.span-3 { grid-column: span 3; }
.checkbox { display: flex; align-items: center; gap: 9px; min-height: 42px; }
.checkbox input { width: 18px; height: 18px; accent-color: var(--teal); }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; padding-top: 8px; }
.dynamic-row { display: grid; grid-template-columns: minmax(220px, 1.4fr) minmax(150px, .8fr) auto auto; gap: 9px; align-items: end; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.check-list { display: grid; gap: 7px; max-height: 240px; overflow: auto; border: 1px solid var(--line); border-radius: 11px; padding: 9px; }
.check-option { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; }
.check-option:hover { background: var(--surface-soft); }
.check-option.assigned { opacity: .5; }
.check-option small { margin-left: auto; color: var(--muted); }

.modal { width: min(780px, calc(100vw - 24px)); max-height: calc(100vh - 30px); border: 1px solid var(--line); border-radius: 20px; padding: 0; color: var(--ink); background: var(--surface); box-shadow: 0 30px 90px rgba(0,0,0,.3); }
.modal::backdrop { background: rgba(3,14,19,.7); backdrop-filter: blur(3px); }
.modal-head { padding: 19px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { margin: 0; font-size: 1.1rem; }
.modal-body { padding: 22px; max-height: calc(100vh - 170px); overflow-y: auto; }

.upload-box { border: 1px dashed color-mix(in srgb, var(--teal) 60%, var(--line)); background: color-mix(in srgb, var(--teal-soft) 40%, var(--surface)); border-radius: 14px; padding: 15px; }
.upload-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.preview-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(120px,1fr)); gap: 10px; margin-top: 12px; }
.preview { position: relative; min-height: 110px; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; overflow: hidden; display: grid; place-items: center; }
.preview img { width: 100%; height: 110px; object-fit: cover; }
.preview .file-icon { font-size: 1.7rem; color: var(--teal); }
.preview small { padding: 5px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview button { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(8,23,29,.82); color: white; cursor: pointer; }
.camera-view { width: 100%; max-height: 360px; background: #000; border-radius: 12px; margin: 12px 0; }
.timeline { display: grid; gap: 0; }
.timeline-item { display: grid; grid-template-columns: 24px 1fr; gap: 12px; position: relative; padding-bottom: 18px; }
.timeline-item::before { content:""; position:absolute; left:11px; top:23px; bottom:0; border-left:1px solid var(--line); }
.timeline-item:last-child::before { display:none; }
.timeline-dot { width:24px;height:24px;border-radius:50%;display:grid;place-items:center;background:var(--teal-soft);color:var(--teal);font-size:.65rem; }
.detail-grid { display:grid;grid-template-columns:repeat(3,1fr);gap:12px;margin-bottom:20px; }
.detail { background:var(--surface-soft);border-radius:11px;padding:12px; }
.detail small { display:block;color:var(--muted);margin-bottom:4px; }

.toast-region { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: grid; gap: 9px; width: min(380px, calc(100vw - 36px)); }
.modal-toast-region { z-index: 110; margin: 0; padding: 0; border: 0; background: transparent; overflow: visible; }
.toast { background: var(--toast-bg); color: var(--toast-ink); padding: 13px 15px; border-radius: 12px; box-shadow: 0 14px 36px rgba(0,0,0,.28); display: flex; gap: 10px; align-items: start; animation: toast-in .22s ease-out; }
.audit-json { max-height: 52vh; overflow: auto; margin: 0; padding: 14px; color: var(--ink); background: var(--surface-soft); border: 1px solid var(--line); border-radius: 12px; font: .74rem/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.toast.error i { color: #ff958f; }.toast.success i { color: #70cec0; }
.version-notice[hidden] { display: none; }
.version-notice { position: fixed; left: 50%; bottom: 18px; z-index: 105; width: min(680px, calc(100vw - 36px)); transform: translateX(-50%); display: grid; grid-template-columns: 42px minmax(0,1fr) auto; align-items: center; gap: 13px; padding: 14px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 18px 48px rgba(4,15,22,.28); animation: toast-in .22s ease-out; }
.version-notice-icon { width: 42px; height: 42px; display: grid; place-items: center; color: var(--teal); background: var(--teal-soft); border-radius: 12px; }
.version-notice-copy strong { display: block; font-size: .9rem; }
.version-notice-copy p { margin: 3px 0 0; color: var(--muted); font-size: .78rem; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
.skeleton { height: 13px; border-radius: 6px; background: linear-gradient(90deg,var(--surface-soft),var(--surface-strong),var(--surface-soft)); background-size: 200%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position-x: -200%; } }

@media (max-width: 1050px) {
  .metrics { grid-template-columns: repeat(2,1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .span-3 { grid-column: span 6; }
}
@media (max-width: 780px) {
  .login-page { grid-template-columns: 1fr; }
  .login-panel { min-height: 100vh; padding: 28px; }
  .login-visual { display: none; }
  .app-layout, .app-layout.collapsed { grid-template-columns: 1fr; }
  .sidebar, .sidebar.collapsed { width: min(290px,86vw); transform: translateX(-105%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar .sidebar-title, .sidebar .nav span, .sidebar .nav-label, .sidebar .user-meta { display: block; }
  .sidebar .system-meta, .sidebar.collapsed .system-meta { display: flex; }
  .sidebar .nav a { justify-content: flex-start; padding-inline: 12px; }
  .workspace { grid-column: 1; }
  .menu-button { display: inline-grid; place-items: center; }
  .collapse-button { display: none; }
  .search-wrap { display: none; }
  .topbar { min-height: 62px; }
  .content { padding-top: 22px; }
  .page-head { align-items: start; flex-direction: column; }
  .page-actions { justify-content: flex-start; width: 100%; }
  .page-actions .button { flex: 1; }
  .desktop-table { display: none; }
  .mobile-cards { display: grid; gap: 11px; }
  .mobile-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 15px; box-shadow: var(--shadow); }
  .mobile-card-head { display:flex;justify-content:space-between;gap:10px;margin-bottom:12px; }
  .mobile-card dl { display:grid;grid-template-columns:1fr 1fr;gap:10px;margin:0 0 14px; }
  .mobile-card dt { font-size:.65rem;color:var(--muted);text-transform:uppercase;letter-spacing:.05em; }
  .mobile-card dd { margin:3px 0 0;font-size:.8rem; }
  .mobile-actions { display:flex;gap:8px; }
  .mobile-actions .button { flex:1; }
  .span-8,.span-6,.span-4,.span-3 { grid-column: span 12; }
  .dynamic-row { grid-template-columns:1fr; }
  .detail-grid { grid-template-columns:1fr 1fr; }
}
@media (max-width: 500px) {
  .metrics { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric { padding: 14px; }
  .metric-icon { margin-bottom: 10px; }
  .metric strong { font-size: 1.4rem; }
  .modal-body { padding: 16px; }
  .detail-grid { grid-template-columns:1fr; }
  .version-notice { grid-template-columns: 38px minmax(0,1fr); }
  .version-notice-icon { width: 38px; height: 38px; }
  .version-notice .button { grid-column: 1 / -1; width: 100%; }
}

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