:root {
  --bg: #f5f1e8;
  --bg-2: #efe4d2;
  --panel: #fffaf3;
  --panel-2: #ffffff;
  --text: #1f2937;
  --muted: #697386;
  --line: #e4d4bd;
  --brand: #6d3d14;
  --brand-2: #9c6a2e;
  --accent: #1f6f78;
  --success: #146c43;
  --warning: #b7791f;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(46, 32, 16, 0.12);
  --radius: 22px;
}

[data-theme='dark'] {
  --bg: #0d1117;
  --bg-2: #151b23;
  --panel: #151b23;
  --panel-2: #1f2937;
  --text: #f6efe5;
  --muted: #b7c0cc;
  --line: #334155;
  --brand: #d7a85d;
  --brand-2: #f2c47f;
  --accent: #67d2df;
  --success: #7bdcb5;
  --warning: #ffd166;
  --danger: #ff8f8f;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(156, 106, 46, .22), transparent 34rem),
    linear-gradient(135deg, var(--bg), var(--bg-2));
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
svg { width: 1.2rem; height: 1.2rem; fill: currentColor; flex: none; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(1080px, 100%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 32px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.login-hero {
  padding: 42px;
  color: #fff;
  background:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,.18), transparent 14rem),
    linear-gradient(135deg, #351906, #8b5a1e);
}
.login-hero h1 { margin: 14px 0; font-size: clamp(2rem, 5vw, 4rem); line-height: 1; }
.login-hero p { font-size: 1.05rem; line-height: 1.7; opacity: .92; }
.hero-icon {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border-radius: 22px;
  background: rgba(255,255,255,.16);
}
.hero-icon svg { width: 34px; height: 34px; }
.hero-points { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.hero-points span {
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 999px;
  background: rgba(255,255,255,.12);
  font-size: .9rem;
}
.login-panel { padding: 42px; }
.login-panel h2 { margin: 0 0 8px; font-size: 2rem; }
.login-list { display: grid; gap: 12px; margin-top: 22px; }
.login-user {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--text);
  background: var(--panel-2);
  text-align: left;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.login-user:hover { transform: translateY(-2px); border-color: var(--brand); box-shadow: var(--shadow); }
.login-user span { color: var(--brand); font-weight: 700; font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; }
.login-user small { color: var(--muted); }

.app-shell {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: rgba(255,250,243,.74);
  backdrop-filter: blur(18px);
}
[data-theme='dark'] .sidebar { background: rgba(15,23,42,.76); }
.brand-card {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 18px;
  border-radius: var(--radius);
  color: #fff;
  background: linear-gradient(135deg, #3d1f09, #8b5a1e);
  box-shadow: var(--shadow);
}
.brand-card h1 { margin: 0; font-size: 1.55rem; }
.brand-card p { margin: 2px 0 0; opacity: .86; font-size: .92rem; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: rgba(255,255,255,.16);
}
.brand-mark svg { width: 28px; height: 28px; }
.sidebar-nav { display: grid; gap: 8px; margin-top: 22px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 16px;
  color: var(--text);
  background: transparent;
  text-align: left;
  transition: .18s ease;
}
.nav-item:hover, .nav-item.active {
  border-color: var(--line);
  background: var(--panel);
  color: var(--brand);
  box-shadow: 0 10px 28px rgba(31, 41, 55, .08);
}
.sidebar-note {
  display: grid;
  gap: 6px;
  margin-top: 22px;
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  color: var(--muted);
  background: var(--panel);
  font-size: .92rem;
}
.sidebar-note strong { color: var(--text); }

.main { padding: 28px; padding-bottom: 90px; min-width: 0; }
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}
.eyebrow {
  margin: 0 0 6px;
  color: var(--brand);
  font-weight: 800;
  font-size: .78rem;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.topbar h2 { margin: 0 0 6px; font-size: clamp(1.85rem, 4vw, 3rem); line-height: 1.05; }
.subtitle { margin: 0; color: var(--muted); line-height: 1.6; }
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.chip, .badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  font-size: .86rem;
  white-space: nowrap;
}
.badge.success { color: var(--success); }
.badge.warning { color: var(--warning); }
.badge.danger { color: var(--danger); }
.badge.neutral { color: var(--accent); }
.btn, .icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: var(--panel);
  padding: 10px 14px;
  box-shadow: 0 8px 20px rgba(31,41,55,.06);
}
.icon-button { width: 42px; padding: 0; }
.btn.primary { border-color: transparent; color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-2)); }
.btn.ghost { box-shadow: none; }
.btn.danger { color: var(--danger); }

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.metric-card {
  position: relative;
  overflow: hidden;
  min-height: 154px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.metric-card::after {
  content: '';
  position: absolute;
  inset: auto -24px -48px auto;
  width: 120px;
  height: 120px;
  border-radius: 999px;
  background: rgba(156, 106, 46, .13);
}
.metric-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin-bottom: 16px;
  border-radius: 14px;
  color: var(--brand);
  background: color-mix(in srgb, var(--brand) 12%, transparent);
}
.metric-card span { color: var(--muted); }
.metric-card strong { display: block; margin: 4px 0; font-size: 2.1rem; }
.metric-card small { color: var(--muted); }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr); gap: 16px; }
.content-grid.single { grid-template-columns: 1fr; }
.card {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.card.wide { min-width: 0; }
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.section-head h3, .card h3 { margin: 0 0 4px; font-size: 1.25rem; }
.section-head p, .card p { margin: 0; color: var(--muted); line-height: 1.55; }
.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}
.searchbox {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: min(420px, 100%);
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
}
.searchbox input {
  width: 100%;
  min-height: 44px;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

.form-card { background: linear-gradient(180deg, var(--panel), color-mix(in srgb, var(--panel) 85%, var(--brand) 6%)); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid label { display: grid; gap: 7px; color: var(--muted); font-size: .9rem; }
.form-grid .full { grid-column: 1 / -1; }
.field {
  width: 100%;
  min-height: 44px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  background: var(--panel-2);
  outline: none;
}
textarea.field { min-height: 90px; resize: vertical; }
.field:focus { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 14%, transparent); }

.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 760px; border-collapse: collapse; }
th, td { padding: 14px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; }
td strong { font-weight: 800; }
.muted { color: var(--muted); }

