:root {
  --bg: #040914;
  --bg-soft: #07111d;
  --sidebar: #06111e;
  --surface: #0b1726;
  --surface-2: #0f1d2f;
  --line: #1c314b;
  --line-soft: rgba(255,255,255,.06);
  --text: #f7fbff;
  --muted: #95a7bc;
  --blue: #2f7cff;
  --cyan: #35d6ff;
  --green: #27d987;
  --purple: #9b6cff;
  --amber: #e9bb36;
  --red: #ff6676;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(0,0,0,.28);
  --sidebar-width: 272px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 78% -5%, rgba(47,124,255,.12), transparent 28%),
    radial-gradient(circle at 28% 105%, rgba(53,214,255,.06), transparent 32%),
    linear-gradient(180deg, var(--bg), var(--bg-soft));
  color: var(--text);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

body {
  min-height: 100vh;
}

a {
  color: inherit;
}

button,
input,
select,
textarea {
  font: inherit;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  height: 100vh;
  z-index: 30;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, rgba(6,17,30,.99), rgba(4,12,22,.99));
  border-right: 1px solid var(--line);
}

.logo {
  min-height: 96px;
  display: flex;
  align-items: center;
  padding: 18px;
  border-bottom: 1px solid var(--line-soft);
}

.logo img {
  width: 214px;
  max-width: 100%;
  display: block;
}

.sidebar nav {
  padding: 14px;
  overflow-y: auto;
}

.nav-heading {
  margin: 23px 10px 8px;
  color: #6f8299;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.nav-link {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 4px 0;
  padding: 9px 12px;
  color: #cbd6e4;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 8px;
  transition: .18s ease;
}

.nav-link span {
  width: 22px;
  color: #9db3cc;
  text-align: center;
  font-size: 18px;
}

.nav-link:hover {
  color: white;
  background: rgba(47,124,255,.10);
  border-color: rgba(47,124,255,.18);
  transform: translateX(2px);
}

