:root {
  color-scheme: dark;
  --bg: #0f1923;
  --bg-deep: #091018;
  --panel: #162332;
  --panel-2: #1e2f40;
  --panel-3: #24384b;
  --gold: #c9a84c;
  --gold-2: #e3c66e;
  --text: #f3ead4;
  --body: #d9e1e7;
  --muted: #8fa3b8;
  --line: rgba(201, 168, 76, 0.22);
  --line-soft: rgba(255, 255, 255, 0.08);
  --green: #70d18a;
  --red: #ff897d;
  --amber: #f4c96b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  background: linear-gradient(180deg, #0f1923 0%, #101b27 48%, #0b1119 100%);
  color: var(--body);
  font: 13px/1.42 "Segoe UI", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

body.auth-body {
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    radial-gradient(circle at 50% 16%, rgba(201, 168, 76, 0.11), transparent 30%),
    linear-gradient(180deg, #101b27 0%, #0b1119 100%);
  background-size: 42px 42px, 42px 42px, auto, auto;
}

.auth-shell {
  width: min(410px, 100%);
  display: block;
}

.auth-panel {
  border: 1px solid rgba(201, 168, 76, 0.24);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(30, 47, 64, 0.98), rgba(18, 30, 43, 0.98));
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.32);
  padding: 28px;
  display: grid;
  gap: 16px;
}

.auth-logo {
  width: 142px;
  height: auto;
  display: block;
  margin: 0 auto 4px;
}

.auth-copy {
  text-align: center;
}

.auth-copy h1 {
  margin-bottom: 5px;
  font-size: 22px;
  line-height: 1.2;
}

.auth-copy p:not(.eyebrow) {
  margin-bottom: 0;
  font-size: 13px;
}

.auth-form {
  display: grid;
  gap: 10px;
}

.auth-form label {
  display: grid;
  gap: 6px;
}

.auth-form input {
  width: 100%;
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 7px;
  background: rgba(6, 10, 15, 0.68);
  color: var(--text);
  padding: 0 10px;
}

.auth-form button {
  width: 100%;
  min-height: 40px;
}

.auth-warning,
.auth-error {
  border: 1px solid rgba(244, 201, 107, 0.32);
  border-radius: 7px;
  background: rgba(244, 201, 107, 0.08);
  padding: 9px 10px;
}

.auth-error {
  border-color: rgba(255, 137, 125, 0.32);
  background: rgba(255, 137, 125, 0.08);
}

.auth-meta {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 11px;
}

.auth-meta span {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: rgba(6, 10, 15, 0.3);
  padding: 4px 8px;
}

button,
input,
select {
  font: inherit;
}

button,
.button-link {
  min-height: 32px;
  border: 1px solid rgba(201, 168, 76, 0.46);
  border-radius: 7px;
  background: var(--gold);
  color: #080b0d;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 10px;
  cursor: pointer;
  text-decoration: none;
}

button:hover,
.button-link:hover {
  background: var(--gold-2);
}

button svg,
a svg {
  width: 15px;
  height: 15px;
}

.secondary {
  background: rgba(255, 255, 255, 0.045);
  border-color: rgba(201, 168, 76, 0.22);
  color: var(--text);
}

.secondary:hover {
  background: rgba(255, 255, 255, 0.08);
}

.danger {
  border-color: rgba(255, 137, 125, 0.35);
  color: #ffd2cc;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 12px;
  border-right: 1px solid var(--line);
  background: rgba(7, 11, 16, 0.86);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.brand {
  display: block;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(201, 168, 76, 0.3);
}

.brand img {
  width: 158px;
  height: auto;
  display: block;
}

nav {
  display: grid;
  gap: 4px;
}

nav a {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  text-decoration: none;
  border-radius: 7px;
  padding: 7px 9px;
  font-weight: 720;
}

nav a:hover,
nav a.active {
  background: rgba(201, 168, 76, 0.12);
  color: var(--text);
}

nav svg {
  width: 16px;
  height: 16px;
}

.connection-card {
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(201, 168, 76, 0.08), rgba(255, 255, 255, 0.035));
  padding: 10px;
  display: grid;
  gap: 9px;
}

