:root {
  --bg: #f3f4f8;
  --panel: #ffffff;
  --border: #e6e7ef;
  --border-soft: #eef0f6;
  --text: #23253a;
  --muted: #7c7f95;
  --accent: #4f5fd6;
  --accent-dark: #3d4bb8;
  --accent-soft: #eef0fd;
  --ok: #1f9d55;
  --ok-soft: #e7f7ee;
  --warn: #b7791f;
  --warn-soft: #fdf3e0;
  --err: #d8483f;
  --err-soft: #fceceb;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(30, 34, 60, 0.04), 0 4px 16px rgba(30, 34, 60, 0.05);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin-top: 0; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
small.muted, .muted { color: var(--muted); }
a { color: var(--accent); }
code {
  background: var(--accent-soft);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 12px;
}

/* ---------- layout shell ---------- */

.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 16px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #7c8ef2);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  flex: none;
}

.brand-text {
  font-size: 13px;
  line-height: 1.25;
  color: var(--muted);
}
.brand-text b { color: var(--text); font-size: 15px; }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 12px;
  flex: 1;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: background 0.12s ease, color 0.12s ease;
}

.sidebar-nav a svg {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.8;
}

.sidebar-nav a:hover {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.sidebar-nav a.active {
  background: var(--accent-soft);
  color: var(--accent-dark);
  border-left-color: var(--accent);
  font-weight: 700;
}

.sidebar-foot {
  padding: 14px 18px 18px;
  border-top: 1px solid var(--border-soft);
}
.sidebar-foot small { color: var(--muted); font-size: 11.5px; }
.sidebar-user { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sidebar-user-name { font-weight: 700; font-size: 13px; text-decoration: none; color: var(--text); }
.sidebar-user-name:hover { color: var(--accent-dark); }
.logout-btn { background: none; color: var(--muted); padding: 0; font-weight: 600; }
.logout-btn:hover { color: var(--err); text-decoration: underline; }

/* ---------- auth pages (login/setup, no sidebar) ---------- */

.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(160deg, var(--accent) 0%, #7c8ef2 55%, var(--bg) 55%);
}
.auth-wrap { width: 100%; max-width: 380px; padding: 20px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; justify-content: center; }
.auth-brand .brand-text { color: white; font-size: 15px; }
.auth-brand .brand-text b { color: white; font-size: 18px; }
.auth-panel h1 { font-size: 19px; margin-bottom: 14px; }
.auth-panel .field { max-width: none; }

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

.topbar {
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.topbar-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--muted);
}

main {
  padding: 24px 28px 40px;
  max-width: 1400px;
  width: 100%;
}

/* ---------- panels & cards ---------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin-bottom: 18px;
}

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.card .num { font-size: 26px; font-weight: 800; color: var(--text); letter-spacing: -0.02em; }
.card .label { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* ---------- stat cards (dashboard) ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.stat-card .num { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.stat-card .label { color: var(--muted); font-size: 12px; margin-top: 2px; }
.stat-icon {
  width: 42px; height: 42px; flex: none;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
}
.stat-icon svg {
  width: 21px; height: 21px;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.stat-icon-blue { background: var(--accent-soft); color: var(--accent-dark); }
.stat-icon-purple { background: #f4ecfb; color: #7a3fb0; }
.stat-icon-green { background: var(--ok-soft); color: #146338; }
.stat-icon-amber { background: var(--warn-soft); color: #8a5a10; }

.move-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.move-grid .field { max-width: none; }

.participant-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
}
.participant-row .field { max-width: none; flex: 1; margin-bottom: 0; }
#participant-rows { margin-bottom: 12px; }

.run-panel { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.run-panel > div:nth-child(2) { flex: 1; min-width: 240px; }
.run-panel h2 { margin-bottom: 2px; }
.run-panel p { margin: 0; font-size: 13px; }

.panel-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; gap: 10px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; }
.bar-lg { height: 16px; }

/* ---------- quick step links (dashboard) ---------- */

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.12s ease, background 0.12s ease, transform 0.08s ease;
}
.step:hover { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); }
.step b { display: block; font-size: 13px; }
.step small { font-size: 11.5px; }
.step-num {
  width: 26px; height: 26px; flex: none;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 12.5px;
}
.run-note { color: var(--muted); font-size: 12.5px; margin: 0; }
.run-note b { color: var(--text); }

