:root {
  color-scheme: light;
  --navy: #142238;
  --navy-soft: #1d304d;
  --blue: #2457d6;
  --blue-dark: #1946b5;
  --bg: #f3f6fb;
  --surface: #fff;
  --text: #1d2939;
  --muted: #66758a;
  --line: #e3e9f2;
  --success-bg: #e9f8ef;
  --success: #17643a;
  --danger-bg: #fff0ee;
  --danger: #a33226;
  --radius: 14px;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
body.modal-open { overflow: hidden; }
a { color: var(--blue); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .7; }
:focus-visible { outline: 3px solid #7da4ff; outline-offset: 2px; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  width: 252px;
  padding: 26px 18px 18px;
  color: #fff;
  background: linear-gradient(180deg, var(--navy), #101c2e);
}
.brand { padding: 7px 10px 28px; font-size: 19px; font-weight: 800; letter-spacing: -.45px; }
.brand.large { padding: 0; color: var(--navy); font-size: 25px; text-align: center; }
nav { display: grid; gap: 7px; }
nav a {
  padding: 11px 13px;
  border-radius: 9px;
  color: #dce5f5;
  text-decoration: none;
  transition: background .15s ease, color .15s ease;
}
nav a:hover, nav a.active { color: #fff; background: #ffffff1b; }
nav a.active { box-shadow: inset 3px 0 #8fb0ff; font-weight: 700; }
.userbox {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding: 17px 9px 0;
  border-top: 1px solid #ffffff25;
  color: #d3dceb;
  font-size: 13px;
}
.userbox span { overflow: hidden; text-overflow: ellipsis; }
.userbox form { margin: 0; }
.logout-btn { border: 0; padding: 5px 8px; color: #fff; background: transparent; border-radius: 6px; }
.logout-btn:hover { background: #ffffff18; }

.main { width: min(100% - 252px, 1600px); margin-left: 252px; padding: 34px clamp(18px, 3vw, 42px); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 25px; }
.topbar h1 { margin: 0; font-size: clamp(23px, 2.3vw, 30px); letter-spacing: -.8px; line-height: 1.2; }
.eyebrow { margin: 0 0 6px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: 1.5px; }

.panel, .stats article, .login-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 5px 20px #172b4d08;
}
.panel { margin-bottom: 22px; padding: clamp(17px, 2vw, 24px); }
.panel h2 { margin: 0 0 17px; font-size: 17px; letter-spacing: -.2px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-head a { font-weight: 700; text-decoration: none; }
.panel-head a:hover { text-decoration: underline; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.stats article { min-width: 0; padding: 20px; }
.stats span { display: block; color: var(--muted); font-size: 13px; }
.stats strong { display: block; margin-top: 8px; font-size: clamp(22px, 2.4vw, 29px); letter-spacing: -.8px; overflow-wrap: anywhere; }

.primary {
  min-height: 42px;
  padding: 10px 17px;
  border: 1px solid var(--blue);
  border-radius: 9px;
  color: #fff;
  background: var(--blue);
  font-weight: 750;
  transition: background .15s ease, transform .15s ease;
}
.primary:hover { border-color: var(--blue-dark); background: var(--blue-dark); }
.primary:active { transform: translateY(1px); }
.full { width: 100%; margin-top: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.form-grid label, .login-card label { display: grid; gap: 6px; color: #465367; font-size: 13px; font-weight: 700; }
.form-grid .wide { grid-column: 1 / -1; }
input, select, textarea {
  width: 100%; min-width: 0; min-height: 42px; padding: 10px 12px;
  border: 1px solid #d6deea; border-radius: 8px; color: var(--text); background: #fff;
}
input::placeholder, textarea::placeholder { color: #98a4b5; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: 3px solid #2457d61c; }
textarea { min-height: 86px; resize: vertical; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 12px 13px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; }
th { position: sticky; top: 0; color: var(--muted); background: #f8fafd; font-weight: 800; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f9fbff; }
td small { display: block; margin-top: 3px; color: var(--muted); white-space: normal; }
.status { display: inline-flex; align-items: center; border-radius: 30px; padding: 4px 10px; color: #3154a5; background: #edf2ff; font-size: 11px; font-weight: 800; }
.empty { padding: 10px 0; color: var(--muted); }
.alert { margin: 0 0 18px; padding: 12px 15px; border-radius: 9px; font-weight: 600; }
.alert.success { color: var(--success); background: var(--success-bg); }
.alert.error { color: var(--danger); background: var(--danger-bg); }
.small-btn { padding: 7px 11px; border: 1px solid #dce5ff; border-radius: 7px; color: #244caa; background: #f0f4ff; font-weight: 700; }
.small-btn:hover { background: #e5edff; }

.modal { display: none; position: fixed; inset: 0; z-index: 10; align-items: center; justify-content: center; padding: 18px; background: #0c172b99; }
.modal.open { display: flex; }
.modal-card { position: relative; width: min(740px, 100%); max-height: min(90vh, 900px); overflow: auto; padding: clamp(20px, 3vw, 28px); border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: 0 20px 70px #0003; }
.modal-card h2 { margin: 0 42px 21px 0; font-size: 20px; }
.close { position: absolute; top: 12px; right: 15px; width: 36px; height: 36px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; font-size: 27px; line-height: 1; }
.close:hover { background: #f0f3f8; }

.login-main { display: grid; width: 100%; min-height: 100vh; margin: 0; padding: 22px; place-items: center; background: radial-gradient(ellipse at top, #e8efff, var(--bg) 60%); }
.login-card { width: min(430px, 100%); padding: clamp(25px, 5vw, 38px); }
.login-card h1 { margin: 16px 0 25px; text-align: center; font-size: 22px; }
.login-card form { display: grid; gap: 16px; }

@media (max-width: 1050px) {
  .sidebar { width: 218px; }
  .main { width: calc(100% - 218px); margin-left: 218px; padding: 26px 22px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .sidebar { position: sticky; top: 0; width: 100%; padding: 10px 12px; }
  .brand { padding: 3px 5px 9px; font-size: 17px; }
  nav { display: flex; gap: 5px; overflow-x: auto; padding-bottom: 3px; }
  nav a { flex: 0 0 auto; padding: 8px 10px; font-size: 12px; white-space: nowrap; }
  nav a.active { box-shadow: inset 0 -2px #8fb0ff; }
  .userbox { position: absolute; top: 8px; right: 10px; margin: 0; padding: 0; border: 0; }
  .userbox span { display: none; }
  .main { width: 100%; margin: 0; padding: 19px 14px; }
  .topbar { align-items: flex-start; }
  .topbar .primary { flex: 0 0 auto; padding: 9px 11px; font-size: 12px; }
  .stats { gap: 9px; }
  .stats article { padding: 14px; }
  .stats span { font-size: 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .panel { padding: 16px; }
  .modal { align-items: flex-end; padding: 8px; }
  .modal-card { max-height: 92vh; border-radius: 16px 16px 10px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