.timeline { display: grid; gap: 14px; }
.timeline-item { display: grid; grid-template-columns: 16px minmax(0,1fr); gap: 12px; }
.timeline-item > span {
  width: 10px;
  height: 10px;
  margin-top: 6px;
  border-radius: 999px;
  background: var(--brand);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--brand) 13%, transparent);
}
.timeline-item p { margin: 4px 0 0; color: var(--muted); line-height: 1.5; }
.status-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.status-grid > div { padding: 16px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel-2); }
.status-grid p { margin-top: 6px; }
.status-dot { display: inline-block; width: 10px; height: 10px; margin-right: 8px; border-radius: 999px; }
.status-dot.ok { background: var(--success); }
.status-dot.wait { background: var(--warning); }
.status-dot.no { background: var(--danger); }

.bottom-nav {
  display: none;
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 10;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}
.bottom-nav .nav-item {
  display: grid;
  place-items: center;
  gap: 3px;
  padding: 8px 4px;
  font-size: .74rem;
  border-radius: 16px;
}
.bottom-nav svg { width: 1.05rem; height: 1.05rem; }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 36px));
  padding: 14px 16px;
  border-radius: 16px;
  color: #fff;
  background: #111827;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(110px);
  transition: .24s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1120px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-nav { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .sidebar-note { display: none; }
  .content-grid { grid-template-columns: 1fr; }
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .login-page { padding: 14px; }
  .login-card { grid-template-columns: 1fr; border-radius: 24px; }
  .login-hero, .login-panel { padding: 26px; }
  .hero-points { display: grid; }
  .sidebar { display: none; }
  .bottom-nav { display: grid; }
  .main { padding: 20px 14px 96px; }
  .topbar { flex-direction: column; }
  .top-actions { width: 100%; justify-content: flex-start; }
  .metrics-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .searchbox { min-width: 100%; }
  .toolbar .btn { width: 100%; }
  .status-grid { grid-template-columns: 1fr; }
  table, thead, tbody, tr, td { display: block; min-width: 0; width: 100%; }
  thead { display: none; }
  tr { padding: 12px; border: 1px solid var(--line); border-radius: 16px; margin-bottom: 12px; background: var(--panel-2); }
  td { display: grid; grid-template-columns: 120px minmax(0,1fr); gap: 10px; padding: 8px 0; border-bottom: 0; }
  td::before { content: attr(data-label); color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
}
