:root {
  --ink: #111111;
  --coal: #1d1a17;
  --muted: #756d62;
  --line: #ded4c6;
  --paper: #fbf8f2;
  --cream: #f3eadc;
  --gold: #c9a45b;
  --rose: #8c4f4a;
  --green: #2e5f51;
  --blue: #263f67;
  --white: #ffffff;
  --shadow: 0 18px 48px rgba(17, 17, 17, 0.12);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(rgba(17,17,17,.45), rgba(17,17,17,.58)),
    url("/images/fabric-pattern.svg") center/cover;
}
.auth-card {
  width: min(520px, 100%);
  padding: 32px;
  border: 1px solid rgba(244,217,155,.36);
  color: var(--white);
  background: rgba(17, 17, 17, .78);
  box-shadow: var(--shadow);
}
.auth-card h1 { margin: 12px 0; font-size: clamp(32px, 5vw, 54px); line-height: .98; letter-spacing: 0; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border: 1px solid var(--gold);
  background: var(--ink);
  color: var(--gold);
  font-weight: 800;
  letter-spacing: 0;
}
.brand-mark.small { width: 46px; height: 46px; font-size: 14px; }
.eyebrow {
  margin: 0;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.muted { color: var(--muted); }
.auth-card .muted { color: #e7dbca; }
.stack { display: grid; gap: 12px; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink);
  padding: 12px 13px;
  border-radius: 6px;
  outline: none;
}
textarea { min-height: 92px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,164,91,.18); }
.primary, .ghost, .icon {
  border: 0;
  border-radius: 6px;
  min-height: 42px;
  padding: 0 16px;
  font-weight: 800;
}
.primary { background: var(--ink); color: var(--white); }
.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.icon { width: 38px; padding: 0; background: var(--cream); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 280px 1fr; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  color: var(--white);
  background: var(--ink);
}
.side-brand { display: flex; align-items: center; gap: 12px; padding-bottom: 18px; border-bottom: 1px solid rgba(255,255,255,.12); }
.side-brand span { display: block; color: #d8c6a9; font-size: 13px; }
nav { display: grid; gap: 6px; overflow: auto; padding-right: 4px; }
nav button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  border: 0;
  border-radius: 6px;
  padding: 11px 12px;
  color: #e8decc;
  background: transparent;
  text-align: left;
}
nav button.active, nav button:hover { background: #26211c; color: var(--white); }
nav small { color: var(--gold); }
.sidebar .ghost { margin-top: auto; color: var(--white); border-color: rgba(255,255,255,.16); }
.sidebar .ghost + .ghost { margin-top: 0; }

.workspace { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 22px 28px;
  background: rgba(251,248,242,.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.topbar h1 { margin: 4px 0 0; font-size: 30px; letter-spacing: 0; }
.top-actions { display: flex; gap: 10px; align-items: end; }
.search { display: grid; gap: 4px; min-width: 310px; color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.view { padding: 24px 28px 42px; display: grid; gap: 18px; }

.quick-actions {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}
.quick-card {
  min-height: 118px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  display: grid;
  align-content: start;
  gap: 8px;
  text-align: left;
  background: var(--white);
  box-shadow: 0 10px 24px rgba(17,17,17,.05);
}
.quick-card:hover, .quick-card:focus {
  border-color: var(--gold);
  box-shadow: 0 14px 30px rgba(201,164,91,.16);
}
.quick-card span {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  color: var(--ink);
  background: var(--cream);
  font-weight: 900;
}
.quick-card strong { font-size: 16px; }
.quick-card small { color: var(--muted); line-height: 1.35; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metric, .panel, .record-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 10px 24px rgba(17,17,17,.05);
}
.metric { padding: 18px; }
.metric span { color: var(--muted); font-weight: 700; font-size: 13px; }
.metric strong { display: block; margin-top: 8px; font-size: 32px; }
.metric b { color: var(--gold); }
.panel { padding: 18px; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.panel h2 { margin: 0; font-size: 18px; }
.grid-2 { display: grid; grid-template-columns: 1.2fr .8fr; gap: 18px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.record-card { padding: 16px; display: grid; gap: 12px; }
.record-card h3 { margin: 0; font-size: 18px; }
.record-card p { margin: 0; color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 7px; }
.tag { border-radius: 999px; padding: 5px 9px; background: var(--cream); color: var(--coal); font-size: 12px; font-weight: 800; }
.tag.green { background: #dbeee5; color: var(--green); }
.tag.rose { background: #f2deda; color: var(--rose); }
.tag.blue { background: #dbe6f5; color: var(--blue); }
.actions { display: flex; gap: 8px; }
.actions button { min-height: 34px; padding: 0 10px; }

.timeline { display: grid; gap: 10px; }
.step { display: grid; grid-template-columns: 24px 1fr auto; gap: 10px; align-items: start; }
.dot { width: 13px; height: 13px; border-radius: 50%; margin-top: 4px; background: var(--gold); box-shadow: 0 0 0 5px rgba(201,164,91,.18); }
.step strong { display: block; }
.step span { color: var(--muted); font-size: 13px; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }

dialog { width: min(760px, calc(100vw - 28px)); border: 1px solid var(--line); border-radius: 8px; padding: 0; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(17,17,17,.42); backdrop-filter: blur(4px); }
dialog header, dialog footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px; border-bottom: 1px solid var(--line); }
dialog footer { border-top: 1px solid var(--line); border-bottom: 0; justify-content: flex-end; }
dialog h2 { margin: 4px 0 0; }
.field-grid { padding: 18px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.field-grid label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.field-grid label.full { grid-column: 1 / -1; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 10;
  max-width: 360px;
  border-radius: 8px;
  padding: 14px 16px;
  color: var(--white);
  background: var(--ink);
  box-shadow: var(--shadow);
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 8;
  display: none;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 8px 10px 10px;
  background: rgba(251,248,242,.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.bottom-nav button {
  min-height: 54px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
  font-weight: 800;
}
.bottom-nav span {
  display: block;
  margin-bottom: 2px;
  font-size: 18px;
  color: var(--gold);
}
.bottom-nav button.active {
  color: var(--ink);
  background: var(--cream);
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar, .top-actions { align-items: stretch; flex-direction: column; }
  .search { min-width: 0; }
  .metric-grid, .grid-2 { grid-template-columns: 1fr; }
  .quick-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bottom-nav { display: grid; }
  .view { padding-bottom: 94px; }
  .sidebar .ghost { margin-top: 0; }
}

@media (max-width: 620px) {
  .view, .topbar, .sidebar { padding-left: 16px; padding-right: 16px; }
  nav { grid-template-columns: 1fr; }
  .field-grid { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr; }
  .quick-actions { grid-template-columns: 1fr; }
  .quick-card { min-height: 88px; grid-template-columns: 44px 1fr; align-items: center; }
  .quick-card small { grid-column: 2; }
}
