:root {
  --bg: #eef1f8;
  --bg-2: #e6e9f5;
  --panel: #ffffff;
  --ink: #0f172a;
  --ink-soft: #334155;
  --muted: #64748b;
  --line: #e6e9f2;
  --line-soft: #eef1f7;

  --brand: #4f46e5;
  --brand-2: #6366f1;
  --brand-ink: #4338ca;
  --brand-soft: #eef2ff;

  --accent: #0d9488;
  --danger: #e11d48;
  --danger-bg: #fff1f3;
  --danger-line: #fbcfe1;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .05);
  --shadow: 0 4px 12px rgba(15, 23, 42, .06), 0 12px 32px -12px rgba(15, 23, 42, .14);
  --shadow-lg: 0 8px 24px rgba(15, 23, 42, .08), 0 24px 56px -20px rgba(79, 70, 229, .28);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-family: var(--font);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background:
    radial-gradient(1100px 620px at 12% -8%, #e0e7ff 0%, rgba(224,231,255,0) 55%),
    radial-gradient(1000px 560px at 96% 0%, #dcfce7 0%, rgba(220,252,231,0) 50%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
  min-height: 100vh;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-ink); }

.hidden { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255,255,255,.72);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid rgba(226,232,240,.8);
  padding: 0 26px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar .brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -.2px;
  color: var(--ink);
}
.topbar .brand .logo {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: .5px;
  box-shadow: 0 6px 16px -6px rgba(79,70,229,.6);
}
.topbar .right { display: flex; align-items: center; gap: 16px; font-size: 14px; }
.topbar .right .user { color: var(--ink-soft); font-weight: 600; }
.topbar .right a { color: var(--muted); font-weight: 600; }
.topbar .right a:hover { color: var(--brand); }

.trainbadge {
  background: linear-gradient(135deg, #fef9c3, #fde68a);
  color: #92600a;
  border: 1px solid #f7dd8a;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 4px 11px;
  border-radius: 999px;
}

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  padding: 38px 34px;
  animation: pop .4s cubic-bezier(.18,.89,.32,1.28);
}
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.login-card .logo-big {
  width: 54px; height: 54px;
  border-radius: 15px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: .5px;
  margin-bottom: 20px;
  box-shadow: 0 12px 28px -10px rgba(79,70,229,.7);
}
.login-card h1 { font-size: 22px; margin: 0 0 5px; letter-spacing: -.4px; }
.login-card .sub { color: var(--muted); font-size: 13.5px; margin: 0 0 24px; }

label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 7px; color: var(--ink-soft); }
input[type=text], input[type=password], input[type=email], input[type=number], select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  font-size: 14.5px;
  font-family: var(--font);
  margin-bottom: 17px;
  background: #fff;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: #a3adbf; }
input:focus, select:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 4px rgba(99,102,241,.14); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 14.5px;
  font-weight: 650;
  font-family: var(--font);
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  box-shadow: 0 10px 22px -12px rgba(79,70,229,.85);
  transition: transform .12s, box-shadow .12s, filter .12s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 14px 26px -12px rgba(79,70,229,.95); filter: brightness(1.05); }
