:root {
  --brown: #3f2315;
  --gold: #c3a117;
  --ink: #171312;
  --ink-2: #211b19;
  --panel: #f7f3ed;
  --panel-dark: #241d1a;
  --line: rgba(255, 255, 255, 0.12);
  --line-dark: rgba(63, 35, 21, 0.16);
  --text: #f8f4ed;
  --muted: #b9aaa1;
  --muted-dark: #6f625b;
  --blue: #5b8def;
  --green: #43a36d;
  --red: #d75f57;
  --amber: #d59b35;
  --radius: 8px;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #120f0e;
  color: var(--text);
}

.hidden {
  display: none !important;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(63, 35, 21, 0.22), transparent 300px),
    #120f0e;
}

.login-panel {
  width: min(100%, 420px);
  display: grid;
  gap: 18px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.045);
  box-shadow: var(--shadow);
}

.login-logo {
  display: block;
  width: min(100%, 260px);
  height: auto;
  margin-bottom: 4px;
}

.login-panel h1 {
  font-size: 34px;
}

.shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px;
  background: #171211;
  border-right: 1px solid var(--line);
}

.brand {
  display: grid;
  gap: 12px;
}

.brand-logo {
  display: block;
  width: min(100%, 220px);
  height: auto;
  object-fit: contain;
}

.brand-system {
  display: grid;
  gap: 2px;
  padding-left: 10px;
  border-left: 2px solid rgba(195, 161, 23, 0.58);
}

.brand-system strong,
.brand-system small {
  display: block;
}

.brand-system strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
}

.brand-system small,
.eyebrow,
.sidebar-footer label,
.sync-state {
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  min-height: 40px;
  padding: 10px 12px;
  color: #ddcfbf;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
}

.nav-item:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.nav-item.active {
  color: #fff;
  background: rgba(195, 161, 23, 0.14);
  border-color: rgba(195, 161, 23, 0.28);
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.profile-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.profile-name {
  color: #fff;
  font-size: 14px;
}

.security-pill,
.badge,
.mini-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.security-pill {
  color: #f4e5b3;
  background: rgba(195, 161, 23, 0.14);
  border: 1px solid rgba(195, 161, 23, 0.22);
}

.main {
  min-width: 0;
  padding: 28px;
  background:
    linear-gradient(180deg, rgba(63, 35, 21, 0.18), transparent 260px),
    #120f0e;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
}

h1 {
  margin-bottom: 0;
  font-size: 34px;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
}

.topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.button,
.icon-button {
  border: 0;
  border-radius: var(--radius);
  font-weight: 700;
}

.button {
  min-height: 40px;
  padding: 10px 14px;
  color: var(--brown);
  background: var(--gold);
}

.button:hover {
  filter: brightness(1.04);
}

.button-secondary {
  color: #eadfcd;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
}

.button-small {
  min-height: 30px;
  padding: 6px 9px;
  font-size: 12px;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 18px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(120px, 1fr));
  gap: 12px;
}

.metric-card,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.045);
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 116px;
  display: grid;
  align-content: space-between;
  padding: 16px;
}

.metric-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.metric-card strong {
  font-size: 30px;
}

.metric-card[data-tone="red"] strong {
  color: #ffaaa4;
}

.metric-card[data-tone="green"] strong {
  color: #8ed9ad;
}

.metric-card[data-tone="blue"] strong {
  color: #a6c0ff;
}

.split-grid,
.work-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.35fr);
  gap: 18px;
}

.panel {
  min-width: 0;
  padding: 18px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.form-panel {
  align-self: start;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.span-2 {
  grid-column: span 2;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: 0;
  padding: 9px 10px;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(195, 161, 23, 0.72);
  box-shadow: 0 0 0 3px rgba(195, 161, 23, 0.14);
}

select option {
  color: #171312;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

td strong {
  display: block;
  margin-bottom: 4px;
}

.muted {
  color: var(--muted);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  color: #fff;
  background: rgba(255, 255, 255, 0.11);
}

.badge.green {
  color: #b7edcb;
  background: rgba(67, 163, 109, 0.18);
}

.badge.blue {
  color: #c0d2ff;
  background: rgba(91, 141, 239, 0.18);
}

.badge.red {
  color: #ffbfbb;
  background: rgba(215, 95, 87, 0.18);
}

.badge.amber {
  color: #f4d398;
  background: rgba(213, 155, 53, 0.18);
}

.stack-list {
  display: grid;
  gap: 10px;
}

.list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.list-row:last-child {
  border-bottom: 0;
}

.list-row strong {
  display: block;
  margin-bottom: 5px;
}

.export-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.export-item {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.045);
}

.export-actions {
  display: flex;
  gap: 8px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--brown);
  box-shadow: var(--shadow);
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.active {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1240px) {
  .metric-grid {
    grid-template-columns: repeat(4, minmax(120px, 1fr));
  }

  .split-grid,
  .work-grid,
  .export-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 840px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .brand-logo {
    width: min(100%, 240px);
  }

  .main {
    padding: 20px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .metric-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }
}

@media (max-width: 640px) {
  .table-wrap {
    overflow: visible;
  }

  table,
  thead,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  thead {
    display: none;
  }

  tr {
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
  }

  tr:last-child {
    border-bottom: 0;
  }

  td {
    display: grid;
    grid-template-columns: minmax(96px, 0.4fr) minmax(0, 1fr);
    gap: 10px;
    padding: 7px 0;
    border-bottom: 0;
    overflow-wrap: anywhere;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
  }
}
