:root {
  color-scheme: light;
  --bg: #f4f7f5;
  --panel: #ffffff;
  --panel-soft: #eef5f2;
  --text: #16211d;
  --muted: #66756f;
  --line: #dce5e1;
  --primary: #1f7a5f;
  --primary-dark: #155c47;
  --accent: #c47a2c;
  --danger: #b54747;
  --shadow: 0 18px 45px rgba(24, 47, 38, .12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

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

button, a.link-button {
  border: 0;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}

.primary { background: var(--primary); color: white; }
.primary:hover { background: var(--primary-dark); }
.secondary { background: var(--panel); color: var(--text); border: 1px solid var(--line); }
.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); width: 100%; }
.danger { background: #fff4f4; color: var(--danger); border: 1px solid #f0caca; }
.hidden { display: none !important; }
.muted { color: var(--muted); line-height: 1.7; }
.eyebrow { margin: 0 0 6px; color: var(--accent); font-size: .78rem; font-weight: 700; letter-spacing: 0; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(130deg, rgba(31,122,95,.12), rgba(196,122,44,.08)),
    var(--bg);
}

.auth-panel {
  width: min(460px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.auth-panel h1 {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.5rem);
  line-height: 1.25;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--panel-soft);
  padding: 6px;
  border-radius: 8px;
  margin: 22px 0;
}

.tab {
  background: transparent;
  color: var(--muted);
}

.tab.active {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 2px 10px rgba(0,0,0,.06);
}

.form-stack {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: .9rem;
}

input, select, textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
}

textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(31,122,95,.18); border-color: var(--primary); }
.message { min-height: 22px; margin: 14px 0 0; color: var(--danger); }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #17251f;
  color: white;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 44px;
  aspect-ratio: 1;
  border-radius: 8px;
  background: #d49a45;
  color: #17251f;
  display: grid;
  place-items: center;
  font-weight: 800;
}

.brand small {
  display: block;
  color: #adc2ba;
  margin-top: 3px;
}

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

.nav-item {
  width: 100%;
  justify-content: flex-start;
  background: transparent;
  color: #d8e6e1;
  border-radius: 6px;
}

.nav-item.active, .nav-item:hover {
  background: rgba(255,255,255,.11);
  color: white;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

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

.topbar h2 {
  margin: 0;
  font-size: clamp(1.45rem, 2vw, 2rem);
}

.top-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.content {
  display: grid;
  gap: 18px;
}

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

.stat, .panel, .form-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stat {
  padding: 16px;
}

.stat span {
  color: var(--muted);
  font-size: .86rem;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 1.65rem;
}

.panel {
  overflow: hidden;
}

.panel-header {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-header h3 {
  margin: 0;
  font-size: 1.05rem;
}

.table-wrap {
  overflow-x: auto;
}

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

th, td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  vertical-align: top;
  white-space: nowrap;
}

th {
  background: #f8faf9;
  color: var(--muted);
  font-size: .83rem;
}

td {
  color: #26342f;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--panel-soft);
  color: var(--primary-dark);
  font-size: .82rem;
}

.form-panel {
  padding: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
}

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

.empty-state {
  padding: 34px 18px;
  color: var(--muted);
  text-align: center;
}

.toast {
  padding: 12px 14px;
  border-radius: 8px;
  background: #eaf6ef;
  color: var(--primary-dark);
  border: 1px solid #b9dec9;
}

.toast.error {
  background: #fff1f1;
  color: var(--danger);
  border-color: #f0caca;
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
  }
  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .workspace, .sidebar, .auth-shell { padding: 16px; }
  .auth-panel { padding: 20px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .top-actions, .top-actions > * { width: 100%; }
  .nav-list, .stats-grid, .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: span 1; }
}