.btn:active { transform: translateY(0); }
.btn.block { width: 100%; }
.btn.secondary { background: #fff; color: var(--ink-soft); border-color: var(--line); box-shadow: var(--shadow-sm); }
.btn.secondary:hover { background: #fbfcfe; border-color: #d7dcea; filter: none; }
.btn.ghost { background: transparent; color: var(--brand); box-shadow: none; }
.btn.ghost:hover { background: var(--brand-soft); }
.btn.danger { background: linear-gradient(135deg, #e11d48, #f43f5e); box-shadow: 0 10px 22px -12px rgba(225,29,72,.8); }
.btn.sm { padding: 8px 14px; font-size: 13px; border-radius: 10px; }

.login-hint { font-size: 12.5px; color: var(--muted); margin-top: 15px; text-align: center; }
.login-hint strong { color: var(--ink-soft); }

/* ---------- App shell ---------- */
.shell { max-width: 1140px; margin: 0 auto; padding: 34px 26px 70px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 26px; flex-wrap: wrap; gap: 14px; }
.page-head h2 { margin: 0; font-size: 26px; letter-spacing: -.6px; }
.page-head .desc { color: var(--muted); font-size: 13.5px; margin-top: 3px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; }

/* KPI cards */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 28px; }
.kpi {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform .14s, box-shadow .14s;
}
.kpi::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: linear-gradient(180deg, var(--brand), var(--brand-2));
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.kpi .k-label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.kpi .k-value { font-size: 30px; font-weight: 800; margin-top: 5px; letter-spacing: -1px; }
.kpi .k-trend { font-size: 12px; margin-top: 5px; color: var(--accent); font-weight: 600; }
.kpi .k-trend.down { color: var(--danger); }

/* ---------- Table ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card .card-head { padding: 17px 22px; border-bottom: 1px solid var(--line-soft); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.card .card-head h3 { margin: 0; font-size: 16px; letter-spacing: -.3px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 14px 22px; font-size: 14px; border-bottom: 1px solid var(--line-soft); }
th { background: #f8fafc; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 700; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--brand-soft); }
tbody tr:last-child td { border-bottom: none; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 4px 11px; border-radius: 999px; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: #e7f8f0; color: #0f9d63; }
.pill.warn { background: #fef6e0; color: #b7791f; }
.pill.bad { background: var(--danger-bg); color: var(--danger); }
.pill.info { background: var(--brand-soft); color: var(--brand); }

.row-actions { display: flex; gap: 7px; }
.icon-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  color: var(--ink-soft);
  transition: all .12s;
}
.icon-btn:hover { background: #f8fafc; border-color: #d7dcea; }
.icon-btn.danger { color: var(--danger); border-color: var(--danger-line); }
.icon-btn.danger:hover { background: var(--danger-bg); }

/* ---------- Error banner (red) ---------- */
.errbar {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--danger-bg);
  border: 1px solid var(--danger-line);
  color: var(--danger);
  padding: 14px 18px;
  border-radius: 14px;
  font-size: 14px;
  margin-bottom: 20px;
  box-shadow: 0 10px 24px -14px rgba(225,29,72,.5);
  animation: shake .4s cubic-bezier(.36,.07,.19,.97);
}
@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}
.errbar .x {
  flex: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 800;
  font-size: 13px;
  margin-top: 1px;
}
.errbar .msg strong { display: block; font-weight: 700; }
.errbar .msg .detail { color: #9f1239; font-size: 12.5px; font-weight: 500; margin-top: 3px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.errbar .close { margin-left: auto; cursor: pointer; color: var(--danger); background: none; border: none; font-size: 18px; line-height: 1; opacity: .7; }
.errbar .close:hover { opacity: 1; }

.field-error { color: var(--danger); font-size: 12.5px; margin: -10px 0 14px; }

/* ---------- Landing (root + sub-landings) ---------- */
.landing { min-height: 100vh; display: flex; flex-direction: column; }
.landing .hero { max-width: 900px; margin: 0 auto; padding: 76px 24px 24px; text-align: center; }
.landing .hero .train-tag {
  display: inline-flex; align-items: center; gap: 7px; margin-bottom: 22px;
  background: rgba(255,255,255,.7);
  backdrop-filter: blur(8px);
  color: #92600a;
  border: 1px solid #f7dd8a;
  font-size: 12.5px; font-weight: 700; letter-spacing: .3px;
  padding: 7px 16px; border-radius: 999px;
  box-shadow: var(--shadow-sm);
}
.landing .hero h1 {
  font-size: 46px; line-height: 1.08; margin: 0 0 16px; letter-spacing: -1.6px; font-weight: 800;
  background: linear-gradient(120deg, #1e1b4b 0%, var(--brand) 55%, var(--brand-2) 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.landing .hero p { color: var(--ink-soft); font-size: 17px; max-width: 640px; margin: 0 auto; line-height: 1.6; }
.landing .hero p strong { color: var(--ink); }

.choices { max-width: 940px; margin: 36px auto 0; padding: 0 24px 64px; display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 24px; }
.choice {
  position: relative;
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 30px 28px;
  display: flex; flex-direction: column;
  transition: transform .16s cubic-bezier(.18,.89,.32,1.1), box-shadow .16s;
  overflow: hidden;
}
.choice::after {
  content: "";
  position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2), var(--accent));
  opacity: 0; transition: opacity .16s;
}
.choice:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); }
.choice:hover::after { opacity: 1; }
.choice .ico {
  width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center;
  font-size: 27px; margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}
.choice .ico.a { background: linear-gradient(135deg, #e0e7ff, #c7d2fe); }
.choice .ico.b { background: linear-gradient(135deg, #d1fae5, #a7f3d0); }
.choice h3 { margin: 0 0 8px; font-size: 21px; letter-spacing: -.4px; }
.choice p { color: var(--muted); font-size: 14.5px; margin: 0 0 22px; flex: 1; line-height: 1.6; }
.choice .btn { align-self: flex-start; }

.foot { text-align: center; color: var(--muted); font-size: 12.5px; padding: 26px; border-top: 1px solid var(--line); margin-top: auto; }

.backlink { font-size: 13px; }

@media (max-width: 560px) {
  .landing .hero { padding-top: 52px; }
  .landing .hero h1 { font-size: 34px; }
  .landing .hero p { font-size: 15.5px; }
}
