:root {
  color-scheme: dark;
  font-family: "Segoe UI", Arial, sans-serif;
  --bg: #0d1216;
  --panel: #141b21;
  --panel-2: #1a2229;
  --line: #2c3740;
  --line-soft: #202a31;
  --text: #f4f6f7;
  --muted: #9aa7b0;
  --gold: #f3b632;
  --gold-soft: #3b321f;
  --cyan: #39b9e6;
  --green: #43c878;
  --red: #ef5358;
  --orange: #f39b38;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; overflow-x: hidden; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; letter-spacing: 0; }
button, a, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 1.15fr) minmax(360px, .85fr); }
.login-brand { min-width: 0; padding: clamp(32px, 6vw, 90px); display: flex; flex-direction: column; justify-content: center; overflow: hidden; background: #111920; border-right: 1px solid var(--line); }
.login-brand img { width: min(600px, 90%); max-width: 100%; height: auto; }
.login-brand span { margin: 24px 0 0 8px; color: var(--gold); font-size: 18px; font-weight: 700; text-transform: uppercase; }
.login-form { min-width: 0; width: min(430px, calc(100% - 40px)); margin: auto; display: grid; gap: 10px; }
.login-form h1 { margin: 2px 0 8px; font-size: 34px; }
.login-form label { margin-top: 10px; color: #cbd2d7; font-size: 13px; font-weight: 700; }
.eyebrow { margin: 0; color: var(--gold); font-size: 12px; font-weight: 800; text-transform: uppercase; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; z-index: 30; display: flex; flex-direction: column; background: #10171c; border-right: 1px solid var(--line); }
.brand-row { height: 94px; padding: 18px; display: flex; align-items: center; border-bottom: 1px solid var(--line-soft); }
.brand-row img { width: 100%; max-width: 198px; height: auto; }
.main-nav { padding: 16px 10px; display: grid; gap: 5px; }
.main-nav a { min-height: 46px; padding: 0 14px; display: flex; align-items: center; gap: 12px; color: #c5cdd2; border-left: 3px solid transparent; text-decoration: none; font-size: 14px; font-weight: 650; }
.main-nav a:hover { color: #fff; background: #182127; }
.main-nav a.active { color: var(--gold); background: var(--gold-soft); border-left-color: var(--gold); }
.nav-icon { width: 20px; text-align: center; font-size: 20px; line-height: 1; }
.sidebar-footer { margin-top: auto; min-height: 78px; padding: 13px 14px; display: grid; grid-template-columns: 38px 1fr 38px; gap: 9px; align-items: center; border-top: 1px solid var(--line); }
.user-mark { width: 36px; height: 36px; display: grid; place-items: center; color: #17130a; background: var(--gold); border-radius: 50%; font-weight: 900; }
.user-copy { min-width: 0; }
.user-copy strong, .user-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-copy strong { font-size: 13px; }
.user-copy span { margin-top: 2px; color: var(--muted); font-size: 11px; }

.workspace { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; min-height: 76px; padding: 10px 24px; display: flex; align-items: center; gap: 16px; background: rgba(13, 18, 22, .96); border-bottom: 1px solid var(--line); }
.topbar-title { min-width: 0; margin-right: auto; }
.topbar-title h1 { margin: 1px 0 0; font-size: 23px; line-height: 1.2; }
.breadcrumb { min-height: 14px; margin: 0; color: var(--gold); font-size: 11px; font-weight: 700; }
.topbar-actions { display: flex; gap: 9px; align-items: center; }
.global-search { width: min(310px, 28vw); height: 42px; padding: 0 11px; display: flex; align-items: center; gap: 8px; background: #151c22; border: 1px solid var(--line); border-radius: 6px; }
.global-search input { min-width: 0; width: 100%; padding: 0; border: 0; background: transparent; outline: 0; color: #fff; }
.content { width: min(1500px, 100%); margin: 0 auto; padding: 24px; outline: none; }

input, select { min-height: 42px; padding: 0 11px; color: #fff; background: var(--panel-2); border: 1px solid #42505a; border-radius: 6px; outline: 0; }
input:focus, select:focus { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(243,182,50,.12); }
.button { min-height: 40px; padding: 0 14px; color: #fff; background: #28343c; border: 1px solid #4b5a64; border-radius: 6px; font-weight: 700; }
.button:hover, .icon-button:hover { filter: brightness(1.15); }
.button.primary { color: #17130a; background: var(--gold); border-color: #ffd36d; }
.button.danger { background: #8d292e; border-color: #d9545a; }
.button.success { background: #17643c; border-color: #3aad6d; }
.button.full { width: 100%; margin-top: 10px; }
.button.small { min-height: 34px; padding: 0 10px; font-size: 12px; }
.icon-button { width: 40px; height: 40px; padding: 0; display: grid; place-items: center; color: #dce2e6; background: #202a31; border: 1px solid #3b4851; border-radius: 6px; font-size: 20px; }

.page-heading { margin-bottom: 20px; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-heading h2 { margin: 0; font-size: 19px; }
.page-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters input { min-width: 220px; }

.metrics { margin-bottom: 24px; display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); border: 1px solid var(--line); background: var(--panel); }
.metric { min-height: 104px; padding: 19px 21px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric span { display: block; color: var(--muted); font-size: 12px; font-weight: 650; }
.metric strong { display: block; margin-top: 8px; font-size: 28px; }
.metric.cyan strong { color: var(--cyan); }
.metric.green strong { color: var(--green); }
.metric.orange strong { color: var(--orange); }
.metric.red strong { color: var(--red); }

.overview-grid { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 24px; }
.section { min-width: 0; }
.section-title { min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.section-title h2, .section-title h3 { margin: 0; font-size: 15px; }
.section-title a { color: var(--gold); font-size: 12px; font-weight: 700; text-decoration: none; }

.data-table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); }
.data-table th { height: 42px; padding: 0 13px; color: var(--muted); background: #182027; border-bottom: 1px solid var(--line); text-align: left; font-size: 11px; text-transform: uppercase; }
.data-table td { min-height: 58px; padding: 12px 13px; border-bottom: 1px solid var(--line-soft); font-size: 13px; vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr[data-machine] { cursor: pointer; }
.data-table tbody tr[data-machine]:hover { background: #192229; }
.machine-name strong, .machine-name span { display: block; }
.machine-name span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.status { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status.online { color: var(--green); }
.status.online::before { background: var(--green); }
.status.offline { color: var(--red); }
.status.offline::before { background: var(--red); }
.status.warning { color: var(--orange); }
.status.warning::before { background: var(--orange); }
.money { color: var(--cyan); font-weight: 800; }
.row-actions { display: flex; justify-content: flex-end; gap: 6px; }
.chevron { color: var(--gold); font-size: 22px; }

.activity-list { display: grid; }
.activity-item { padding: 15px 0; display: grid; grid-template-columns: 10px 1fr; gap: 10px; border-bottom: 1px solid var(--line-soft); }
.activity-dot { width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; background: var(--cyan); }
.activity-dot.online { background: var(--green); }
.activity-dot.offline { background: var(--red); }
.activity-item strong, .activity-item span { display: block; }
.activity-item strong { font-size: 12px; }
.activity-item span { margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.45; }

.machine-header { margin-bottom: 0; padding: 0 0 20px; display: grid; grid-template-columns: minmax(260px, 1.3fr) repeat(3, minmax(120px, .7fr)) auto; gap: 18px; align-items: center; border-bottom: 1px solid var(--line); }
.machine-title h2 { margin: 0 0 6px; font-size: 24px; }
.machine-title span { font-size: 12px; }
.machine-fact { min-height: 48px; padding-left: 16px; border-left: 1px solid var(--line); }
.machine-fact span, .machine-fact strong { display: block; }
.machine-fact span { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.machine-fact strong { margin-top: 7px; font-size: 13px; }
.machine-actions { display: flex; gap: 7px; justify-content: flex-end; }
.tabs { margin-bottom: 22px; display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tab { min-height: 48px; padding: 0 18px; color: var(--muted); background: transparent; border: 0; border-bottom: 3px solid transparent; white-space: nowrap; }
.tab.active { color: #fff; border-bottom-color: var(--gold); }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.detail-grid .wide { grid-column: 1 / -1; }
.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--line); }
.info-cell { min-height: 88px; padding: 17px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.info-cell:nth-child(2n) { border-right: 0; }
.info-cell:nth-last-child(-n+2) { border-bottom: 0; }
.info-cell span, .info-cell strong { display: block; }
.info-cell span { color: var(--muted); font-size: 11px; }
.info-cell strong { margin-top: 8px; font-size: 20px; }
.queue-list, .disk-list { border: 1px solid var(--line); background: var(--panel); }
.queue-row, .disk-row { min-height: 52px; padding: 11px 13px; display: grid; align-items: center; gap: 12px; border-bottom: 1px solid var(--line-soft); }
.queue-row:last-child, .disk-row:last-child { border-bottom: 0; }
.queue-row { grid-template-columns: 28px 1fr; }
.disk-row { grid-template-columns: minmax(130px, 1fr) 90px 80px minmax(160px, 1fr); }
.disk-row span { color: var(--muted); font-size: 11px; }
.disk-row strong { font-size: 12px; }
.health-ok { color: var(--green) !important; }
.health-error { color: var(--red) !important; }
.temperature-chart { min-height: 190px; padding: 18px 12px 8px; display: flex; align-items: end; gap: 12px; border: 1px solid var(--line); background: var(--panel); }
.temp-column { min-width: 36px; flex: 1; display: grid; grid-template-rows: 1fr 20px; align-items: end; gap: 7px; text-align: center; }
.temp-bar { width: min(42px, 70%); min-height: 4px; margin: auto; background: var(--gold); border-radius: 3px 3px 0 0; }
.temp-column span { color: var(--muted); font-size: 10px; }
.empty { padding: 34px 18px; color: var(--muted); text-align: center; border: 1px dashed #394650; }
.muted { color: var(--muted); }

.operator-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 24px; }
.operator-row.selected { background: var(--gold-soft); box-shadow: inset 3px 0 var(--gold); }
.operator-panel { padding-left: 22px; border-left: 1px solid var(--line); }
.operator-panel h2 { margin: 0 0 2px; font-size: 20px; }
.operator-panel > span { color: var(--muted); font-size: 12px; }
.panel-block { margin-top: 24px; }
.panel-block h3 { margin: 0 0 10px; color: var(--gold); font-size: 12px; text-transform: uppercase; }
.panel-list { display: grid; }
.panel-list div { min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line-soft); font-size: 12px; }
.panel-actions { display: grid; gap: 8px; }
.password-display { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; padding: 18px; display: grid; place-items: center; background: rgba(0,0,0,.72); }
.modal { width: min(480px, 100%); padding: 22px; background: #151d23; border: 1px solid #44515a; border-radius: 6px; box-shadow: 0 18px 70px rgba(0,0,0,.55); }
.modal h2 { margin: 0; font-size: 20px; }
.modal p { color: var(--muted); font-size: 13px; }
.modal-form { display: grid; gap: 9px; }
.modal-form label { margin-top: 7px; color: #d6dce0; font-size: 12px; font-weight: 700; }
.modal-actions { margin-top: 16px; display: flex; justify-content: flex-end; gap: 8px; }
.message { padding: 10px 12px; border: 1px solid #51462b; color: #ffd36f; background: #292416; font-size: 12px; }
.message.error { color: #ff9a9e; background: #291619; border-color: #67353a; }
.toast { position: fixed; z-index: 120; right: 22px; bottom: 22px; max-width: min(420px, calc(100% - 44px)); padding: 13px 16px; color: #fff; background: #17643c; border: 1px solid #48bd7a; border-radius: 6px; box-shadow: 0 14px 40px rgba(0,0,0,.4); font-size: 13px; }
.toast.error { background: #7c272c; border-color: #e05b61; }
.mobile-only { display: none; }

@media (max-width: 1100px) {
  .overview-grid, .operator-layout { grid-template-columns: 1fr; }
  .operator-panel { padding: 20px 0 0; border: 0; border-top: 1px solid var(--line); }
  .machine-header { grid-template-columns: 1fr 1fr 1fr; }
  .machine-title { grid-column: 1 / -1; }
  .machine-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .hide-tablet { display: none; }
}

@media (max-width: 760px) {
  .mobile-only { display: grid; }
  .login-shell { max-width: 100vw; grid-template-columns: minmax(0, 1fr); overflow-x: hidden; }
  .login-brand { min-height: 210px; padding: 32px 26px; border: 0; border-bottom: 1px solid var(--line); }
  .login-brand img { width: min(400px, calc(100vw - 40px)); max-width: calc(100vw - 40px); }
  .login-brand span { margin-top: 12px; font-size: 13px; }
  .login-form { width: calc(100vw - 40px); max-width: calc(100vw - 40px); padding: 32px 0 48px; }
  .login-form .muted { max-width: calc(100vw - 40px); overflow-wrap: anywhere; }
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; width: min(280px, 86vw); transform: translateX(-105%); transition: transform .2s ease; box-shadow: 12px 0 40px rgba(0,0,0,.5); }
  .sidebar.open { transform: translateX(0); }
  .brand-row { justify-content: space-between; }
  .brand-row img { width: 180px; }
  .menu-backdrop { position: fixed; inset: 0; z-index: 25; display: block; background: rgba(0,0,0,.62); }
  .topbar { min-height: 66px; padding: 8px 12px; }
  .topbar-title h1 { font-size: 18px; }
  .global-search { display: none; }
  .content { padding: 16px 12px 28px; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; }
  .filters input { min-width: 0; grid-column: 1 / -1; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric { min-height: 86px; padding: 14px; border-bottom: 1px solid var(--line); }
  .metric:nth-child(2n) { border-right: 0; }
  .metric:nth-last-child(-n+2) { border-bottom: 0; }
  .metric strong { font-size: 22px; }
  .table-scroll { overflow-x: auto; border: 1px solid var(--line); }
  .table-scroll .data-table { min-width: 720px; border: 0; }
  .machine-header { grid-template-columns: 1fr 1fr; gap: 13px; }
  .machine-fact { padding-left: 10px; }
  .machine-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .machine-actions .button { padding: 0 8px; }
  .tabs { margin-left: -12px; margin-right: -12px; padding-left: 8px; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-grid .wide { grid-column: auto; }
  .disk-row { grid-template-columns: 1fr 80px; }
  .disk-row span:nth-last-child(-n+2) { display: none; }
  .operator-layout .data-table { min-width: 620px; }
}

@media (max-width: 430px) {
  .metrics { grid-template-columns: 1fr; }
  .metric { border-right: 0; border-bottom: 1px solid var(--line) !important; }
  .metric:last-child { border-bottom: 0 !important; }
  .filters { grid-template-columns: 1fr; }
  .filters input { grid-column: auto; }
  .info-grid { grid-template-columns: 1fr; }
  .info-cell { border-right: 0; border-bottom: 1px solid var(--line) !important; }
  .info-cell:last-child { border-bottom: 0 !important; }
}
