:root {
  color-scheme: light;
  --navy-950: #0a0a0a;
  --navy-900: #171717;
  --navy-800: #262626;
  --ink: #171717;
  --muted: #737373;
  --line: #e5e5e5;
  --line-strong: #d4d4d4;
  --surface: #fff;
  --surface-muted: #fafafa;
  --teal: #059669;
  --teal-dark: #047857;
  --teal-soft: #ecfdf5;
  --danger: #b4232d;
  --danger-soft: #fff0f1;
  --warning: #a45d09;
  --shadow: 0 18px 48px rgb(13 27 51 / 14%);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; color: var(--ink); background: var(--surface-muted); font-size: 14px; line-height: 1.45; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .55; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background: linear-gradient(135deg, var(--teal-soft) 0%, white 52%, var(--surface-muted) 100%);
}
.login-panel { width: min(100%, 430px); background: white; padding: 44px; border: 1px solid var(--line); box-shadow: var(--shadow); }
.brand-mark { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; color: white; background: var(--navy-950); font-weight: 760; letter-spacing: .02em; }
.brand-mark.small { width: 34px; height: 34px; font-size: 12px; flex: 0 0 auto; }
.brand-name { margin: 16px 0 32px; font-family: "Libre Baskerville", Georgia, serif; font-weight: 700; font-size: 16px; }
.login-panel h1 { margin: 0 0 10px; font-family: "Libre Baskerville", Georgia, serif; font-size: 27px; line-height: 1.25; letter-spacing: -.025em; }
.login-copy { color: var(--muted); margin: 0 0 28px; }
form label { display: grid; gap: 7px; margin-bottom: 18px; font-weight: 650; }
input, select, textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 5px; background: white; color: var(--ink); padding: 11px 12px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgb(8 126 123 / 12%); }
textarea { min-height: 100px; resize: vertical; }
.form-error { color: var(--danger); min-height: 20px; margin: 8px 0 0; font-size: 13px; }
.form-status { color: var(--teal-dark); min-height: 20px; margin: 12px 0 0; font-size: 13px; }

