:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #172033;
  --muted: #68758a;
  --line: #dfe6ef;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --success: #15803d;
  --warning: #b45309;
  --danger: #b91c1c;
  --sidebar: #0f172a;
  --sidebar-soft: #1e293b;
  --shadow: 0 10px 30px rgba(15, 23, 42, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--primary); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at top left, #dbeafe 0, #f4f7fb 38%, #eef2ff 100%);
}
.login-card {
  width: min(430px, 100%);
  background: var(--panel);
  border: 1px solid rgba(148, 163, 184, .28);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 34px;
}
.brand-mark {
  width: 46px; height: 46px; border-radius: 14px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff; font-weight: 800; letter-spacing: .04em;
  box-shadow: 0 8px 20px rgba(37, 99, 235, .22);
}
.brand-row { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.brand-row h1 { margin: 0; font-size: 22px; }
.brand-row p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.dashboard { min-height: 100vh; display: grid; grid-template-columns: 255px minmax(0, 1fr); }
.sidebar {
  background: var(--sidebar); color: #e2e8f0; padding: 22px 14px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand-row { padding: 0 8px 18px; border-bottom: 1px solid rgba(148,163,184,.16); }
.sidebar .brand-row h1 { color: #fff; font-size: 18px; }
.sidebar .brand-row p { color: #94a3b8; }
.nav { margin-top: 18px; display: grid; gap: 4px; }
.nav button {
  width: 100%; border: 0; background: transparent; color: #cbd5e1;
  text-align: left; padding: 10px 12px; border-radius: 10px; font-weight: 600;
}
.nav button:hover { background: rgba(148,163,184,.12); color: #fff; }
.nav button.active { background: var(--sidebar-soft); color: #fff; }
.sidebar-footer { margin-top: 22px; padding: 14px 8px; border-top: 1px solid rgba(148,163,184,.16); }

.main { min-width: 0; }
.topbar {
  height: 72px; background: rgba(255,255,255,.92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); display: flex; align-items: center;
  justify-content: space-between; padding: 0 28px; position: sticky; top: 0; z-index: 20;
}
.topbar h2 { margin: 0; font-size: 20px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.content { padding: 28px; max-width: 1550px; margin: 0 auto; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.page-heading h3 { margin: 0 0 5px; font-size: 24px; }
.page-heading p { margin: 0; color: var(--muted); }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 5px 18px rgba(15,23,42,.045); padding: 20px; min-width: 0;
}
.card h4 { margin: 0 0 14px; font-size: 16px; }
.metric strong { font-size: 28px; display: block; margin-top: 6px; }
.metric span { color: var(--muted); font-size: 13px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin-bottom: 16px; }
.field { display: grid; gap: 6px; min-width: 140px; flex: 1; }
.field.compact { flex: 0 1 180px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 700; letter-spacing: .02em; }
input, select, textarea {
  width: 100%; border: 1px solid #cfd8e6; border-radius: 9px; padding: 9px 10px;
  background: #fff; color: var(--text); outline: none;
}
textarea { min-height: 78px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #93b4f7; box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; }
.check input { width: auto; }

.btn {
  border: 1px solid transparent; border-radius: 9px; padding: 9px 13px; font-weight: 700;
  background: #e8edf5; color: #24324a; transition: .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-strong); }
.btn-danger { background: #fee2e2; color: var(--danger); border-color: #fecaca; }
.btn-success { background: #dcfce7; color: var(--success); border-color: #bbf7d0; }
.btn-warning { background: #fef3c7; color: var(--warning); border-color: #fde68a; }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-sm { padding: 6px 9px; font-size: 12px; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; white-space: nowrap; }
th { background: var(--panel-soft); color: #4b5a70; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
td.wrap { white-space: normal; min-width: 180px; }
.empty { padding: 26px; text-align: center; color: var(--muted); }

.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 8px; font-size: 11px; font-weight: 800; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-neutral { background: #e2e8f0; color: #475569; }

.section-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.section-tabs button { border: 1px solid var(--line); background: #fff; padding: 8px 12px; border-radius: 999px; font-weight: 700; color: #53637a; }
.section-tabs button.active { background: #eaf1ff; color: #1d4ed8; border-color: #bfdbfe; }

.split { display: grid; grid-template-columns: minmax(280px, .9fr) minmax(0, 2fr); gap: 18px; }
.sequence-list { display: grid; gap: 8px; }
.sequence-row { display: grid; grid-template-columns: 36px 1fr auto; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: #fff; }
.sequence-pos { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: #eef2ff; color: #3730a3; font-weight: 800; }
.sequence-actions { display: flex; gap: 4px; }

.callout { border: 1px solid #bfdbfe; background: #eff6ff; color: #1e3a8a; border-radius: 12px; padding: 13px 15px; font-size: 13px; }
.callout.warning { border-color: #fed7aa; background: #fff7ed; color: #9a3412; }
.error-box { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; border-radius: 10px; padding: 12px; margin: 10px 0; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.56); display: grid; place-items: center; padding: 20px; z-index: 100; }
.modal { width: min(650px, 100%); max-height: 90vh; overflow: auto; background: #fff; border-radius: 16px; box-shadow: 0 22px 60px rgba(15,23,42,.25); }
.modal-head, .modal-foot { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.modal-head h4 { margin: 0; }
.modal-body { padding: 20px; }
.modal-foot { border-top: 1px solid var(--line); border-bottom: 0; justify-content: flex-end; }

.toast-root { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 200; }
.toast { min-width: 260px; max-width: 430px; background: #111827; color: #fff; border-radius: 10px; padding: 12px 14px; box-shadow: var(--shadow); font-size: 13px; }
.toast.error { background: #991b1b; }
.toast.success { background: #166534; }
.loading { opacity: .62; pointer-events: none; }

@media (max-width: 1050px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .dashboard { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main { min-width: 0; }
  .topbar { position: static; padding: 0 16px; }
  .content { padding: 18px 14px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .page-heading { flex-direction: column; }
}
