:root {
  --bg: #07090d;
  --bg2: #0d1016;
  --panel: rgba(17, 21, 29, .76);
  --panel-strong: rgba(21, 26, 35, .92);
  --border: rgba(255,255,255,.08);
  --text: #f4f6f8;
  --muted: #8d96a5;
  --red: #e12b3c;
  --red2: #ff4353;
  --green: #3bd18a;
  --amber: #f0b84f;
  --blue: #5ea1ff;
  --shadow: 0 30px 80px rgba(0,0,0,.46);
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(circle at 15% 10%, rgba(225,43,60,.17), transparent 24%),
    radial-gradient(circle at 88% 78%, rgba(118,24,42,.17), transparent 28%),
    linear-gradient(135deg, #07090d 0%, #0a0d12 48%, #06080b 100%);
  color: var(--text);
  font-family: "Segoe UI", Inter, Arial, sans-serif;
  overflow-x: hidden;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.82), transparent 92%);
}
body::after {
  content: "LEGION";
  position: fixed;
  right: -4vw;
  bottom: -7vh;
  font-size: 24vw;
  font-weight: 900;
  letter-spacing: -.08em;
  color: rgba(255,255,255,.012);
  pointer-events: none;
  user-select: none;
}
.ambient { position: fixed; border-radius: 50%; filter: blur(90px); pointer-events: none; opacity: .45; }
.ambient-a { width: 420px; height: 420px; background: rgba(225,43,60,.20); left: -180px; top: 16%; animation: driftA 14s ease-in-out infinite alternate; }
.ambient-b { width: 520px; height: 520px; background: rgba(118,21,45,.15); right: -210px; bottom: -120px; animation: driftB 18s ease-in-out infinite alternate; }
@keyframes driftA { to { transform: translate(70px, -40px) scale(1.08); } }
@keyframes driftB { to { transform: translate(-70px, -50px) scale(.94); } }
.glass {
  background: linear-gradient(160deg, rgba(22,27,36,.86), rgba(12,15,21,.74));
  border: 1px solid var(--border);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.025);
  backdrop-filter: blur(18px);
}
.login-body { display: grid; place-items: center; min-height: 100vh; }
.login-shell { width: min(430px, calc(100vw - 34px)); position: relative; z-index: 2; }
.login-card { border-radius: 28px; padding: 36px; position: relative; overflow: hidden; }
.login-card::before { content:""; position:absolute; inset:0 0 auto 0; height:3px; background:linear-gradient(90deg, transparent, var(--red), transparent); }
.brand-mark {
  width: 72px; height: 72px; border-radius: 22px; display:grid; place-items:center;
  font-size: 38px; font-weight:900; font-style: italic; letter-spacing:-.08em;
  color:white; background:linear-gradient(145deg, #fa3c4e, #9b1628);
  box-shadow: 0 16px 36px rgba(225,43,60,.28), inset 0 1px 0 rgba(255,255,255,.24);
}
.brand-mark.small { width: 44px; height: 44px; border-radius: 14px; font-size: 24px; flex:0 0 auto; }
.brand-stack { margin-top: 24px; }
.brand-name { font-size: 34px; font-weight:900; letter-spacing:.11em; line-height:1; }
.brand-product { margin-top: 6px; color: var(--red2); font-size: 13px; font-weight:800; letter-spacing:.52em; }
.brand-name.compact { font-size: 16px; letter-spacing:.08em; }
.brand-product.compact { font-size: 8px; letter-spacing:.35em; margin-top:4px; }
.login-form { margin-top: 40px; }
.login-form label, .section-kicker, .kicker { color: var(--muted); font-size: 10px; font-weight:800; letter-spacing:.22em; }
.login-form input, .field, .big-input {
  width: 100%; border: 1px solid rgba(255,255,255,.09); outline: none;
  background: rgba(5,8,12,.67); color: var(--text); border-radius: 14px;
  transition: border-color .2s, box-shadow .2s, transform .2s;
}
.login-form input { margin: 9px 0 14px; padding: 15px 16px; font-size: 18px; letter-spacing:.18em; }
.login-form input:focus, .field:focus, .big-input:focus { border-color: rgba(225,43,60,.75); box-shadow:0 0 0 4px rgba(225,43,60,.08); }
.btn {
  border:0; border-radius: 12px; color:white; font-weight:800; letter-spacing:.06em;
  cursor:pointer; transition: transform .15s, filter .15s, opacity .15s; font-family:inherit;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.08); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity:.5; cursor:not-allowed; transform:none; }
