/* ============ RESET & BASE ============ */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 13px;
  color: #0a3d3f;
  background: #f0f4f5;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
small { font-size: 0.55em; font-weight: 500; opacity: 0.7; margin-left: 2px; }

:root {
  --teal-900: #0a3d3f;
  --teal-800: #0d5d60;
  --teal-700: #0d7d80;
  --teal-500: #14a3a6;
  --teal-100: #d6ebec;
  --teal-50: #eaf4f5;
  --gray-50: #f8fafa;
  --gray-100: #f1f5f5;
  --gray-200: #e3e8e8;
  --gray-300: #c8d0d0;
  --gray-500: #6b7676;
  --gray-700: #3d4848;
  --gray-900: #0a1a1a;
  --green: #10b981;
  --green-bg: #d1fae5;
  --amber: #f59e0b;
  --amber-bg: #fef3c7;
  --red: #ef4444;
  --red-bg: #fee2e2;
  --purple: #7c3aed;
  --shadow-sm: 0 1px 2px rgba(10, 61, 63, 0.04), 0 1px 3px rgba(10, 61, 63, 0.06);
  --shadow-md: 0 4px 12px rgba(10, 61, 63, 0.06);
}

/* ============ TOPBAR ============ */
.topbar {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 12px 24px;
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 38px; height: 38px;
  background: var(--teal-50);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.brand-mark svg { width: 28px; height: 28px; }
.brand-name {
  font-size: 16px; font-weight: 800; letter-spacing: -0.02em;
  color: var(--teal-900);
}
.brand-tag { font-size: 11px; color: var(--gray-500); font-family: 'JetBrains Mono', monospace; }

.topbar-stats { display: flex; gap: 24px; padding-left: 16px; border-left: 1px solid var(--gray-200); }
.ts-item { text-align: left; }
.ts-lbl { font-size: 10px; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.ts-val { font-size: 16px; font-weight: 700; color: var(--teal-900); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.live-time {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: var(--gray-50);
  border-radius: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--teal-900);
}
.live-dot {
  width: 7px; height: 7px;
  background: var(--green);
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulse-dot 2s infinite;
}
.live-date { color: var(--gray-500); padding-left: 8px; border-left: 1px solid var(--gray-300); font-weight: 500; }
@keyframes pulse-dot {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}
.bell-btn {
  position: relative;
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--gray-50);
  color: var(--teal-900);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.bell-btn:hover { background: var(--teal-50); }
.bell-btn svg { width: 18px; height: 18px; }
.bell-badge {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
}
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 12px 4px 4px;
  background: var(--gray-50);
  border-radius: 999px;
}
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--teal-700), var(--teal-500));
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  display: flex; align-items: center; justify-content: center;
}
.u-name { font-size: 13px; font-weight: 600; color: var(--teal-900); line-height: 1.2; }
.u-role { font-size: 11px; color: var(--gray-500); line-height: 1.2; }

