:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --border: #e6e1d6;
  --text: #1a1a1a;
  --text-muted: #6b6660;
  --primary: #b8862b;
  --primary-hover: #96701f;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success: #16a34a;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.05);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

/* ---------- Layout ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
}

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

.brand-mark .brand-icon svg {
  width: 26px;
  height: 26px;
  color: var(--primary);
}

.brand-mark .brand-name {
  font-weight: 800;
  font-size: 17px;
  letter-spacing: 0.3px;
  border-bottom: 2px solid var(--primary);
  padding-bottom: 2px;
  display: inline-block;
}

.brand-mark .brand-name span {
  color: var(--primary);
}

.brand-mark .brand-sub {
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 3px;
}

.brand-mark.lg .brand-icon svg {
  width: 44px;
  height: 44px;
}

.brand-mark.lg .brand-name {
  font-size: 26px;
}

.brand-mark.lg .brand-sub {
  font-size: 12px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--text-muted);
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px;
}

/* ---------- Login ---------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}

.login-card h1 {
  font-size: 20px;
  margin: 0 0 4px;
}

.login-card p.subtitle {
  margin: 0 0 24px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ---------- Forms ---------- */

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

input[type="text"],
input[type="password"],
input[type="url"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
  background: var(--surface);
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
}

button {
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  padding: 10px 16px;
  background: var(--primary);
  color: #fff;
  transition: background 0.15s ease;
}

button:hover {
  background: var(--primary-hover);
}

button.secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

button.secondary:hover {
  background: var(--bg);
}

button.danger {
  background: var(--danger);
}

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

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.checkbox-row input {
  width: auto;
  margin: 0;
}

.error-msg {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}

.hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: -10px;
  margin-bottom: 16px;
}

/* ---------- Dashboard cards ---------- */

.section-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 16px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.sys-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sys-card .icon {
  color: var(--primary);
}
.sys-card .icon svg {
  width: 30px;
  height: 30px;
}

.sys-card h3 {
  margin: 0;
  font-size: 16px;
}

.sys-card p {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  flex-grow: 1;
}

.sys-card button {
  margin-top: 8px;
}

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

/* ---------- Admin ---------- */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.tab-btn {
  background: none;
  color: var(--text-muted);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 10px 16px;
}

.tab-btn:hover {
  background: none;
  color: var(--text);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

th, td {
  text-align: left;
  padding: 10px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--bg);
  color: var(--text-muted);
  font-weight: 600;
}

tr:last-child td {
  border-bottom: none;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.badge.active {
  background: #dcfce7;
  color: var(--success);
}
.badge.inactive {
  background: #f3f4f6;
  color: var(--text-muted);
}
.badge.admin {
  background: #f3e6c8;
  color: #8a651f;
}

.row-actions {
  display: flex;
  gap: 8px;
}
.row-actions button {
  padding: 6px 10px;
  font-size: 12px;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
}

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
}

.modal h2 {
  margin: 0 0 20px;
  font-size: 18px;
}

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

.checkbox-group {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 16px;
  max-height: 160px;
  overflow-y: auto;
}
.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
  font-size: 13px;
  margin-bottom: 8px;
}
.checkbox-group label:last-child {
  margin-bottom: 0;
}
.checkbox-group input {
  width: auto;
  margin: 0;
}

.icon-picker {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.icon-option {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
}

.icon-option svg {
  width: 20px;
  height: 20px;
}

.icon-option:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.icon-option.selected {
  border-color: var(--primary);
  background: #f3e6c8;
  color: var(--primary);
}

.icon-cell {
  color: var(--primary);
}
.icon-cell svg {
  width: 20px;
  height: 20px;
}

.hidden {
  display: none !important;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181d;
    --surface: #1f2229;
    --border: #2d3138;
    --text: #e6e7ea;
    --text-muted: #9aa0aa;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  }
  .error-msg {
    background: #3a1a1a;
    border-color: #5c2626;
  }
  .badge.active {
    background: #123a24;
  }
  .badge.inactive {
    background: #2a2d33;
  }
  .badge.admin {
    background: #3d3115;
    color: #e0b559;
  }
  .icon-option.selected {
    background: #3d3115;
  }
}
