:root {
  --navy: #1c2333;
  --navy-light: #2a3349;
  --oak: #b5702f;
  --oak-light: #d99456;
  --bg: #f7f7f5;
  --surface: #ffffff;
  --border: #e2e0da;
  --text: #232323;
  --text-muted: #6b6b66;
  --fillin: #fff2cc;
  --danger: #b3432b;
  --ok: #4a7c59;
  --radius: 6px;
  --shadow: 0 2px 10px rgba(28, 35, 51, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--navy);
  color: #e8e8ea;
  display: flex;
  flex-direction: column;
  padding: 20px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 12px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--oak);
  color: white;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.5px;
}

.brand-title {
  font-weight: 700;
  font-size: 15px;
  color: #fff;
}

.brand-sub {
  font-size: 11px;
  color: #9a9fae;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 12px;
  flex: 1;
}

.nav-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: none;
  border: none;
  color: #c4c8d4;
  font-size: 13.5px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

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

.nav-item.active {
  background: var(--oak);
  color: #fff;
  font-weight: 600;
}

.sidebar-footer {
  padding: 12px 20px 0;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.db-status {
  font-size: 11px;
  color: #9a9fae;
}

.db-status.ok::before {
  content: "● ";
  color: #6fbf8b;
}

.db-status.error::before {
  content: "● ";
  color: #e07a5f;
}

/* ---------- Main ---------- */
.main {
  flex: 1;
  padding: 28px 32px;
  overflow-x: auto;
}

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

.topbar h1 {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  color: var(--navy);
}

.btn {
  border: none;
  border-radius: var(--radius);
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s, background 0.15s;
}

.btn:focus-visible {
  outline: 2px solid var(--oak);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--oak);
  color: #fff;
}
.btn-primary:hover { filter: brightness(1.08); }

.btn-secondary {
  background: #eceae4;
  color: var(--text);
}
.btn-secondary:hover { filter: brightness(0.97); }

.btn-danger-text {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 12.5px;
  padding: 4px 6px;
}
.btn-danger-text:hover { text-decoration: underline; }

.btn-edit-text {
  background: none;
  border: none;
  color: var(--navy);
  cursor: pointer;
  font-size: 12.5px;
  padding: 4px 6px;
}
.btn-edit-text:hover { text-decoration: underline; }

/* ---------- Table ---------- */
.table-wrap {
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: auto;
  border: 1px solid var(--border);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

.data-table thead th {
  background: var(--navy);
  color: #fff;
  text-align: left;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.data-table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: top;
  max-width: 280px;
}

.data-table tbody tr:hover {
  background: #faf9f6;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.col-actions {
  white-space: nowrap;
  width: 1%;
}

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

.empty-state p {
  margin-bottom: 16px;
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 35, 51, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.modal {
  background: var(--surface);
  border-radius: 10px;
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 16px;
  margin: 0;
  color: var(--navy);
}

.icon-btn {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 8px;
}
.icon-btn:hover { color: var(--text); }

.modal-form {
  padding: 18px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.field input,
.field select,
.field textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 13.5px;
  font-family: inherit;
  background: var(--fillin);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid var(--oak);
  outline-offset: 1px;
  background: #fff;
}

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

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--border);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  box-shadow: var(--shadow);
  z-index: 100;
}

.toast.error {
  background: var(--danger);
}

/* ---------- Responsive ---------- */
@media (max-width: 780px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    padding: 12px;
    overflow-x: auto;
  }
  .brand { border-bottom: none; margin-bottom: 0; padding: 0 12px 0 0; }
  .nav { flex-direction: row; padding: 0; }
  .sidebar-footer { display: none; }
  .main { padding: 18px; }
}
