:root {
  --bg: #f4f8fc;
  --bg-page: #f9f9fb;
  --surface: #ffffff;
  --surface-tint: #eaf3fb;
  --surface-tint-2: #e5f1fb;
  --border: #e3e9f0;
  --border-strong: #d3dce6;
  --text: #00112d;
  --muted: #4b5563;
  --muted-2: #8a97ac;
  --blue: #177dbd;
  --blue-deep: #0f5e90;
  --sky-light: #7fd1ff;
  --green: #059669;
  --green-tint: #e7f6ef;
  --amber: #b45309;
  --amber-tint: #fdf2e1;
  --red: #dc2626;
  --red-tint: #fdecec;
  --navy: #00112d;
  --grad: linear-gradient(135deg, #177dbd 0%, #0f5e90 100%);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-card: 0 1px 2px rgba(0, 17, 45, 0.04), 0 8px 24px rgba(0, 17, 45, 0.05);
  --font-body: "Manrope", system-ui, -apple-system, sans-serif;
  --font-display: "Sora", var(--font-body);
  --sidebar-w: 248px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue-deep); }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.01em; line-height: 1.2; }
img { max-width: 100%; }
button { font-family: inherit; }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- auth screen ---------- */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
}
@media (max-width: 860px) { .auth-wrap { grid-template-columns: 1fr; } }
.auth-aside {
  background: linear-gradient(155deg, #0a2540 0%, #00112d 70%, #0d2c4d 100%);
  color: #fff;
  padding: 48px 44px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.auth-aside::after {
  content: "";
  position: absolute; top: -80px; right: -80px; width: 320px; height: 320px;
  background: radial-gradient(circle, rgba(127, 209, 255, 0.22), transparent 70%);
}
@media (max-width: 860px) { .auth-aside { display: none; } }
.auth-aside .brand-logo { height: 40px; filter: brightness(0) invert(1); }
.auth-aside h2 { font-size: 1.9rem; margin-bottom: 14px; position: relative; }
.auth-aside p { color: #9fb3cc; max-width: 30rem; position: relative; }
.auth-points { list-style: none; margin-top: 26px; display: grid; gap: 14px; position: relative; }
.auth-points li { display: flex; gap: 12px; align-items: flex-start; color: #cdd9e8; font-size: 0.95rem; }
.auth-points li b { color: #fff; font-weight: 600; }
.auth-points .dot {
  flex: none; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center;
  background: rgba(127, 209, 255, 0.16); color: var(--sky-light); font-weight: 700;
}
.auth-main {
  display: flex; align-items: center; justify-content: center;
  padding: 40px 24px; background: var(--bg-page);
}
.auth-card { width: min(420px, 100%); }
.auth-card .brand-logo-mobile { height: 36px; margin-bottom: 28px; display: none; }
@media (max-width: 860px) { .auth-card .brand-logo-mobile { display: block; } }
.auth-card h1 { font-size: 1.6rem; margin-bottom: 6px; }
.auth-card .sub { color: var(--muted); margin-bottom: 26px; }

/* ---------- forms ---------- */
.field { margin-bottom: 16px; display: flex; flex-direction: column; }
label { font-size: 0.84rem; font-weight: 600; margin-bottom: 7px; }
input[type="text"], input[type="tel"], input[type="email"], input[type="password"],
input[type="number"], select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 12px 14px; outline: none; width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(23, 125, 189, 0.15);
}
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238a97ac' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
::placeholder { color: var(--muted-2); }
.form-error { color: var(--red); font-size: 0.85rem; margin-top: 10px; min-height: 1.1em; }
.hint { color: var(--muted-2); font-size: 0.8rem; margin-top: 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: 999px; font-weight: 600; font-size: 0.92rem;
  text-decoration: none; border: 1px solid transparent; cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 6px 18px rgba(23, 125, 189, 0.28); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(23, 125, 189, 0.36); }
.btn-ghost { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover { background: var(--surface-tint); border-color: var(--blue); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(1.05); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 0.84rem; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; transform: none; }

/* ---------- app shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  background: var(--navy); color: #cdd9e8; padding: 22px 16px;
  display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand-logo { height: 34px; filter: brightness(0) invert(1); margin: 6px 8px 22px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 10px;
  color: #a9bcd2; text-decoration: none; font-size: 0.92rem; font-weight: 500;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav-item.active { background: var(--grad); color: #fff; box-shadow: 0 6px 16px rgba(23, 125, 189, 0.35); }
.nav-item .ico { width: 18px; text-align: center; }
.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.sidebar-user { font-size: 0.82rem; color: #8fa4bd; padding: 4px 8px 12px; word-break: break-word; }
.sidebar-user b { color: #fff; display: block; font-weight: 600; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 16px 30px; display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 1.3rem; }
.topbar .role-badge {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--blue-deep); background: var(--surface-tint); border: 1px solid rgba(23, 125, 189, 0.25);
  padding: 4px 10px; border-radius: 999px;
}
.topbar .spacer { margin-left: auto; }
.content { padding: 28px 30px 60px; max-width: 1200px; width: 100%; }

/* mobile shell */
.menu-btn { display: none; background: none; border: 0; font-size: 1.4rem; cursor: pointer; color: var(--text); }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 60; left: 0; top: 0; width: 260px; transform: translateX(-100%);
    transition: transform 0.22s ease; box-shadow: 0 0 40px rgba(0,0,0,0.3);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: block; }
  .content { padding: 20px 16px 50px; }
  .topbar { padding: 14px 16px; }
  .scrim { position: fixed; inset: 0; background: rgba(0,17,45,0.4); z-index: 55; display: none; }
  .scrim.show { display: block; }
}

/* ---------- tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 26px; }
@media (max-width: 1040px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .tiles { grid-template-columns: 1fr; } }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow-card); position: relative; overflow: hidden;
}
.tile .tile-label { color: var(--muted); font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.tile .tile-value { font-family: var(--font-display); font-size: 1.7rem; font-weight: 700; margin-top: 8px; }
.tile .tile-sub { color: var(--muted-2); font-size: 0.82rem; margin-top: 4px; }
.tile.accent { background: linear-gradient(150deg, #0a2540, #00112d); color: #fff; border-color: transparent; }
.tile.accent .tile-label { color: #9fb3cc; }
.tile.accent .tile-value { color: #fff; }
.tile.accent .tile-sub { color: var(--sky-light); }
.tile .tile-ico {
  position: absolute; top: 18px; right: 18px; width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center; font-size: 1.1rem; background: var(--surface-tint); color: var(--blue-deep);
}
.tile.accent .tile-ico { background: rgba(127,209,255,0.15); color: var(--sky-light); }

/* ---------- cards / panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-card); margin-bottom: 22px; }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.panel-head h2 { font-size: 1.05rem; }
.panel-head .spacer { margin-left: auto; }
.panel-body { padding: 6px 22px 22px; }
.panel-pad { padding: 22px; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.data th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: 0.76rem;
  text-transform: uppercase; letter-spacing: 0.04em; padding: 12px 14px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data td { padding: 13px 14px; border-bottom: 1px solid var(--bg); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--bg-page); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-strong { font-weight: 600; }
.cell-muted { color: var(--muted-2); }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  font-size: 0.76rem; font-weight: 600; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-green { color: var(--green); background: var(--green-tint); }
.badge-amber { color: var(--amber); background: var(--amber-tint); }
.badge-red { color: var(--red); background: var(--red-tint); }
.badge-blue { color: var(--blue-deep); background: var(--surface-tint); }
.badge-grey { color: var(--muted); background: #eef1f5; }

.pos { color: var(--green); font-weight: 600; }

/* ---------- empty / loading ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--muted-2); }
.empty .ico { font-size: 2rem; opacity: 0.5; }
.empty p { margin-top: 8px; }
.skeleton { color: transparent; background: linear-gradient(90deg, #eef2f7, #f6f9fc, #eef2f7); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 6px; }
@keyframes sk { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.loading-row td { padding: 22px 14px; }

/* ---------- modal ---------- */
.modal-scrim {
  position: fixed; inset: 0; background: rgba(0, 17, 45, 0.45); backdrop-filter: blur(2px);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-scrim.show { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius); width: min(460px, 100%);
  box-shadow: 0 30px 70px rgba(0, 17, 45, 0.3); overflow: hidden;
}
.modal-head { padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 1.15rem; }
.modal-head p { color: var(--muted); font-size: 0.88rem; margin-top: 4px; }
.modal-body { padding: 20px 24px; }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ---------- toast ---------- */
.toast-host { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 0.9rem;
  box-shadow: 0 10px 30px rgba(0,17,45,0.35); max-width: 340px; animation: toast-in 0.25s ease;
}
.toast-success { background: var(--green); }
.toast-error { background: var(--red); }
.toast-out { opacity: 0; transform: translateY(8px); transition: all 0.3s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.section-title { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted-2); margin: 8px 0 14px; }