/* ---------- tables ---------- */

table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { border-bottom: 1px solid var(--border-soft); padding: 9px 10px; text-align: left; }
th {
  background: #fafafd;
  color: var(--muted);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  position: sticky;
  top: 0;
  z-index: 1;
}
tbody tr { transition: background 0.1s ease; }
tbody tr:hover { background: var(--accent-soft); }
.table-wrap {
  max-height: 70vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--panel);
}
.table-wrap table { margin: 0; }

/* ---------- forms & buttons ---------- */

form.inline { display: inline; }

.filters {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: end;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.filters label { display: block; font-size: 11.5px; color: var(--muted); font-weight: 600; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.02em; }

input, select, textarea {
  font-size: 13.5px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

button {
  background: var(--accent);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  transition: background 0.12s ease, transform 0.05s ease;
}
button:hover { background: var(--accent-dark); }
button:active { transform: translateY(1px); }
button.secondary { background: var(--panel); color: var(--text); border: 1px solid var(--border); }
button.secondary:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-dark); }

.actions-row { display: flex; gap: 10px; margin-bottom: 4px; flex-wrap: wrap; }

/* ---------- upload cards (import page) ---------- */

.upload-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin-bottom: 16px;
}
.upload-head { display: flex; gap: 14px; margin-bottom: 14px; }
.upload-head h2 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.upload-head p { margin: 4px 0 0; font-size: 13px; max-width: 640px; }
.upload-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.pill {
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
}
.tag-optional {
  background: var(--border-soft);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ---------- flashes ---------- */

.flashes { margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.flash {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  box-shadow: var(--shadow);
}
.flash-icon {
  width: 20px; height: 20px; flex: none;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800;
}
.flash-success { background: var(--ok-soft); color: #146338; }
.flash-success .flash-icon { background: var(--ok); color: white; }
.flash-warning { background: var(--warn-soft); color: #7a5211; }
.flash-warning .flash-icon { background: var(--warn); color: white; }
.flash-error { background: var(--err-soft); color: #8f2d26; }
.flash-error .flash-icon { background: var(--err); color: white; }

/* ---------- badges ---------- */

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
}
.badge-0 { background: var(--err-soft); color: #8f2d26; }
.badge-1 { background: var(--ok-soft); color: #146338; }
.badge-2 { background: var(--accent-soft); color: var(--accent-dark); }
.badge-cazat { background: var(--ok-soft); color: #146338; }
.badge-necazat { background: var(--err-soft); color: #8f2d26; }

/* ---------- misc widgets ---------- */

.link-btn { font-size: 12.5px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.link-btn:hover { text-decoration: underline; }

.bar-outer { background: var(--border-soft); border-radius: 999px; overflow: hidden; height: 10px; width: 100%; }
.bar-inner { background: linear-gradient(90deg, var(--accent), #7c8ef2); height: 100%; border-radius: 999px; }

.checkbox-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.checkbox-row input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); }

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  padding: 14px 16px;
  background: #fbfbfd;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  max-width: 280px;
  margin-bottom: 12px;
}
.field input, .field select { font-weight: 400; color: var(--text); }
.field:last-child { margin-bottom: 0; }

.page-lead { margin-bottom: 16px; }
.page-lead h1 { margin-bottom: 8px; }
.lead-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.back-link { color: var(--muted); font-weight: 600; }
.back-link:hover { color: var(--accent-dark); }

legend { font-weight: 700; font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; padding: 0 6px; }

/* ---------- responsive ---------- */

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-nav a span:last-child { display: none; }
  main { padding: 16px; }
}
