:root {
  --bg: #070b10;
  --bg-2: #0b1018;
  --card: rgba(14, 20, 30, 0.72);
  --card-solid: #101820;
  --stroke: rgba(255, 255, 255, 0.07);
  --stroke-strong: rgba(255, 255, 255, 0.12);
  --text: #e8eef5;
  --muted: #8b9bb0;
  --dim: #5c6b7c;
  --amber: #f5a623;
  --green: #3ddc84;
  --green-2: #22c55e;
  --blue: #3b9eff;
  --red: #ef4444;
  --orange: #f97316;
  --steel: #7a8ea3;
  --glow: 0 0 0 1px var(--stroke), 0 12px 40px rgba(0, 0, 0, 0.35);
  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 10% -10%, #122033 0%, var(--bg) 45%) fixed;
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0.01em;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; }

.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: linear-gradient(180deg, #0c121c 0%, #090d14 100%);
  border-right: 1px solid var(--stroke);
  padding: 18px 12px 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar.collapsed { display: none; }
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px 18px;
}
.brand-mark {
  width: 36px; height: 36px; border-radius: 8px;
  background: linear-gradient(135deg, #1b2a3c, #0e1622);
  border: 1px solid var(--stroke-strong);
  display: grid; place-items: center;
  font-weight: 700; font-size: 18px; color: var(--text);
  box-shadow: inset 0 0 12px rgba(59, 158, 255, 0.15);
}
.brand-text { line-height: 1.1; }
.brand-text strong { display: block; font-size: 13px; letter-spacing: 0.16em; font-weight: 600; }
.brand-text span { font-size: 9px; color: var(--muted); letter-spacing: 0.18em; text-transform: uppercase; }

.nav-link, .nav-parent {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  color: var(--muted); font-size: 13px; font-weight: 500;
}
.nav-link i, .nav-parent i { width: 16px; text-align: center; font-size: 12px; }
.nav-link:hover, .nav-parent:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.nav-link.active { background: rgba(59, 158, 255, 0.12); color: var(--text); box-shadow: inset 3px 0 0 var(--blue); }
.nav-sub { padding-left: 28px; display: none; }
.nav-group.open .nav-sub { display: block; }
.nav-sub a { display: block; padding: 6px 8px; color: var(--dim); border-radius: 6px; font-size: 12px; }
.nav-sub a.active, .nav-sub a:hover { color: var(--text); background: rgba(255,255,255,0.04); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--stroke);
  background: rgba(8, 12, 18, 0.85);
  backdrop-filter: blur(16px);
  position: sticky; top: 0; z-index: 20;
}
.icon-btn {
  width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,0.03);
  color: var(--text); display: grid; place-items: center; cursor: pointer;
}
.crumb { color: var(--muted); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.spacer { flex: 1; }
.user-chip { color: var(--muted); font-size: 12px; }
.user-chip strong { color: var(--text); font-weight: 500; }
.role-pill {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em;
  border: 1px solid var(--stroke); padding: 3px 8px; border-radius: 999px; color: var(--amber);
}

.content { padding: 18px; }
.page-title { font-size: 22px; font-weight: 600; margin: 0 0 14px; letter-spacing: 0.02em; }

.glass {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: 14px;
  box-shadow: var(--glow);
  backdrop-filter: blur(18px) saturate(140%);
}

.kpi-row { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.kpi {
  padding: 14px 16px 10px;
  min-height: 148px;
  display: flex; flex-direction: column;
}
.kpi h3, .panel h3, .section-label {
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.kpi .sub { font-size: 10px; color: var(--dim); letter-spacing: 0.08em; margin-top: 2px; text-transform: uppercase; }
.kpi .value {
  font-family: var(--mono);
  font-size: 34px;
  font-weight: 600;
  line-height: 1;
  margin: 10px 0 6px;
}
.kpi .delta { font-size: 11px; font-weight: 500; }
.up { color: var(--green); }
.down { color: var(--orange); }
.warn { color: var(--amber); }
.bad { color: var(--red); }

.grid-2 { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 12px; margin-top: 12px; }
.grid-3 { display: grid; grid-template-columns: 1.1fr 0.7fr 0.7fr; gap: 12px; margin-top: 12px; }
.panel { padding: 14px 16px; }
.panel-h {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px;
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 8px var(--green); display: inline-block; margin-right: 6px;
}
.live-dot.alert { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.live-dot.off { background: var(--red); box-shadow: 0 0 8px var(--red); }

.machines {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px;
}
.machine {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 10px;
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 10px;
  align-items: center;
}
.machine img {
  width: 72px; height: 64px; object-fit: contain; filter: drop-shadow(0 8px 12px rgba(0,0,0,0.45));
}
.machine .m-name { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; }
.machine .m-type { font-size: 10px; color: var(--dim); letter-spacing: 0.08em; text-transform: uppercase; }
.machine .m-job { font-size: 10px; color: var(--muted); margin-top: 2px; }
.st-running { color: var(--green); }
.st-alert { color: var(--amber); }
.st-offline { color: var(--red); }
.oee-mini { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 4px; }

.gantt { overflow: hidden; }
.gantt-head, .gantt-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  align-items: center;
}
.gantt-days { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; color: var(--dim); font-size: 10px; letter-spacing: 0.12em; }
.gantt-track { position: relative; height: 28px; background: linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px) 0 0 / calc(100%/7) 100%; margin: 6px 0; }
.gantt-bar {
  position: absolute; top: 6px; height: 16px; border-radius: 4px;
}
.bar-blue { background: #2f6fb5; }
.bar-green { background: #2ea56a; }
.bar-amber { background: #c48a1e; border: 1px dashed rgba(255,255,255,0.25); background: repeating-linear-gradient(90deg, #c48a1e, #c48a1e 6px, #8a6418 6px, #8a6418 10px); }
.now-line {
  position: absolute; top: 0; bottom: 0; width: 2px; background: var(--amber);
  box-shadow: 0 0 8px var(--amber);
}
.now-label { position: absolute; top: -14px; transform: translateX(-50%); font-size: 9px; color: var(--amber); letter-spacing: 0.14em; }

.donut-wrap { display: flex; gap: 16px; align-items: center; }
.legend { list-style: none; padding: 0; margin: 0; font-size: 11px; color: var(--muted); }
.legend li { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.sw { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 8px; }

.big-ring { position: relative; width: 110px; height: 110px; }
.big-ring svg { transform: rotate(-90deg); }
.ring-label { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ring-label b { font-family: var(--mono); font-size: 22px; display: block; }

.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 90px 1fr 70px; gap: 8px; align-items: center; font-size: 11px; color: var(--muted); }
.bar-track { height: 8px; background: rgba(255,255,255,0.05); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; }
.mono { font-family: var(--mono); }

.hero-photo {
  position: relative; overflow: hidden; min-height: 150px; border-radius: 12px;
}
.hero-photo img { width: 100%; height: 100%; object-fit: cover; display: block; min-height: 150px; opacity: 0.85; }
.hero-photo .overlay {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(7,11,16,0.2), rgba(7,11,16,0.55));
  padding: 16px;
  display: flex; flex-direction: column; justify-content: flex-end;
}
.hero-photo h4 { margin: 0 0 6px; font-size: 16px; letter-spacing: 0.08em; }
.hero-photo p { margin: 0; color: var(--muted); font-size: 11px; letter-spacing: 0.12em; }

.spec { font-size: 11px; color: var(--muted); line-height: 1.55; }
.spec b { color: var(--text); font-weight: 500; display: inline-block; min-width: 92px; }
.spec hr { border: 0; border-top: 1px solid var(--stroke); margin: 8px 0; }

.dash-header {
  display: flex; align-items: center; gap: 18px; padding: 8px 18px 0;
}
.dash-header .sep { width: 1px; height: 28px; background: var(--stroke-strong); }
.status-run { color: var(--green); font-weight: 600; letter-spacing: 0.16em; font-size: 12px; }
.shift-select {
  background: transparent; color: var(--text); border: 1px solid var(--stroke);
  border-radius: 8px; padding: 6px 10px; font-size: 12px;
}

table.data {
  width: 100%; border-collapse: collapse; font-size: 12px;
}
table.data th {
  text-align: left; font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--stroke);
  white-space: nowrap;
}
table.data td {
  padding: 9px 10px; border-bottom: 1px solid var(--stroke); color: var(--text); white-space: nowrap;
}
table.data tbody tr:hover { background: rgba(255,255,255,0.03); }
table.data a { color: var(--blue); }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.search {
  background: rgba(255,255,255,0.03); border: 1px solid var(--stroke); color: var(--text);
  border-radius: 8px; padding: 8px 12px; min-width: 220px;
}
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border-radius: 8px; padding: 8px 12px; border: 1px solid var(--stroke);
  background: rgba(255,255,255,0.04); color: var(--text); cursor: pointer; font-size: 12px; font-weight: 500;
}
.btn-primary { background: linear-gradient(180deg, #2a6fbf, #1d4f8a); border-color: #3b9eff55; }
.btn-danger { background: #5a1d1d; border-color: #ef444455; }
.btn-ghost { background: transparent; }

.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.span-4 { grid-column: span 4; }
.field.span-2 { grid-column: span 2; }
.field label { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea {
  background: rgba(0,0,0,0.25); border: 1px solid var(--stroke); color: var(--text);
  border-radius: 8px; padding: 8px 10px;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: #3b9eff88; box-shadow: 0 0 0 3px #3b9eff22;
}
.readonly { color: var(--text); padding: 8px 0; min-height: 20px; }

.sticky-actions {
  position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px; margin-top: 16px;
}

.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(800px 400px at 50% 0%, #16324c, var(--bg));
}
.login-card { width: min(420px, 100%); padding: 28px; }
.login-card h1 { margin: 8px 0 4px; letter-spacing: 0.18em; font-size: 18px; }
.login-card p { color: var(--muted); margin: 0 0 18px; }
.error { color: var(--red); font-size: 12px; margin-bottom: 10px; }

.pager { display: flex; gap: 6px; align-items: center; justify-content: flex-end; margin-top: 12px; color: var(--muted); }
.pager a, .pager span { padding: 6px 8px; border-radius: 6px; border: 1px solid var(--stroke); }

.cards-home { display: flex; flex-wrap: wrap; gap: 22px; }
.home-card {
  width: 160px; height: 160px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px; text-align: center;
  font-size: 14px; font-weight: 500;
}
.home-card i { font-size: 36px; color: var(--blue); }
.home-card:hover { border-color: var(--blue); }

.notif { position: relative; }
.badge {
  position: absolute; top: -4px; right: -4px; background: var(--red); color: white;
  font-size: 9px; min-width: 16px; height: 16px; border-radius: 99px; display: grid; place-items: center;
  font-family: var(--mono);
}

@media (max-width: 1200px) {
  .kpi-row { grid-template-columns: repeat(3, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .machines { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .field.span-4 { grid-column: span 2; }
}
@media (max-width: 768px) {
  .sidebar { display: none; }
  .kpi-row, .machines { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .field.span-4, .field.span-2 { grid-column: span 1; }
  .dash-header { flex-wrap: wrap; }
}