.connection-card p,
.eyebrow,
.stat-strip span,
.panel-kicker,
.table-head,
.field-label {
  margin: 0;
  color: var(--gold);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.connection-card strong {
  color: var(--text);
  display: block;
  margin-top: 2px;
}

.connection-card span {
  color: var(--muted);
}

main {
  min-width: 0;
  padding: 18px;
}

.app-header {
  min-height: 48px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

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

h1 {
  margin-bottom: 0;
  color: var(--text);
  font-size: 24px;
  line-height: 1.18;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 3px;
  color: var(--text);
  font-size: 16px;
}

h3 {
  margin-bottom: 6px;
  color: var(--text);
  font-size: 14px;
}

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

.header-actions,
.toolbar,
.table-actions,
.button-row,
.tabs,
.doc-grid {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.stat-strip article,
.panel,
.drawer-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(34, 56, 76, 0.94), rgba(22, 35, 50, 0.94));
}

.stat-strip article {
  min-height: 58px;
  padding: 10px 12px;
}

.stat-strip strong {
  display: block;
  margin-top: 2px;
  color: var(--text);
  font-size: 21px;
}

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

.panel + .panel,
.page-grid + .panel,
.panel + .page-grid {
  margin-top: 10px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.panel-head p {
  margin-bottom: 0;
}

.toolbar {
  justify-content: space-between;
  margin-bottom: 10px;
}

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.search,
select {
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 7px;
  background: rgba(6, 10, 15, 0.68);
  color: var(--text);
}

.search {
  min-width: 280px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 9px;
}

.search input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

select {
  padding: 0 9px;
}

.data-table {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}

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

th,
td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  padding: 8px 9px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  background: rgba(6, 10, 15, 0.42);
}

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

td strong {
  color: var(--text);
}

td small,
.muted,
.activity span,
.job-status,
.doc-card span {
  color: var(--muted);
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  padding: 3px 7px;
}

.pill.good {
  color: var(--green);
  background: rgba(112, 209, 138, 0.12);
}

.pill.warn {
  color: var(--amber);
  background: rgba(244, 201, 107, 0.12);
}

.pill.bad {
  color: var(--red);
  background: rgba(255, 137, 125, 0.12);
}

.client-link {
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
}

.client-link:hover {
  color: var(--gold-2);
}

.table-actions {
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.icon-button {
  width: 32px;
  padding: 0;
}

.page-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 10px;
  align-items: start;
}

.connect-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 18px;
  align-items: center;
  margin-bottom: 10px;
  background:
    linear-gradient(135deg, rgba(201, 168, 76, 0.12), rgba(34, 56, 76, 0.92) 42%, rgba(22, 35, 50, 0.94));
}

.connect-hero h2 {
  font-size: 22px;
}

.connect-hero p {
  max-width: 680px;
  margin-bottom: 0;
}

.connect-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.connect-checks span {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(112, 209, 138, 0.18);
  border-radius: 999px;
  background: rgba(112, 209, 138, 0.08);
  color: #b5edc4;
  padding: 5px 9px;
  font-weight: 760;
}

.connect-checks svg {
  width: 14px;
  height: 14px;
}

.connect-action-card {
  border: 1px solid rgba(201, 168, 76, 0.24);
  border-radius: 8px;
  background: rgba(6, 10, 15, 0.36);
  padding: 14px;
  display: grid;
  gap: 8px;
}

.connect-action-card strong {
  color: var(--text);
}

.connect-action-card span,
.connect-action-card small {
  color: var(--muted);
}

.detail-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.record-title {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.record-title h2 {
  margin: 0;
}

.tabs {
  margin: 10px 0;
}

.tab {
  min-height: 30px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
  border-color: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.tab.active {
  background: rgba(201, 168, 76, 0.14);
  border-color: rgba(201, 168, 76, 0.34);
  color: var(--text);
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.mini-card {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(6, 10, 15, 0.32);
  padding: 10px;
}

.mini-card span {
  color: var(--muted);
  font-size: 11px;
}

.mini-card strong {
  display: block;
  color: var(--text);
  font-size: 18px;
  margin-top: 2px;
}

.side-list,
.activity,
.approval-list {
  display: grid;
  gap: 8px;
}

.side-item,
.activity-item,
.approval-item,
.doc-card {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(6, 10, 15, 0.32);
  padding: 10px;
}

.side-item strong,
.activity-item strong,
.approval-item strong,
.doc-card strong {
  color: var(--text);
}

.activity-item {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 130px;
  gap: 10px;
  align-items: center;
}

.doc-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.doc-card {
  min-height: 92px;
  color: inherit;
  text-decoration: none;
  display: grid;
  align-content: start;
  gap: 4px;
}

.code-box {
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #070b10;
  color: #f2d987;
  padding: 12px;
}

.scope-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.empty-state {
  min-height: 220px;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(201, 168, 76, 0.32);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  padding: 18px;
}

@media (max-width: 1180px) {
  body {
    grid-template-columns: 1fr;
  }

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

  .page-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  main {
    padding: 12px;
  }

  .auth-panel {
    padding: 22px;
  }

  .app-header,
  .detail-header,
  .panel-head,
  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .stat-strip,
  .mini-grid,
  .doc-grid,
  .scope-grid {
    grid-template-columns: 1fr 1fr;
  }

  .connect-hero {
    grid-template-columns: 1fr;
  }

  .search {
    min-width: 0;
    width: 100%;
  }

  .activity-item {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}

@media (max-width: 540px) {
  .stat-strip,
  .mini-grid,
  .doc-grid,
  .scope-grid {
    grid-template-columns: 1fr;
  }
}
