:root {
  --bg: #0a0c10;
  --bg-soft: #0f131a;
  --panel: #141821;
  --panel-2: #1a2029;
  --line: #232a36;
  --line-soft: #1c2330;
  --text: #e9ecf2;
  --muted: #8b95a7;
  --gold: #f5b544;
  --gold-soft: rgba(245, 181, 68, 0.12);
  --green: #3ddc97;
  --blue: #5b8cff;
  --purple: #a97bff;
  --red: #ff6b6b;
  --gray: #7a8394;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 20px 40px -24px rgba(0, 0, 0, 0.9);
  --sidebar-w: 250px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Be Vietnam Pro', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(900px 500px at 12% -10%, rgba(245, 181, 68, 0.09), transparent 60%),
    radial-gradient(700px 460px at 100% 0%, rgba(91, 140, 255, 0.08), transparent 62%);
  background-attachment: fixed;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
img { display: block; max-width: 100%; }

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

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  padding: 22px 16px;
  border-right: 1px solid var(--line-soft);
  background: rgba(10, 12, 16, 0.85);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 4px 6px; }
.brand-mark {
  width: 40px; height: 40px; flex: 0 0 40px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(150deg, #ffd479, var(--gold) 55%, #d98f1c);
  color: #201603;
  font-weight: 800;
  font-size: 20px;
  box-shadow: 0 8px 22px -10px rgba(245, 181, 68, 0.85);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 17px; letter-spacing: 0.02em; }
.brand-text em { font-style: normal; font-size: 11.5px; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 12px;
  border-radius: 11px;
  color: var(--muted);
  font-weight: 500;
  font-size: 14.5px;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item i { width: 18px; text-align: center; font-size: 15px; }
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: var(--gold-soft); color: var(--gold); font-weight: 600; }

.sidebar-foot {
  margin-top: auto;
  display: flex; gap: 9px;
  font-size: 11.5px;
  color: var(--muted);
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: rgba(20, 24, 33, 0.6);
}
.sidebar-foot i { color: var(--gold); margin-top: 2px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px;
  padding: 22px 28px 16px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(10, 12, 16, 0.6);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.page-head h1 { font-size: 22px; }
.page-head p { color: var(--muted); font-size: 13px; margin-top: 2px; }
.topbar-actions { display: flex; gap: 9px; }

.view { padding: 24px 28px 64px; flex: 1; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 15px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease, opacity 0.15s;
  white-space: nowrap;
}
.btn:hover { background: var(--panel-2); border-color: #2f3948; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(160deg, #ffcd6b, var(--gold) 60%, #e0a027);
  border-color: transparent;
  color: #221705;
  box-shadow: 0 10px 26px -14px rgba(245, 181, 68, 0.95);
}
.btn-primary:hover { background: linear-gradient(160deg, #ffd98b, #f8c057 60%, #e6a92c); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 7px 11px; font-size: 13px; border-radius: 9px; }
.btn-danger { color: var(--red); border-color: rgba(255, 107, 107, 0.35); background: rgba(255, 107, 107, 0.08); }
.btn-danger:hover { background: rgba(255, 107, 107, 0.16); border-color: rgba(255, 107, 107, 0.5); }
.btn-icon { padding: 8px; width: 34px; height: 34px; border-radius: 9px; }

/* ---------- panels / cards ---------- */
.card {
  background: linear-gradient(180deg, rgba(26, 32, 41, 0.95), rgba(20, 24, 33, 0.95));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.card-head h3 { font-size: 15px; }
.card-head .muted { font-size: 12.5px; color: var(--muted); }
.card-body { padding: 16px 18px; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.amber { color: var(--gold); background: rgba(245, 181, 68, 0.12); border-color: rgba(245, 181, 68, 0.28); }
.badge.blue { color: var(--blue); background: rgba(91, 140, 255, 0.12); border-color: rgba(91, 140, 255, 0.28); }
.badge.purple { color: var(--purple); background: rgba(169, 123, 255, 0.12); border-color: rgba(169, 123, 255, 0.28); }
.badge.green { color: var(--green); background: rgba(61, 220, 151, 0.12); border-color: rgba(61, 220, 151, 0.28); }
.badge.gray { color: var(--gray); background: rgba(122, 131, 148, 0.14); border-color: rgba(122, 131, 148, 0.3); }
.badge.red { color: var(--red); background: rgba(255, 107, 107, 0.12); border-color: rgba(255, 107, 107, 0.28); }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field .hint { font-size: 11.5px; color: var(--muted); }
input[type="text"], input[type="tel"], input[type="email"], input[type="date"],
input[type="time"], input[type="number"], input[type="search"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  background: #0d1117;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: rgba(245, 181, 68, 0.6);
  box-shadow: 0 0 0 3px rgba(245, 181, 68, 0.12);
}
textarea { resize: vertical; min-height: 70px; }
select { appearance: none; background-image: none; cursor: pointer; }
input[type="date"], input[type="time"] { color-scheme: dark; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.tbl td { padding: 13px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.tbl tbody tr { cursor: pointer; transition: background 0.12s ease; }
table.tbl tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
table.tbl tbody tr:last-child td { border-bottom: none; }
.td-strong { font-weight: 600; }
.td-muted { color: var(--muted); font-size: 12.5px; }
.td-right { text-align: right; }

/* ---------- modal ---------- */
#modal-root:empty { display: none; }
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(4, 6, 9, 0.72);
  backdrop-filter: blur(3px);
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}
.modal {
  width: min(560px, 100%);
  max-height: min(88vh, 900px);
  display: flex;
  flex-direction: column;
  background: #12161e;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 40px 80px -30px rgba(0, 0, 0, 0.95);
  animation: slideUp 0.18s ease;
}
.modal.wide { width: min(760px, 100%); }
.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.modal-head h3 { font-size: 17px; }
.modal-head p { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.modal-close {
  background: transparent; border: none; color: var(--muted);
  font-size: 18px; cursor: pointer; padding: 4px 6px; border-radius: 8px; line-height: 1;
}
.modal-close:hover { color: var(--text); background: var(--panel); }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--line-soft);
}
.modal-error {
  margin: 0 20px 12px;
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(255, 107, 107, 0.12);
  border: 1px solid rgba(255, 107, 107, 0.32);
  color: #ffb3b3;
  font-size: 13px;
  display: none;
}
.modal-error.show { display: block; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- toast ---------- */
.toast-root {
  position: fixed; right: 20px; bottom: 22px;
  display: flex; flex-direction: column; gap: 9px;
  z-index: 120;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 15px;
  border-radius: 12px;
  background: #171d27;
  border: 1px solid var(--line);
  box-shadow: 0 18px 34px -20px rgba(0, 0, 0, 0.95);
  font-size: 13.5px;
  font-weight: 500;
  animation: slideUp 0.18s ease;
  max-width: 340px;
}
.toast.ok { border-color: rgba(61, 220, 151, 0.4); color: #b9f6d8; }
.toast.ok i { color: var(--green); }
.toast.err { border-color: rgba(255, 107, 107, 0.45); color: #ffc4c4; }
.toast.err i { color: var(--red); }
.toast.info i { color: var(--gold); }

/* ---------- misc ---------- */
.muted { color: var(--muted); }
.grid { display: grid; gap: 16px; }
.spacer { flex: 1; }
.empty {
  text-align: center;
  padding: 44px 22px;
  color: var(--muted);
}
.empty i { font-size: 30px; color: #3a4454; margin-bottom: 12px; display: block; }
.empty h3 { color: var(--text); font-size: 16px; margin-bottom: 6px; }
.empty p { font-size: 13.5px; max-width: 420px; margin: 0 auto 16px; }
.skeleton {
  border-radius: 12px;
  background: linear-gradient(90deg, #141821 25%, #1b222c 37%, #141821 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.spin { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- responsive ---------- */
@media (max-width: 1023px) {
  :root { --sidebar-w: 78px; }
  .brand-text, .nav-item span, .sidebar-foot span { display: none; }
  .brand { justify-content: center; }
  .nav-item { justify-content: center; padding: 13px 0; }
  .sidebar-foot { justify-content: center; padding: 10px 0; }
  .topbar, .view { padding-left: 18px; padding-right: 18px; }
}

@media (max-width: 700px) {
  .app { flex-direction: column; }
  .sidebar {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto;
    width: 100%; height: auto; flex: none;
    flex-direction: row; align-items: center; justify-content: space-around;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    border-right: none; border-top: 1px solid var(--line);
    background: rgba(10, 12, 16, 0.97);
    z-index: 50;
    gap: 0;
  }
  .brand, .sidebar-foot { display: none; }
  .nav { flex-direction: row; width: 100%; justify-content: space-around; gap: 0; }
  .nav-item {
    flex-direction: column; gap: 3px;
    padding: 7px 4px; font-size: 10px; border-radius: 9px;
    flex: 1;
  }
  .nav-item span { display: block; }
  .nav-item i { font-size: 17px; }
  .main { padding-bottom: 74px; }
  .topbar {
    padding: 14px 15px 12px;
    align-items: center;
    position: static;
  }
  .page-head h1 { font-size: 18px; }
  .page-head p { display: none; }
  .topbar-actions .label { display: none; }
  .topbar-actions .btn { padding: 10px 12px; }
  .view { padding: 16px 15px 40px; }
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal { width: 100%; max-height: 92vh; border-radius: 18px 18px 0 0; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .toast-root { left: 14px; right: 14px; bottom: 84px; }
  .toast { max-width: none; }
}
