:root {
  --bg: #f4f1ea;
  --surface: #ffffff;
  --ink: #17221f;
  --muted: #68736e;
  --brand: #145c4c;
  --brand-strong: #0f4a3d;
  --brand-soft: #e4f0eb;
  --accent: #c96a4a;
  --accent-soft: #f7e7e0;
  --line: #e3ddd2;
  --warn: #9a5310;
  --warn-soft: #fdf1e2;
  --danger: #a83a2a;
  --ok: #2c7a5c;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: Georgia, "Times New Roman", serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

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

button {
  cursor: pointer;
}

.app {
  min-height: 100vh;
}

a {
  color: var(--brand);
}

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

.sidebar {
  background: #0d2a21;
  color: #f4f1ea;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: #f4f1ea;
  color: #10201b;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
}

.brand-title {
  font-weight: 700;
  font-size: 14px;
  line-height: 1.2;
}

.brand-sub {
  color: rgba(244, 241, 234, 0.55);
  font-size: 11px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav button {
  appearance: none;
  border: 0;
  background: transparent;
  color: rgba(244, 241, 234, 0.7);
  text-align: left;
  padding: 9px 11px;
  border-radius: 9px;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

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

.nav button.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-weight: 650;
}

.nav .count {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 10px;
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: rgba(244, 241, 234, 0.6);
  font-size: 11px;
}

.user {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 10px 11px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 9px;
}

.user strong {
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  word-break: break-all;
}

.main {
  min-width: 0;
  padding: 24px 26px 48px;
}

.header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.header h1 {
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: -0.01em;
  font-size: clamp(26px, 3vw, 36px);
  margin: 0;
}

.header h1::after {
  content: "";
  display: block;
  width: 54px;
  height: 4px;
  margin-top: 12px;
  border-radius: 4px;
  background: var(--accent);
}

.header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.button {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 9px;
  background: var(--brand);
  color: #fff;
  padding: 9px 14px;
  min-height: 38px;
  font-weight: 600;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.button:hover {
  background: var(--brand-strong);
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.button.secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

.button.secondary:hover {
  background: #f8f4ec;
}

.button.danger {
  background: #f6e3df;
  color: var(--danger);
  border-color: #ecc8c0;
}

.button.danger:hover {
  background: #f1d5cf;
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

.card + .card {
  margin-top: 16px;
}

.card-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0 0 12px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  min-height: 92px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
}

.stat-label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 650;
}

.stat-value {
  font-family: var(--display);
  font-size: 30px;
  line-height: 1;
  letter-spacing: -0.02em;
}

.stat-value.small {
  font-family: var(--font);
  font-size: 17px;
  font-weight: 700;
}

.stat.note {
  background: var(--brand-soft);
  border-color: #c6e0d6;
}

.banner {
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 13px;
}

.banner.legal {
  background: var(--warn-soft);
  border: 1px solid #efd3ae;
  color: #6f3d0a;
}

.banner.ok {
  background: var(--brand-soft);
  border: 1px solid #c6e0d6;
  color: #1d5a49;
}

.banner strong {
  display: block;
  margin-bottom: 3px;
}

.banner a {
  color: inherit;
}

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

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

.input,
.select,
.textarea {
  border: 1px solid var(--line);
  background: #fffdf9;
  border-radius: 9px;
  padding: 8px 10px;
  min-height: 38px;
  outline: none;
  min-width: 0;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(20, 92, 76, 0.12);
}

.textarea {
  min-height: 78px;
  resize: vertical;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

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

thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  background: #faf7f1;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

tbody td {
  padding: 11px 12px;
  border-bottom: 1px solid #efeae0;
  vertical-align: top;
}

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

tbody tr:hover {
  background: #fdfbf7;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

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

.nowrap {
  white-space: nowrap;
}

.right {
  text-align: right;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
  background: #eee9df;
  color: #6d675d;
}

.badge.green {
  background: var(--brand-soft);
  color: var(--brand);
}

.badge.red {
  background: #f6e3df;
  color: var(--danger);
}

.badge.amber {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge.blue {
  background: #e7eef6;
  color: #35628f;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label {
  font-size: 11px;
  font-weight: 650;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.field .hint {
  color: var(--muted);
  font-size: 11px;
}

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

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--ink);
}

.checkbox input {
  margin-top: 2px;
  accent-color: var(--brand);
}

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

.empty {
  text-align: center;
  color: var(--muted);
  padding: 32px 20px;
}

.loading {
  color: var(--muted);
  padding: 22px;
  text-align: center;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: #10201b;
  color: #fff;
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 13px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.3);
  max-width: min(420px, calc(100vw - 36px));
  z-index: 100;
  animation: toast-in 0.2s ease;
}

.toast.error {
  background: #7c2d1f;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 24, 21, 0.55);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 50;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: min(820px, 100%);
  max-height: min(88vh, 900px);
  overflow: auto;
  padding: 22px;
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.35);
}

.modal.wide {
  width: min(980px, 100%);
}

.modal h2 {
  font-family: var(--display);
  font-weight: 400;
  font-size: 26px;
  margin: 0 0 14px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.detail {
  background: #faf7f1;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

.detail .label {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
  margin-bottom: 3px;
}

.detail .value {
  font-size: 13px;
  word-break: break-word;
}

.subtable {
  min-width: 0;
  width: 100%;
  font-size: 12px;
}

.subtable th,
.subtable td {
  padding: 7px 8px;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  background: #faf7f1;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  max-height: 220px;
  overflow: auto;
}

details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(20, 92, 76, 0.18), transparent 60%),
    var(--bg);
}

.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(23, 34, 31, 0.12);
}

.login-card h1 {
  font-family: var(--display);
  font-weight: 400;
  font-size: 30px;
  margin: 0 0 4px;
}

.login-card p {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 20px;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.locale {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f4f1ea;
  border-radius: 8px;
  padding: 7px 8px;
  font-size: 12px;
}

.error-text {
  color: var(--danger);
  font-size: 12px;
  margin: 6px 0 0;
}

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

  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
    gap: 12px;
  }

  .nav {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .nav button {
    white-space: nowrap;
  }

  .sidebar-footer {
    display: none;
  }

  .main {
    padding: 16px 14px 40px;
  }

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