.button { min-height: 40px; border: 1px solid transparent; border-radius: 4px; padding: 9px 15px; font-weight: 700; }
.button.primary { color: white; background: var(--teal); }
.button.primary:hover { background: var(--teal-dark); }
.button.secondary { color: var(--ink); background: white; border-color: var(--line-strong); }
.button.danger { color: var(--danger); background: white; border-color: #e7a9ae; }
.button.wide { width: 100%; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 224px minmax(0, 1fr); }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 224px; z-index: 20; display: flex; flex-direction: column; color: #f5f5f5; background: var(--navy-900); }
.sidebar-brand { height: 72px; display: flex; align-items: center; gap: 12px; padding: 0 22px; border-bottom: 1px solid rgb(255 255 255 / 13%); }
.sidebar-brand .brand-mark { display: none; }
.sidebar-brand strong { font-family: "Libre Baskerville", Georgia, serif; font-size: 15px; }
.sidebar nav { padding: 18px 0; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 13px; padding: 13px 22px; color: #d7e2f1; background: none; border: 0; border-left: 3px solid transparent; text-align: left; font-weight: 620; }
.nav-item span { width: 20px; font-size: 18px; text-align: center; }
.nav-item:hover { background: rgb(255 255 255 / 6%); }
.nav-item.active { color: white; background: #065f46; border-left-color: #6ee7b7; }
.sidebar-footer { margin-top: auto; padding: 18px; border-top: 1px solid rgb(255 255 255 / 13%); display: grid; gap: 4px; }
.sidebar-action { border: 0; background: none; color: #c7d3e5; text-align: left; padding: 8px 4px; }
.sidebar-action:hover { color: white; }

.workspace { grid-column: 2; min-width: 0; }
.topbar { height: 72px; position: sticky; top: 0; z-index: 10; display: grid; grid-template-columns: minmax(160px, 1fr) minmax(280px, 590px) 42px; align-items: center; gap: 26px; padding: 0 30px; border-bottom: 1px solid var(--line); background: rgb(255 255 255 / 96%); }
.topbar h1 { margin: 0; font-family: "Libre Baskerville", Georgia, serif; font-size: 19px; letter-spacing: -.02em; }
.topbar p { margin: 1px 0 0; font-size: 12px; }
.global-search { height: 40px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line-strong); padding: 0 12px; background: white; }
.global-search span { color: var(--muted); font-size: 19px; }
.global-search input { border: 0; box-shadow: none; padding: 0; }
.account-button { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--navy-950); color: white; font-weight: 720; }
.mobile-nav { display: none; }
.content { padding: 30px; max-width: 1480px; margin: 0 auto; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-bottom: 24px; }
.metric { min-height: 104px; display: flex; align-items: center; gap: 16px; padding: 20px; background: white; border: 1px solid var(--line); }
.metric-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: var(--teal-soft); color: var(--teal); font-size: 22px; }
.metric strong { display: block; font-size: 27px; line-height: 1; letter-spacing: -.025em; }
.metric span { color: var(--muted); }

.list-panel { background: white; border: 1px solid var(--line); }
.list-toolbar { min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.list-toolbar h2 { margin: 0; font-family: "Libre Baskerville", Georgia, serif; font-size: 17px; }
.list-toolbar p { margin: 2px 0 0; font-size: 12px; }
.toolbar-actions { display: flex; gap: 10px; }
.compact-search input { min-width: 260px; }
.toolbar-actions select { min-width: 160px; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 11px 16px; color: #48546a; background: #fafbfc; border-bottom: 1px solid var(--line); font-size: 11px; text-align: left; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
td { height: 55px; padding: 10px 16px; border-bottom: 1px solid #e8ecf0; white-space: nowrap; }
tbody tr { transition: background 140ms ease; }
tbody tr:hover, tbody tr.selected { background: #f0faf8; }
tbody tr { cursor: pointer; }
.name-cell { font-weight: 690; }
.status-text { color: var(--teal-dark); font-weight: 650; }
.row-action { border: 0; background: none; color: var(--muted); font-size: 18px; }
.loading-state, .empty-state { min-height: 330px; display: grid; place-content: center; text-align: center; color: var(--muted); }
.empty-state h3 { color: var(--ink); margin: 0 0 4px; }
.empty-state p { margin: 0; }
.pagination { min-height: 62px; display: flex; justify-content: space-between; align-items: center; padding: 0 16px; }
.pagination > div { display: flex; align-items: center; gap: 12px; }
.icon-button { width: 36px; height: 36px; border: 1px solid var(--line-strong); background: white; color: var(--ink); border-radius: 4px; font-size: 18px; }

.detail-drawer { position: fixed; inset: 0 0 0 auto; z-index: 40; width: min(430px, 100vw); background: white; box-shadow: var(--shadow); overflow-y: auto; }
.drawer-scrim { position: fixed; inset: 0; z-index: 30; background: transparent; }
.drawer-header { min-height: 84px; position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding: 22px 24px 16px; background: white; border-bottom: 1px solid var(--line); }
.drawer-header h2 { margin: 0; font-family: "Libre Baskerville", Georgia, serif; font-size: 20px; line-height: 1.3; letter-spacing: -.02em; }
.drawer-header p { margin: 3px 0 0; font-size: 12px; }
.drawer-content { padding: 22px 24px 32px; }
.detail-section { padding: 0 0 22px; margin: 0 0 22px; border-bottom: 1px solid var(--line); }
.detail-section:last-child { border-bottom: 0; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 13px; }
.section-heading h3 { margin: 0; font-size: 14px; }
.detail-grid { display: grid; grid-template-columns: 118px minmax(0, 1fr); gap: 9px 12px; }
.detail-grid dt { color: var(--muted); }
.detail-grid dd { margin: 0; overflow-wrap: anywhere; }
.sensitive-lock { padding: 24px 18px; border: 1px dashed var(--line-strong); background: #fbfcfd; text-align: center; }
.sensitive-lock strong { display: block; margin: 6px 0; }
.sensitive-lock p { margin: 0 0 14px; color: var(--muted); font-size: 12px; }
.sensitive-data { padding: 14px; background: var(--danger-soft); border: 1px solid #f1c5c8; }
.sensitive-data .detail-grid { grid-template-columns: 140px minmax(0, 1fr); }
.document-list { display: grid; gap: 7px; }
.document-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); }
.document-row strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.document-row span { color: var(--muted); font-size: 11px; }
.document-actions, .drawer-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.upload-input { display: none; }

dialog { width: min(600px, calc(100vw - 32px)); max-height: calc(100vh - 40px); padding: 0; border: 1px solid var(--line); box-shadow: var(--shadow); }
dialog::backdrop { background: rgb(6 25 54 / 34%); }
dialog form { padding: 0; }
.dialog-header { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 0; font-size: 19px; }
.edit-fields { max-height: 60vh; padding: 20px 22px; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.edit-fields label { margin: 0; }
.edit-fields label.full { grid-column: 1 / -1; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; padding: 16px 22px; border-top: 1px solid var(--line); }
dialog .form-error { padding: 0 22px; }
.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 8px; }
.toast { min-width: 270px; max-width: 420px; padding: 13px 15px; color: white; background: var(--navy-950); box-shadow: var(--shadow); }
.toast.error { background: var(--danger); }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { transform: translateX(-100%); transition: transform 180ms ease; }
  .sidebar.open { transform: translateX(0); }
  .workspace { grid-column: 1; }
  .topbar { grid-template-columns: 42px 1fr 42px; padding: 0 16px; gap: 12px; }
  .topbar > div p { display: none; }
  .mobile-nav { display: block; border: 0; background: none; font-size: 20px; }
  .global-search { grid-column: 1 / -1; grid-row: 2; margin: 0 0 10px; }
  .topbar { height: auto; min-height: 70px; padding-top: 12px; }
  .content { padding: 70px 16px 24px; }
  .metrics { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .login-shell { padding: 0; background: white; }
  .login-panel { min-height: 100vh; border: 0; box-shadow: none; padding: 34px 24px; }
  .content { padding-left: 10px; padding-right: 10px; }
  .list-toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-actions { flex-direction: column; }
  .compact-search input, .toolbar-actions select { min-width: 0; }
  .metrics { gap: 10px; }
  .metric { min-height: 84px; }
  .edit-fields { grid-template-columns: 1fr; }
  .edit-fields label.full { grid-column: auto; }
}

@media print {
  .sidebar, .topbar, .metrics, .list-panel, .drawer-header .icon-button, .drawer-actions, .document-actions, .sensitive-data, .sensitive-lock, .drawer-scrim { display: none !important; }
  body { background: white; }
  .detail-drawer { position: static; display: block !important; width: 100%; box-shadow: none; }
  .drawer-header { position: static; padding: 0 0 20px; }
  .drawer-content { padding: 0; }
}