.btn.primary { background: linear-gradient(135deg, var(--red2), #b5162b); box-shadow: 0 12px 28px rgba(225,43,60,.18); }
.btn.secondary { background: rgba(255,255,255,.055); border:1px solid rgba(255,255,255,.08); color:#e6e9ed; }
.btn.danger { background: rgba(225,43,60,.13); border:1px solid rgba(225,43,60,.28); color:#ff7280; }
.btn.full { width:100%; padding:14px 16px; }
.btn.xl { padding: 0 28px; min-height:56px; }
.btn.compact { padding: 10px 13px; font-size: 11px; }
.login-error { height: 20px; color:#ff6473; text-align:center; margin-top:10px; font-size:11px; font-weight:800; letter-spacing:.1em; }
.login-foot { text-align:center; color:#4f5867; font-size:9px; letter-spacing:.16em; margin-top:20px; }
.app-shell { min-height: 100vh; display:grid; grid-template-columns: 236px 1fr; gap:18px; padding:18px; position:relative; z-index:2; }
.sidebar { min-height: calc(100vh - 36px); position:sticky; top:18px; border-radius:24px; padding:18px 14px; display:flex; flex-direction:column; }
.sidebar-brand { display:flex; gap:12px; align-items:center; padding:5px 7px 22px; border-bottom:1px solid rgba(255,255,255,.055); }
.nav { display:flex; flex-direction:column; gap:7px; padding-top:18px; }
.nav-item { width:100%; background:transparent; border:0; color:#7f8998; display:flex; align-items:center; gap:12px; padding:13px 13px; border-radius:13px; font-weight:800; font-size:11px; letter-spacing:.08em; cursor:pointer; text-align:left; }
.nav-item:hover { background:rgba(255,255,255,.04); color:#d9dde3; }
.nav-item.active { color:white; background:linear-gradient(90deg, rgba(225,43,60,.17), rgba(225,43,60,.035)); box-shadow: inset 2px 0 0 var(--red); }
.nav-icon { width:22px; color:var(--red2); font-size:18px; line-height:1; text-align:center; }
.sidebar-bottom { margin-top:auto; border-top:1px solid rgba(255,255,255,.055); padding:17px 7px 2px; }
.identity { display:flex; gap:10px; align-items:center; }
.identity-dot { width:9px; height:9px; border-radius:50%; background:var(--green); box-shadow:0 0 16px rgba(59,209,138,.75); }
.identity-name { font-size:11px; font-weight:800; }
.identity-role { margin-top:2px; color:#697382; font-size:9px; letter-spacing:.12em; }
.ghost-link { margin-top:15px; background:none; border:0; padding:0; color:#5f6876; font-size:10px; font-weight:800; cursor:pointer; letter-spacing:.12em; }
.workspace { min-width:0; padding: 12px 14px 40px 0; }
.topbar { display:flex; align-items:center; justify-content:space-between; min-height:72px; margin-bottom:18px; padding:0 4px; }
h1 { font-size:27px; margin:5px 0 0; letter-spacing:.03em; }
h2 { font-size:17px; margin:5px 0 0; letter-spacing:.03em; }
.topbar-right { display:flex; gap:8px; }
.system-pill, .version-pill { border:1px solid rgba(255,255,255,.07); background:rgba(255,255,255,.035); border-radius:999px; padding:9px 12px; font-size:9px; font-weight:800; letter-spacing:.12em; color:#727c8b; }
.system-pill span { display:inline-block; width:7px; height:7px; background:var(--green); border-radius:50%; margin-right:7px; box-shadow:0 0 12px rgba(59,209,138,.55); }
.view { display:none; animation:fade .22s ease; }
.view.active { display:block; }
@keyframes fade { from{opacity:0;transform:translateY(5px)} to{opacity:1;transform:none} }
.hero-grid { display:grid; grid-template-columns:minmax(0,1fr) 250px; gap:16px; }
.panel { border-radius:22px; }
.hero-panel { padding:27px; position:relative; overflow:hidden; min-height:268px; }
.hero-panel::after { content:""; position:absolute; width:260px; height:260px; right:-120px; top:-120px; border-radius:50%; background:rgba(225,43,60,.12); filter:blur(20px); pointer-events:none; }
.hero-title { margin-top:8px; font-size:28px; font-weight:900; letter-spacing:.025em; }
.search-row { display:flex; gap:10px; margin-top:24px; position:relative; z-index:1; }
.big-input { min-height:56px; padding:0 17px; font-size:15px; }
.metric-panel { padding:27px; display:flex; flex-direction:column; justify-content:center; }
.metric-label { color:#747e8d; font-size:10px; font-weight:800; letter-spacing:.18em; }
.metric-value { font-size:58px; line-height:1; font-weight:900; letter-spacing:-.055em; margin-top:12px; }
.metric-unit { color:var(--red2); font-size:10px; font-weight:900; letter-spacing:.25em; margin-top:8px; }
.metric-line { height:1px; background:linear-gradient(90deg, var(--red), transparent); margin:24px 0 12px; }
.metric-sub { color:#4e5765; font-size:9px; letter-spacing:.18em; }
.job-console { margin-top:18px; background:rgba(3,5,8,.46); border:1px solid rgba(255,255,255,.055); border-radius:15px; padding:15px; position:relative; z-index:1; }
.job-head { display:flex; justify-content:space-between; align-items:center; gap:18px; }
.job-status { color:#f3c65c; font-size:10px; font-weight:900; letter-spacing:.14em; }
.job-target { max-width:520px; color:#687281; font-size:10px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; margin-top:4px; }
.job-found { font-size:25px; font-weight:900; }
.progress-track { height:7px; border-radius:999px; background:rgba(255,255,255,.055); overflow:hidden; margin-top:14px; }
.progress-bar { height:100%; width:0; background:linear-gradient(90deg, #b5162b, #ff4959); border-radius:999px; box-shadow:0 0 18px rgba(225,43,60,.35); transition:width .3s ease; }
.job-meta { margin-top:10px; display:flex; align-items:center; justify-content:space-between; color:#65707f; font-size:10px; }
.job-error { margin-top:11px; border-radius:10px; background:rgba(225,43,60,.08); border:1px solid rgba(225,43,60,.14); color:#ff7885; padding:10px 12px; font-size:10px; }
.table-panel { margin-top:16px; padding:22px; overflow:hidden; }
.panel-head { display:flex; align-items:center; justify-content:space-between; gap:14px; margin-bottom:15px; }
.panel-head.split .actions { display:flex; gap:8px; }
.table-wrap { overflow:auto; }
table { width:100%; border-collapse:collapse; min-width:720px; }
th { text-align:left; color:#5d6775; font-size:9px; letter-spacing:.14em; font-weight:900; padding:10px 12px; border-bottom:1px solid rgba(255,255,255,.06); }
td { padding:13px 12px; border-bottom:1px solid rgba(255,255,255,.045); color:#c9ced6; font-size:11px; vertical-align:middle; }
tr:last-child td { border-bottom:0; }
tr:hover td { background:rgba(255,255,255,.012); }
.cell-main { color:#edf0f4; font-weight:700; }
.cell-sub { margin-top:4px; color:#5c6573; font-size:9px; max-width:280px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.status { display:inline-flex; align-items:center; gap:7px; padding:7px 9px; border-radius:999px; font-size:9px; font-weight:900; letter-spacing:.08em; border:1px solid rgba(255,255,255,.06); background:rgba(255,255,255,.035); }
.status::before { content:""; width:7px; height:7px; border-radius:50%; background:#6e7785; }
.status.active::before, .status.done::before { background:var(--green); box-shadow:0 0 10px rgba(59,209,138,.4); }
.status.flood::before, .status.waiting::before, .status.running::before { background:var(--amber); }
.status.frozen::before, .status.failed::before, .status.unauthorized::before { background:var(--red2); }
.status.disabled::before { background:#545c68; }
.row-actions { display:flex; justify-content:flex-end; gap:6px; }
.icon-btn { border:1px solid rgba(255,255,255,.07); background:rgba(255,255,255,.035); color:#a7afba; border-radius:9px; padding:7px 9px; cursor:pointer; font-size:10px; }
.icon-btn:hover { color:white; background:rgba(255,255,255,.07); }
.icon-btn.danger { color:#ff6977; }
.stats-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:12px; margin-bottom:16px; }
.stat-card { padding:18px; border-radius:18px; }
.stat-label { color:#65707e; font-size:9px; font-weight:900; letter-spacing:.14em; }
.stat-value { font-size:30px; font-weight:900; margin-top:8px; }
.operator-layout { display:grid; grid-template-columns:300px minmax(0,1fr); gap:16px; }
.create-card { padding:22px; height:max-content; }
.create-card h2 { margin-bottom:18px; }
.field { padding:13px 14px; margin-bottom:10px; font-size:12px; }
select.field { appearance:none; }
.mini-message { min-height:18px; padding-top:9px; color:#7f8996; font-size:10px; }
.grow { margin-top:0; }
.toast { position:fixed; right:24px; bottom:24px; min-width:240px; max-width:360px; padding:13px 15px; border:1px solid rgba(255,255,255,.09); background:rgba(16,20,27,.94); border-radius:13px; box-shadow:var(--shadow); color:white; font-size:11px; transform:translateY(22px); opacity:0; pointer-events:none; transition:.25s; z-index:30; }
.toast.show { transform:none; opacity:1; }
.hidden { display:none !important; }
.admin-only.hidden-role { display:none !important; }
@media (max-width: 980px) {
  .app-shell { grid-template-columns: 78px 1fr; }
  .sidebar-brand > div:last-child, .nav-item span:last-child, .identity > div:last-child, .ghost-link { display:none; }
  .sidebar-brand { justify-content:center; }
  .nav-item { justify-content:center; padding:13px 8px; }
  .nav-icon { width:auto; }
  .identity { justify-content:center; }
  .hero-grid { grid-template-columns:1fr; }
  .metric-panel { min-height:170px; }
  .operator-layout { grid-template-columns:1fr; }
}
@media (max-width: 700px) {
  .app-shell { display:block; padding:10px; }
  .sidebar { min-height:auto; position:static; flex-direction:row; align-items:center; padding:9px; border-radius:17px; margin-bottom:10px; }
  .sidebar-brand { border:0; padding:0 8px 0 0; }
  .nav { flex-direction:row; padding:0; overflow:auto; flex:1; }
  .nav-item { width:auto; }
  .sidebar-bottom { border:0; padding:0; margin:0 0 0 8px; }
  .workspace { padding:0 0 28px; }
  .topbar { padding:5px 7px; }
  .search-row { flex-direction:column; }
  .stats-grid { grid-template-columns:repeat(2,1fr); }
  .panel-head.split { align-items:flex-start; flex-direction:column; }
}