.nav-link.active {
  color: white;
  background: linear-gradient(135deg, #2e7cf7, #1558d5);
  border-color: rgba(255,255,255,.10);
  box-shadow: 0 9px 24px rgba(32,104,226,.25);
}

.nav-link.disabled {
  opacity: .42;
  cursor: default;
}

.user-box {
  margin-top: auto;
  min-height: 82px;
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 11px;
  align-items: center;
  padding: 15px 18px;
  border-top: 1px solid var(--line);
}

.avatar {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-weight: 800;
  background: linear-gradient(135deg, #5d7590, #293d55);
}

.user-box div:nth-child(2) {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-box span {
  color: var(--green);
  font-size: 12px;
}

.user-box a {
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
}

.main {
  grid-column: 2;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 26px;
  background: rgba(4,9,20,.90);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
}

.menu-button {
  display: none;
  color: white;
  border: 0;
  background: transparent;
  font-size: 24px;
}

.system-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  color: #d9e6f6;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(10,22,38,.78);
  font-size: 12px;
}

.system-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 12px rgba(39,217,135,.7);
}

.content {
  flex: 1;
  width: 100%;
  max-width: 1700px;
  margin: 0 auto;
  padding: 22px;
}

footer {
  padding: 19px 24px;
  color: #657890;
  text-align: center;
  font-size: 12px;
}

.flash-stack {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.flash {
  padding: 12px 14px;
  border: 1px solid rgba(47,124,255,.36);
  border-radius: 8px;
  color: #dbe9ff;
  background: rgba(47,124,255,.10);
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.35fr .85fr;
  gap: 18px;
  margin-bottom: 18px;
}

.hero {
  position: relative;
  min-height: 252px;
  overflow: hidden;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 78% 38%, rgba(53,214,255,.14), transparent 26%),
    radial-gradient(circle at 58% 100%, rgba(47,124,255,.11), transparent 34%),
    linear-gradient(145deg, rgba(15,29,48,.99), rgba(7,17,31,.99));
  box-shadow: var(--shadow);
}

.hero::after {
  content: "M.I.A.I";
  position: absolute;
  right: -8px;
  bottom: -34px;
  color: rgba(255,255,255,.025);
  font-size: 130px;
  font-weight: 900;
  letter-spacing: .08em;
}

.hero h2 {
  max-width: 760px;
  margin: 0 0 12px;
  font-size: clamp(35px, 4vw, 61px);
  line-height: 1.03;
  letter-spacing: -.035em;
}

.hero h2 span {
  color: var(--cyan);
}

.hero p {
  max-width: 680px;
  margin: 0;
  color: #b6c4d6;
  font-size: 16px;
  line-height: 1.7;
}

.eyebrow {
  display: inline-block;
  margin-bottom: 10px;
  color: #7d91aa;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .10em;
  text-transform: uppercase;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 17px;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 750;
  text-decoration: none;
}

.button.primary,
button[type="submit"] {
  color: white;
  border: 0;
  background: linear-gradient(135deg, #2f7cff, #1457d0);
  box-shadow: 0 9px 22px rgba(31,103,226,.24);
}

.button.secondary {
  color: #dbe9f9;
  border: 1px solid var(--line);
  background: rgba(13,29,49,.82);
}

.button:hover {
  filter: brightness(1.08);
}

.panel,
.form-panel {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, rgba(12,24,41,.98), rgba(7,17,30,.98));
  box-shadow: var(--shadow);
}

.form-panel {
  width: min(1000px, 100%);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-header h2 {
  margin: 0;
}

.quick-grid {
  display: grid;
  gap: 12px;
}

.quick-card {
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  color: #e2ebf5;
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(13,29,49,.72);
  transition: .18s ease;
}

.quick-card:hover {
  border-color: rgba(47,124,255,.48);
  background: rgba(27,69,126,.24);
  transform: translateY(-2px);
}

.quick-card > span {
  color: var(--cyan);
  font-size: 23px;
}

.quick-card div {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.quick-card small {
  color: var(--muted);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0,1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi {
  min-height: 132px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(145deg, rgba(15,29,48,.98), rgba(8,19,33,.98));
  box-shadow: var(--shadow);
}

.kpi-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  flex: 0 0 46px;
  border-radius: 10px;
  color: var(--blue);
  background: rgba(47,124,255,.13);
  font-size: 23px;
}

.kpi-icon.green {
  color: var(--green);
}

.kpi-icon.purple {
  color: var(--purple);
}

.kpi-icon.cyan {
  color: var(--cyan);
}

.kpi div {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.kpi small {
  margin-bottom: 6px;
  color: #d9e2ee;
}

.kpi strong {
  margin-bottom: 10px;
  font-size: 30px;
  line-height: 1;
}

.kpi div span {
  color: var(--muted);
  font-size: 12px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0,1.7fr) minmax(320px,.9fr);
  gap: 18px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: middle;
}

th {
  color: #8fa1b7;
  font-size: 12px;
  font-weight: 700;
}

td {
  color: #dbe4ef;
  font-size: 13px;
}

tbody tr:hover td {
  background: rgba(47,124,255,.035);
}

.status {
  display: inline-flex;
  padding: 5px 9px;
  border-radius: 5px;
  font-size: 11px;
  text-transform: capitalize;
}

.status-completed {
  color: #8ff2b8;
  background: rgba(39,217,135,.18);
}

.status-running {
  color: #ffe49c;
  background: rgba(233,187,54,.18);
}

.status-failed {
  color: #ff9aa6;
  background: rgba(255,102,118,.17);
}

.status-queued,
.status-review,
.status-no_results {
  color: #afd0ff;
  background: rgba(47,124,255,.18);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 14px 18px;
}

.form-grid > div {
  display: grid;
  gap: 7px;
}

.form-grid label {
  color: #dbe4ef;
  font-size: 13px;
}

.form-grid input,
.form-grid select,
.form-grid textarea,
.login-card input {
  width: 100%;
  min-height: 45px;
  padding: 10px 12px;
  color: #f3f8ff;
  background: #091523;
  border: 1px solid #203650;
  border-radius: 7px;
  outline: none;
}

.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus,
.login-card input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47,124,255,.13);
}

.full-width {
  grid-column: 1 / -1;
}

.muted {
  color: var(--muted);
  line-height: 1.6;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4,minmax(0,1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.summary-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.summary-card small {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
}

.summary-card strong {
  font-size: 20px;
}

.empty {
  padding: 24px !important;
  color: var(--muted) !important;
  text-align: center !important;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(430px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    linear-gradient(145deg, rgba(12,24,41,.99), rgba(6,16,29,.99));
  box-shadow: 0 30px 80px rgba(0,0,0,.35);
}

.login-card img {
  display: block;
  width: 220px;
  margin: 0 auto 24px;
}

.login-card form {
  display: grid;
  gap: 12px;
}

.login-card label {
  color: #dbe4ef;
  font-size: 13px;
}

.login-card button {
  min-height: 44px;
  margin-top: 8px;
  border: 0;
  border-radius: 7px;
  color: white;
  background:
    linear-gradient(135deg, #2f7cff, #1457d0);
  cursor: pointer;
  font-weight: 750;
}

@media (max-width: 1450px) {
  .kpi-grid {
    grid-template-columns: repeat(3,minmax(0,1fr));
  }
}

@media (max-width: 1100px) {
  .hero-grid,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform .2s ease;
  }

  body.menu-open .sidebar {
    transform: translateX(0);
  }

  .main {
    grid-column: 1;
  }

  .menu-button {
    display: block;
  }

  .system-status {
    display: none;
  }

  .kpi-grid,
  .summary-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .full-width {
    grid-column: 1;
  }
}