/* ============ KPI STRIP ============ */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  padding: 16px 24px;
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
}
.kpi {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 14px 16px;
  transition: all 0.15s;
}
.kpi:hover { background: #fff; box-shadow: var(--shadow-sm); }
.kpi-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.kpi-lbl { font-size: 11px; color: var(--gray-500); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-trend {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}
.kpi-trend.up { background: var(--green-bg); color: #047857; }
.kpi-trend.down { background: var(--amber-bg); color: #b45309; }
.kpi-val {
  font-size: 26px;
  font-weight: 800;
  color: var(--teal-900);
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: 4px;
}
.kpi-foot {
  font-size: 11px;
  color: var(--gray-500);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.bar-mini {
  flex: 1;
  height: 4px;
  background: var(--gray-200);
  border-radius: 999px;
  overflow: hidden;
  max-width: 80px;
}
.bar-fill { height: 100%; border-radius: 999px; transition: width 0.6s; }

/* ============ DASHBOARD GRID ============ */
.dash {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 16px;
  padding: 16px 24px 32px;
  align-items: start;
}
.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  overflow: hidden;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--gray-100);
}
.card-head h2 {
  font-size: 14px;
  font-weight: 700;
  color: var(--teal-900);
  letter-spacing: -0.01em;
}
.card-sub { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.legend { display: flex; gap: 6px; flex-wrap: wrap; }
.lg {
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  position: relative;
  padding-left: 16px;
}
.lg::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px; height: 6px;
  border-radius: 50%;
}
.lg-ok { background: var(--green-bg); color: #047857; }
.lg-ok::before { background: var(--green); }
.lg-warn { background: var(--amber-bg); color: #b45309; }
.lg-warn::before { background: var(--amber); }
.lg-bad { background: var(--red-bg); color: #b91c1c; }
.lg-bad::before { background: var(--red); }
.lg-idle { background: var(--gray-100); color: var(--gray-700); }
.lg-idle::before { background: var(--gray-300); }

.link-btn {
  font-size: 12px;
  color: var(--teal-700);
  font-weight: 600;
}
.link-btn:hover { text-decoration: underline; }

.chart-toggles, .filter-pills { display: flex; gap: 4px; }
.chip {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--gray-100);
  color: var(--gray-700);
}
.chip.active { background: var(--teal-700); color: #fff; }
.chip:hover:not(.active) { background: var(--gray-200); }

/* ============ FLOOR MAP ============ */
.floor-map {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 16px 20px 20px;
}
.zone {
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 12px 14px;
  background: #fff;
  position: relative;
  overflow: hidden;
  transition: all 0.15s;
}
.zone:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.zone.z-ok { background: #f4fbf8; }
.zone.z-warn { background: #fffaf0; }
.zone.z-bad { background: #fef5f4; }
.zone-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.zone-icon { font-size: 16px; color: var(--teal-700); }
.zone-name { font-size: 13px; font-weight: 700; color: var(--teal-900); flex: 1; }
.zone-pct { font-size: 18px; font-weight: 800; color: var(--teal-900); letter-spacing: -0.02em; }
.zone-body { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.zone-row { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--gray-500); }
.zone-row b { color: var(--gray-900); font-weight: 600; font-variant-numeric: tabular-nums; }
.zone-row b.red { color: var(--red); }
.zone-bar { height: 4px; background: var(--gray-100); border-radius: 999px; overflow: hidden; }
.zone-bar div { height: 100%; border-radius: 999px; }

/* ============ LOOM SHEDS ============ */
.loom-stats {
  display: flex; gap: 12px;
  font-size: 12px; color: var(--gray-500);
}
.loom-stats span { font-variant-numeric: tabular-nums; }
.loom-stats b { color: var(--teal-900); font-weight: 700; margin-right: 2px; }
.loom-stats .warn b { color: var(--amber); }
.loom-stats .bad b { color: var(--red); }
.loom-stats .idle b { color: var(--gray-700); }

.loom-sheds {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 16px 20px 20px;
}
.shed {
  background: var(--gray-50);
  border-radius: 8px;
  padding: 10px 12px;
}
.shed-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--gray-700);
  margin-bottom: 6px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  display: flex;
  justify-content: space-between;
}
.shed-count { color: var(--gray-500); font-weight: 500; text-transform: none; letter-spacing: 0; }
.loom-grid {
  display: grid;
  grid-template-columns: repeat(20, 1fr);
  gap: 2px;
}
.loom {
  aspect-ratio: 1;
  border-radius: 2px;
  background: var(--green);
  cursor: pointer;
  transition: transform 0.1s;
}
.loom:hover { transform: scale(1.4); z-index: 5; outline: 1px solid #fff; outline-offset: 1px; }
.loom.warn { background: var(--amber); }
.loom.bad { background: var(--red); }
.loom.idle { background: var(--gray-300); }

/* ============ TREND CHART ============ */
.trend-wrap { padding: 12px 20px 20px; }
.trend-chart { width: 100%; height: 240px; display: block; }
.trend-axis {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--gray-500);
  font-family: 'JetBrains Mono', monospace;
  padding-top: 6px;
  border-top: 1px dashed var(--gray-200);
}

/* ============ ALERTS ============ */
.alerts { padding: 8px 8px 12px; display: flex; flex-direction: column; gap: 4px; }
.alert {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  transition: background 0.15s;
}
.alert:hover { background: var(--gray-50); }
.a-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  font-weight: 700;
}
.a-bad .a-icon { background: var(--red-bg); color: var(--red); }
.a-warn .a-icon { background: var(--amber-bg); color: var(--amber); }
.a-info .a-icon { background: var(--teal-50); color: var(--teal-700); }
.a-body { flex: 1; min-width: 0; }
.a-title { font-size: 13px; font-weight: 600; color: var(--gray-900); margin-bottom: 2px; }
.a-meta { font-size: 11.5px; color: var(--gray-500); margin-bottom: 4px; }
.a-action { font-size: 11.5px; color: var(--teal-700); font-weight: 500; }
.a-bad .a-action { color: var(--red); }
.a-warn .a-action { color: #b45309; }

/* ============ ORDERS ============ */
.orders { padding: 8px 8px 14px; display: flex; flex-direction: column; gap: 2px; }
.order {
  padding: 12px 14px;
  border-radius: 8px;
  transition: background 0.15s;
  cursor: pointer;
}
.order:hover { background: var(--gray-50); }
.order-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.order-po { font-size: 12px; font-weight: 700; color: var(--gray-900); font-family: 'JetBrains Mono', monospace; }
.order-cust { font-size: 11.5px; color: var(--gray-500); margin-top: 2px; }
.status {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.s-ok { background: var(--green-bg); color: #047857; }
.s-warn { background: var(--amber-bg); color: #b45309; }
.s-bad { background: var(--red-bg); color: #b91c1c; }

.order-stages {
  display: flex;
  gap: 4px;
  margin-bottom: 6px;
}
.stg {
  flex: 1;
  font-size: 10px;
  font-weight: 600;
  text-align: center;
  padding: 3px 4px;
  border-radius: 4px;
  background: var(--gray-100);
  color: var(--gray-500);
}
.stg.done { background: var(--teal-50); color: var(--teal-700); }
.stg.active { background: var(--teal-700); color: #fff; box-shadow: 0 0 0 2px rgba(13, 125, 128, 0.2); }
.order-foot { display: flex; justify-content: space-between; font-size: 11px; color: var(--gray-500); margin-bottom: 6px; }
.order-foot .due { font-weight: 600; color: var(--teal-900); font-variant-numeric: tabular-nums; }
.order .bar-mini { max-width: 100%; }

/* ============ QUALITY DONUT ============ */
.quality-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  padding: 16px 20px 20px;
  align-items: center;
}
.donut-wrap { width: 130px; height: 130px; }
.donut { width: 100%; height: 100%; }
.quality-legend { display: flex; flex-direction: column; gap: 8px; }
.ql-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--gray-700);
}
.ql-row .dot { width: 8px; height: 8px; border-radius: 2px; }
.ql-row b { color: var(--teal-900); font-weight: 700; font-variant-numeric: tabular-nums; }
