:root {
  color-scheme: dark;
  --bg: #07101d;
  --bg-deep: #050b14;
  --panel: rgba(14, 25, 42, .86);
  --panel-solid: #0d192a;
  --panel-soft: #111f33;
  --line: rgba(151, 174, 207, .13);
  --line-bright: rgba(151, 174, 207, .23);
  --text: #f2f7ff;
  --muted: #8798b2;
  --subtle: #60718c;
  --green: #3ce6a5;
  --green-soft: rgba(60, 230, 165, .12);
  --violet: #9c7cff;
  --violet-soft: rgba(156, 124, 255, .13);
  --blue: #49b7ff;
  --blue-soft: rgba(73, 183, 255, .12);
  --orange: #ffae5d;
  --orange-soft: rgba(255, 174, 93, .12);
  --red: #ff667e;
  --red-soft: rgba(255, 102, 126, .12);
  --radius: 22px;
  --shadow: 0 24px 70px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 82% -10%, rgba(80, 63, 180, .14), transparent 31rem),
    radial-gradient(circle at 15% 88%, rgba(24, 157, 151, .08), transparent 34rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

.ambient { position: fixed; z-index: -1; border-radius: 50%; filter: blur(90px); pointer-events: none; opacity: .18; }
.ambient-one { width: 350px; height: 350px; right: 8%; top: -210px; background: #624de8; }
.ambient-two { width: 280px; height: 280px; left: 9%; bottom: -180px; background: #1bb993; }

.brand { display: flex; align-items: center; gap: 13px; letter-spacing: .04em; }
.brand > span:last-child { display: flex; flex-direction: column; line-height: 1; }
.brand strong { font-size: 16px; letter-spacing: .17em; }
.brand small { margin-top: 7px; color: var(--subtle); font-size: 8px; font-weight: 700; letter-spacing: .2em; }
.brand-mark { position: relative; display: flex; width: 35px; height: 35px; align-items: center; justify-content: center; border: 1px solid rgba(156, 124, 255, .38); border-radius: 11px; background: linear-gradient(145deg, rgba(156,124,255,.19), rgba(73,183,255,.05)); box-shadow: inset 0 0 18px rgba(156,124,255,.08), 0 8px 24px rgba(5, 8, 28, .5); }
.brand-mark i { width: 3px; margin: 0 2px; border-radius: 4px; background: linear-gradient(#bca9ff, #7856ed); box-shadow: 0 0 9px rgba(156,124,255,.6); }
.brand-mark i:nth-child(1) { height: 10px; }
.brand-mark i:nth-child(2) { height: 19px; }
.brand-mark i:nth-child(3) { height: 14px; }

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 28px; }
.login-card { width: min(100%, 460px); padding: 36px; border: 1px solid var(--line-bright); border-radius: 28px; background: linear-gradient(150deg, rgba(17,31,51,.96), rgba(9,18,31,.96)); box-shadow: var(--shadow); backdrop-filter: blur(20px); }
.brand-login { margin-bottom: 62px; }
.login-copy h1 { margin: 8px 0 12px; font-size: clamp(29px, 6vw, 39px); line-height: 1.08; letter-spacing: -.04em; }
.login-copy p { margin: 0 0 34px; color: var(--muted); line-height: 1.65; font-size: 14px; }
.eyebrow { color: var(--violet); font-size: 10px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
form label { display: block; margin-bottom: 9px; color: #b8c4d7; font-size: 12px; font-weight: 650; }
.password-field { position: relative; }
.password-field input { width: 100%; height: 53px; padding: 0 52px 0 16px; border: 1px solid var(--line-bright); border-radius: 13px; outline: none; background: rgba(5, 12, 23, .74); color: var(--text); transition: border-color .2s, box-shadow .2s; }
.password-field input:focus { border-color: rgba(156,124,255,.72); box-shadow: 0 0 0 4px rgba(156,124,255,.09); }
.icon-button { position: absolute; top: 6px; right: 6px; width: 41px; height: 41px; border: 0; background: transparent; color: var(--subtle); cursor: pointer; }
.primary-button { display: flex; width: 100%; height: 53px; margin-top: 18px; padding: 0 18px; align-items: center; justify-content: space-between; border: 0; border-radius: 13px; background: linear-gradient(120deg, #7659ed, #9a70f3); box-shadow: 0 12px 30px rgba(104, 77, 223, .24); font-weight: 750; cursor: pointer; transition: transform .2s, filter .2s; }
.primary-button:hover { transform: translateY(-1px); filter: brightness(1.08); }
.primary-button:disabled { opacity: .6; cursor: wait; }
.form-error { margin: 10px 2px 0; color: #ff8397; font-size: 12px; }
.login-security { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 24px; color: var(--subtle); font-size: 10px; }
.pulse-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgba(60,230,165,.08), 0 0 12px rgba(60,230,165,.6); }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; display: flex; width: 238px; padding: 30px 20px 22px; flex-direction: column; border-right: 1px solid var(--line); background: rgba(7, 15, 27, .87); backdrop-filter: blur(24px); }
.sidebar .brand { padding: 0 9px 30px; }
.sidebar nav { display: grid; gap: 7px; margin-top: 22px; }
.nav-item { display: flex; min-height: 46px; padding: 0 13px; gap: 12px; align-items: center; border: 1px solid transparent; border-radius: 12px; color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 620; transition: background .2s, color .2s, border-color .2s; }
.nav-item:hover { color: var(--text); background: rgba(255,255,255,.025); }
.nav-item.active { color: #e7e1ff; border-color: rgba(156,124,255,.13); background: linear-gradient(90deg, rgba(156,124,255,.14), rgba(156,124,255,.03)); box-shadow: inset 3px 0 0 var(--violet); }
.nav-icon { display: grid; width: 24px; height: 24px; place-items: center; color: var(--violet); font-size: 17px; }
.nav-item b { min-width: 22px; margin-left: auto; padding: 4px 6px; border-radius: 8px; background: rgba(156,124,255,.11); color: #bba9ff; text-align: center; font-size: 10px; }
.sidebar-system { display: flex; gap: 11px; align-items: center; margin: auto 4px 14px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: rgba(16, 28, 46, .6); }
.sidebar-system div { display: flex; min-width: 0; flex-direction: column; }
.sidebar-system strong { font-size: 11px; }
.sidebar-system small { margin-top: 4px; color: var(--green); font-size: 9px; }
.system-orbit { position: relative; width: 28px; height: 28px; border: 1px solid rgba(60,230,165,.24); border-radius: 50%; }
.system-orbit::before { content: ""; position: absolute; inset: 6px; border: 1px solid rgba(60,230,165,.45); border-radius: 50%; }
.system-orbit i { position: absolute; width: 5px; height: 5px; top: -2px; left: 11px; border-radius: 50%; background: var(--green); box-shadow: 0 0 9px var(--green); }
.logout-button { display: flex; width: 100%; padding: 11px 13px; justify-content: space-between; border: 0; border-radius: 10px; background: transparent; color: var(--subtle); font-size: 11px; cursor: pointer; }
.logout-button:hover { background: var(--red-soft); color: #ff8ba0; }

.content { width: calc(100% - 238px); max-width: 1680px; margin-left: 238px; padding: 31px clamp(22px, 3.5vw, 56px) 36px; }
.topbar { display: flex; min-height: 84px; align-items: flex-start; justify-content: space-between; gap: 24px; }
.topbar h1 { margin: 5px 0 6px; font-size: 29px; letter-spacing: -.035em; }
.topbar p { margin: 0; color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; gap: 14px; align-items: center; }
.live-chip { display: flex; height: 34px; padding: 0 13px; gap: 9px; align-items: center; border: 1px solid rgba(60,230,165,.15); border-radius: 18px; background: var(--green-soft); color: #82f2c7; font-size: 9px; font-weight: 800; letter-spacing: .13em; }
.live-chip.stale { border-color: rgba(255,102,126,.16); background: var(--red-soft); color: #ff91a3; }
.live-chip.stale .pulse-dot { background: var(--red); box-shadow: 0 0 10px rgba(255,102,126,.6); }
.clock { display: flex; min-width: 83px; flex-direction: column; text-align: right; }
.clock strong { font-size: 16px; letter-spacing: .04em; }
.clock small { margin-top: 3px; color: var(--subtle); font-size: 9px; text-transform: uppercase; }
.refresh-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 11px; background: rgba(16,29,48,.7); color: var(--muted); font-size: 18px; cursor: pointer; }
.refresh-button:hover { color: var(--text); border-color: var(--line-bright); }
.refresh-button.loading span { display: inline-block; animation: spin .8s linear infinite; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 22px 0 16px; }
.kpi-card { position: relative; min-height: 164px; padding: 20px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(145deg, rgba(17,31,50,.86), rgba(11,21,36,.86)); box-shadow: 0 15px 40px rgba(0,0,0,.1); }
.kpi-card::after { content: ""; position: absolute; width: 120px; height: 120px; right: -50px; top: -70px; border-radius: 50%; filter: blur(35px); opacity: .14; background: currentColor; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 10px; font-weight: 720; letter-spacing: .08em; text-transform: uppercase; }
.kpi-icon { display: grid; width: 27px; height: 27px; place-items: center; border-radius: 9px; background: currentColor; font-style: normal; font-size: 11px; }
.kpi-card > strong { display: block; margin-top: 14px; font-size: 30px; line-height: 1; letter-spacing: -.04em; }
.kpi-card > p { margin: 8px 0 15px; color: var(--subtle); font-size: 10px; }
.accent-green { color: var(--green); } .accent-green > strong { color: var(--text); } .accent-green .kpi-icon { background: var(--green-soft); }
.accent-violet { color: var(--violet); } .accent-violet > strong { color: var(--text); } .accent-violet .kpi-icon { background: var(--violet-soft); }
.accent-blue { color: var(--blue); } .accent-blue > strong { color: var(--text); } .accent-blue .kpi-icon { background: var(--blue-soft); }
.accent-orange { color: var(--orange); } .accent-orange > strong { color: var(--text); } .accent-orange .kpi-icon { background: var(--orange-soft); }
.micro-bar, .metric-bar { height: 4px; overflow: hidden; border-radius: 4px; background: rgba(151,174,207,.1); }
.micro-bar i, .metric-bar i { display: block; width: 0; height: 100%; border-radius: inherit; background: currentColor; box-shadow: 0 0 10px currentColor; transition: width .5s ease; }
.micro-chart { display: flex; height: 18px; gap: 4px; align-items: end; }
.micro-chart i { width: 8px; border-radius: 3px; background: rgba(156,124,255,.23); }
.micro-chart i:nth-child(1) { height: 30%; }.micro-chart i:nth-child(2) { height: 55%; }.micro-chart i:nth-child(3) { height: 44%; }.micro-chart i:nth-child(4) { height: 78%; }.micro-chart i:nth-child(5) { height: 48%; }.micro-chart i:nth-child(6) { height: 90%; }.micro-chart i:nth-child(7) { height: 62%; background: var(--violet); }
.temperature-scale { position: relative; height: 4px; border-radius: 5px; background: linear-gradient(90deg, var(--green), #e6dc65 58%, var(--red)); }
.temperature-scale i { position: absolute; width: 9px; height: 9px; top: -3px; left: 0; border: 2px solid #fff; border-radius: 50%; background: var(--orange); box-shadow: 0 0 10px rgba(255,174,93,.6); transition: left .5s ease; }

.panel { margin-top: 16px; padding: 23px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: 0 16px 50px rgba(0,0,0,.1); backdrop-filter: blur(16px); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.section-heading h2 { margin: 4px 0 0; font-size: 18px; letter-spacing: -.02em; }
.filter-row { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.filter-button { padding: 7px 11px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.02); color: var(--muted); font-size: 9px; font-weight: 750; cursor: pointer; }
.filter-button.active { border-color: rgba(156,124,255,.3); background: var(--violet-soft); color: #c6b8ff; }
.farm-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.farm-card { padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: linear-gradient(145deg, rgba(17,32,52,.78), rgba(10,20,35,.8)); cursor: pointer; transition: transform .2s, border-color .2s; }
.farm-card:hover { transform: translateY(-2px); border-color: rgba(156,124,255,.3); }
.farm-card.selected { border-color: rgba(156,124,255,.44); box-shadow: inset 0 0 28px rgba(156,124,255,.05); }
.farm-card-head { display: flex; align-items: center; gap: 11px; }
.farm-symbol { display: grid; width: 34px; height: 34px; place-items: center; border: 1px solid rgba(73,183,255,.17); border-radius: 11px; background: var(--blue-soft); color: var(--blue); font-size: 12px; font-weight: 850; }
.farm-card-head div { display: flex; min-width: 0; flex-direction: column; }
.farm-card-head strong { overflow: hidden; text-overflow: ellipsis; font-size: 12px; white-space: nowrap; }
.farm-card-head small { margin-top: 4px; color: var(--green); font-size: 9px; }
.farm-arrow { margin-left: auto; color: var(--subtle); }
.farm-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px; }
.farm-stats span { display: flex; flex-direction: column; }
.farm-stats small, .worker-footer small, .worker-metrics small { color: var(--subtle); font-size: 7px; font-weight: 800; letter-spacing: .09em; }
.farm-stats b { margin-top: 4px; font-size: 12px; }

.legend { display: flex; gap: 15px; color: var(--subtle); font-size: 9px; }
.legend span { display: flex; gap: 6px; align-items: center; }
.dot { width: 6px; height: 6px; border-radius: 50%; }
.dot.online { background: var(--green); }.dot.busy { background: var(--violet); }.dot.offline { background: #536179; }
.worker-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.worker-card { position: relative; padding: 17px; border: 1px solid var(--line); border-radius: 17px; background: linear-gradient(145deg, rgba(17,32,52,.82), rgba(9,19,33,.86)); transition: border-color .2s, transform .2s; }
.worker-card:hover { transform: translateY(-2px); border-color: var(--line-bright); }
.worker-card.is-busy { border-color: rgba(156,124,255,.28); box-shadow: inset 0 0 28px rgba(156,124,255,.045); }
.worker-card.is-offline { opacity: .58; }
.worker-head { display: flex; gap: 10px; align-items: center; }
.worker-avatar { display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid rgba(73,183,255,.15); border-radius: 11px; background: var(--blue-soft); color: var(--blue); font-size: 10px; font-weight: 800; }
.worker-avatar::after { content: "π"; font-size: 17px; }
.worker-head > div { display: flex; min-width: 0; flex-direction: column; }
.worker-name { overflow: hidden; text-overflow: ellipsis; font-size: 12px; white-space: nowrap; }
.worker-farm { margin-top: 4px; color: var(--subtle); font-size: 8px; }
.status-pill { margin-left: auto; padding: 5px 8px; border-radius: 9px; background: var(--green-soft); color: var(--green); font-size: 7px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.is-busy .status-pill { background: var(--violet-soft); color: #b9a7ff; }
.is-offline .status-pill { background: rgba(93,109,134,.12); color: #75849a; }
.capabilities { display: flex; min-height: 22px; gap: 5px; margin: 13px 0; flex-wrap: wrap; }
.capability { padding: 4px 7px; border: 1px solid var(--line); border-radius: 7px; color: #889bb8; font-size: 7px; font-weight: 750; text-transform: uppercase; }
.active-task { display: flex; min-height: 48px; margin: 0 0 13px; padding: 10px 11px; gap: 10px; align-items: center; border: 1px solid rgba(156,124,255,.14); border-radius: 11px; background: var(--violet-soft); }
.active-task > div { display: flex; min-width: 0; flex-direction: column; }
.active-task small { color: #937be8; font-size: 7px; font-weight: 800; }
.active-task strong { margin-top: 3px; overflow: hidden; text-overflow: ellipsis; font-size: 9px; white-space: nowrap; }
.active-task time { margin-left: auto; color: #c2b5f8; font-size: 9px; }
.task-spinner { width: 15px; height: 15px; border: 2px solid rgba(156,124,255,.2); border-top-color: var(--violet); border-radius: 50%; animation: spin 1s linear infinite; }
.worker-metrics { display: grid; gap: 11px; }
.worker-metrics > div > span { display: flex; margin-bottom: 6px; justify-content: space-between; }
.worker-metrics b { color: #b6c2d4; font-size: 8px; }
.memory-fill { color: var(--blue); background: var(--blue) !important; }.disk-fill { color: var(--violet); background: var(--violet) !important; }
.worker-footer { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--line); }
.worker-footer span { display: flex; flex-direction: column; }
.worker-footer span:not(:first-child) { padding-left: 10px; border-left: 1px solid var(--line); }
.worker-footer b { margin-top: 4px; color: #c3cede; font-size: 10px; }
.metric-hot { color: var(--red) !important; }
.empty-state { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty-state > span { display: block; color: var(--violet); font-size: 35px; }.empty-state strong { display: block; margin-top: 10px; color: var(--text); }.empty-state p { font-size: 11px; }

.success-rate { color: var(--subtle); font-size: 9px; }.success-rate span:first-child { color: var(--green); }.success-rate span:last-child { color: var(--red); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 10px; }
th { padding: 0 12px 11px; color: var(--subtle); font-size: 7px; letter-spacing: .1em; text-align: left; text-transform: uppercase; }
td { padding: 13px 12px; border-top: 1px solid var(--line); color: #aab8cc; white-space: nowrap; }
td:first-child { color: #d9e2ef; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.task-type { display: inline-flex; padding: 5px 8px; border: 1px solid var(--line); border-radius: 7px; color: #a6b4ca; }
.result-pill { display: inline-flex; padding: 5px 8px; border-radius: 7px; font-size: 7px; font-weight: 800; text-transform: uppercase; }
.result-completed { background: var(--green-soft); color: var(--green); }.result-failed, .result-cancelled { background: var(--red-soft); color: #ff8295; }
.table-empty { padding: 34px 12px 14px; border-top: 1px solid var(--line); color: var(--subtle); text-align: center; font-size: 10px; }
footer { display: flex; padding: 24px 4px 0; justify-content: space-between; color: #53627a; font-size: 8px; letter-spacing: .04em; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .worker-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .farm-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 780px) {
  .sidebar { position: sticky; top: 0; width: 100%; height: 66px; padding: 12px 18px; flex-direction: row; align-items: center; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar .brand { padding: 0; }
  .sidebar nav, .sidebar-system { display: none; }
  .logout-button { width: auto; margin-left: auto; gap: 15px; }
  .content { width: 100%; margin-left: 0; padding: 23px 16px 30px; }
  .topbar { min-height: 104px; }
  .topbar-actions .clock { display: none; }
  .worker-grid, .farm-cards { grid-template-columns: 1fr; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .filter-row { justify-content: flex-start; }
}

@media (max-width: 520px) {
  .login-card { padding: 28px 22px; }
  .brand-login { margin-bottom: 44px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 25px; }
  .topbar p { max-width: 220px; line-height: 1.5; }
  .live-chip { display: none; }
  .panel { padding: 18px 14px; }
  .legend { gap: 8px; }
  footer { gap: 12px; flex-direction: column; }
}
