:root {
  --ink: #16262b;
  --ink-soft: #4a5c61;
  --paper: #f6f4ee;
  --panel: #ffffff;
  --line: #dcd9cf;
  --teal-900: #0e3b3e;
  --teal-700: #14595c;
  --teal-500: #1d7d80;
  --gold: #b9862f;
  --red: #a3402f;
  --green: #3c6e47;
  --radius: 6px;
  --font-display: "Source Serif 4", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--teal-700); }

/* ---------- Shell layout ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--teal-900);
  color: #dce8e6;
  padding: 24px 0;
  display: flex;
  flex-direction: column;
}

.sidebar .brand {
  padding: 0 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  margin-bottom: 16px;
}
.sidebar .brand .mark-img {
  width: 36px; height: 36px;
  object-fit: contain;
  display: block;
  margin-bottom: 10px;
}
.sidebar .brand .title {
  font-family: var(--font-display);
  font-size: 15px;
  line-height: 1.3;
  color: #fff;
}
.sidebar .brand .sub {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #9fb9b6;
  margin-top: 4px;
}

.sidebar nav { display: flex; flex-direction: column; padding: 0 12px; gap: 2px; }
.sidebar nav a {
  color: #cfe0de;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 14px;
}
.sidebar nav a:hover { background: rgba(255,255,255,0.08); }
.sidebar nav a.active { background: var(--teal-700); color: #fff; font-weight: 600; }

.sidebar-footer {
  margin-top: auto;
  padding: 16px 12px 4px;
  text-align: center;
  color: #5f8783;
  font-size: 11px;
}

.main { flex: 1; padding: 32px 40px; max-width: 1200px; }

.page-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-header h1 {
  font-family: var(--font-display);
  font-size: 26px;
  margin: 0 0 4px;
  color: var(--teal-900);
}
.page-header p { margin: 0; color: var(--ink-soft); font-size: 14px; }

/* ---------- Cards / panels ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 28px; }
.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--teal-500);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat-card .num { font-family: var(--font-display); font-size: 30px; color: var(--teal-900); line-height: 1; }
.stat-card .label { font-size: 12.5px; color: var(--ink-soft); margin-top: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card.warn { border-left-color: var(--gold); }
.stat-card.danger { border-left-color: var(--red); }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left; padding: 10px 12px; background: #eef0ea;
  border-bottom: 1px solid var(--line); color: var(--ink-soft);
  font-weight: 600; text-transform: uppercase; font-size: 11.5px; letter-spacing: 0.04em;
}
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: #fbfaf6; }

.badge {
  display: inline-block; padding: 3px 9px; border-radius: 100px;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.02em;
}
.badge-green { background: #e4efe6; color: var(--green); }
.badge-red { background: #f5e5e1; color: var(--red); }
.badge-gold { background: #f4ead2; color: var(--gold); }
.badge-neutral { background: #e7e5dd; color: var(--ink-soft); }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 4px; color: var(--ink); }
input, select, textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: var(--radius);
  font-family: var(--font-body); font-size: 14px; background: #fff; color: var(--ink);
}
textarea { min-height: 70px; resize: vertical; }

select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='7' viewBox='0 0 11 7'%3E%3Cpath d='M1 1L5.5 5.5L10 1' stroke='%234a5c61' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 11px 7px;
}
.toolbar select { width: auto; min-width: 140px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }

button, .btn {
  font-family: var(--font-body); font-size: 14px; font-weight: 600;
  padding: 10px 18px; border-radius: var(--radius); border: none;
  cursor: pointer; background: var(--teal-700); color: #fff;
  text-decoration: none; display: inline-block;
}
button:hover, .btn:hover { background: var(--teal-900); }
button.secondary, .btn.secondary { background: transparent; color: var(--teal-700); border: 1px solid var(--teal-500); }
button.secondary:hover { background: #eaf2f1; }
button.danger { background: var(--red); }
button.danger:hover { background: #832f22; }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.toolbar .filters { display: flex; gap: 8px; }
.toolbar select, .toolbar input { width: auto; }

.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(14,59,62,0.45);
  align-items: center; justify-content: center; z-index: 50;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: var(--radius); padding: 26px 28px;
  width: 520px; max-width: 92vw; max-height: 88vh; overflow-y: auto;
}
.modal h2 { font-family: var(--font-display); margin-top: 0; color: var(--teal-900); font-size: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.empty-state { text-align: center; padding: 50px 20px; color: var(--ink-soft); }
.empty-state .icon { font-size: 32px; margin-bottom: 8px; }

.section-title {
  font-family: var(--font-display); font-size: 17px; color: var(--teal-900);
  margin: 28px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line);
}

.tag-perm { color: var(--teal-700); font-weight: 600; }
.tag-temp { color: var(--gold); font-weight: 600; }

@media print {
  .sidebar, .no-print { display: none !important; }
  .main { padding: 0; max-width: 100%; }
  body { background: #fff; }
}

@media (max-width: 800px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; padding: 12px; overflow-x: auto; }
  .sidebar .brand { display: none; }
  .sidebar nav { flex-direction: row; }
  .main { padding: 20px; }
  .form-row { grid-template-columns: 1fr; }
}
