:root {
  --bg: #eef1f4;
  --bg-tint: #e8edf1;
  --surface: #ffffff;
  --sidebar: #15202b;
  --sidebar-2: #1b2836;
  --sidebar-text: #c5d0da;
  --sidebar-muted: #8b9aab;
  --accent: #0f7a72;
  --accent-2: #128c83;
  --accent-soft: #dff3f0;
  --accent-ink: #0b5c56;
  --text: #15202b;
  --text-2: #5b6b7a;
  --text-3: #8493a1;
  --line: #e3e8ee;
  --line-2: #d3dbe3;
  --danger: #d11f4b;
  --danger-soft: #fde8ee;
  --warning: #c47a00;
  --warning-soft: #fff3dc;
  --success: #0f8a5a;
  --success-soft: #e3f6ec;
  --info: #1b6ec2;
  --info-soft: #e6f1fb;
  --purple: #6d4ec9;
  --purple-soft: #efeafb;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(21, 32, 43, 0.05), 0 10px 28px rgba(21, 32, 43, 0.06);
  --shadow-lg: 0 16px 48px rgba(21, 32, 43, 0.16);
  --font: "Noto Sans SC", "IBM Plex Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "IBM Plex Sans", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --sidebar-w: 240px;
  --topbar-h: 76px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font-family: inherit; }

/* author display rules must not override the hidden attribute */
[hidden] { display: none !important; }

button { cursor: pointer; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.02em; }

.app { display: flex; min-height: 100vh; position: relative; z-index: 1; }

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--sidebar) 0%, #101820 100%);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 22px 18px 18px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand-mark {
  width: 40px; height: 40px;
  border-radius: 11px;
  background: linear-gradient(145deg, #1aa89c, #0d6b64);
  color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 6px 16px rgba(15, 122, 114, .35);
  flex-shrink: 0;
}
.brand-mark svg { width: 20px; height: 20px; }
.brand-title { font-weight: 700; color: #fff; font-size: 15px; letter-spacing: .02em; }
.brand-sub { font-size: 11px; color: var(--sidebar-muted); margin-top: 2px; }

.nav { padding: 14px 10px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--sidebar-text);
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.is-active {
  background: linear-gradient(90deg, rgba(18,140,131,.28), rgba(18,140,131,.12));
  color: #fff;
  box-shadow: inset 3px 0 0 #1aa89c;
}
.nav-item.is-active svg { opacity: 1; }

.sidebar-foot {
  padding: 16px 18px 22px;
  border-top: 1px solid rgba(255,255,255,.06);
  color: var(--sidebar-muted);
  font-size: 12px;
  line-height: 1.6;
}
.sample-pill {
  display: inline-flex;
  align-items: center;
  background: rgba(26, 168, 156, .18);
  color: #7de3d8;
  border: 1px solid rgba(26, 168, 156, .28);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  padding: 3px 8px;
  border-radius: 999px;
  margin-bottom: 8px;
}
.sidebar-foot p { margin: 0; }

/* ===== Main ===== */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 28px 8px;
}
.topbar h1 { font-size: 22px; }
.page-desc { margin: 4px 0 0; color: var(--text-2); font-size: 13px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.plant-tag {
  font-size: 12px;
  color: var(--text-2);
  background: #fff;
  border: 1px solid var(--line);
  padding: 6px 10px;
  border-radius: 999px;
}
.content { padding: 8px 28px 36px; }

/* ===== Buttons ===== */
.btn {
  appearance: none;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  padding: 8px 14px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  transition: transform .1s, filter .15s, background .15s, box-shadow .15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn.ghost {
  background: #fff;
  color: var(--text);
  border-color: var(--line-2);
}
.btn.ghost:hover { background: #f7f9fb; filter: none; }
.btn.soft {
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.btn.danger { background: var(--danger); }
.btn.warn { background: var(--warning); }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ===== Cards / layout ===== */
.grid { display: grid; gap: 16px; }
.kpi-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 16px 18px; }
.card-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.card-h h2, .section-title { font-size: 14px; font-weight: 650; }
.muted { color: var(--text-2); font-size: 12px; }

.kpi {
  padding: 16px 16px 14px;
  position: relative;
  overflow: hidden;
}
.kpi-icon {
  width: 32px; height: 32px;
  border-radius: 9px;
  display: grid; place-items: center;
  margin-bottom: 10px;
}
.kpi-icon svg { width: 16px; height: 16px; }
.kpi-label { font-size: 12px; color: var(--text-2); }
.kpi-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.04em;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.kpi-hint { font-size: 11px; color: var(--text-3); margin-top: 4px; }
.kpi.warn .kpi-value, .kpi.warn .kpi-hint { color: var(--warning); }
.kpi.danger .kpi-value, .kpi.danger .kpi-hint { color: var(--danger); }

.dash-split { display: grid; grid-template-columns: 1.15fr 1fr; gap: 16px; margin-top: 16px; }

/* ===== Table ===== */
.table-wrap { overflow: auto; border-radius: 0 0 var(--radius) var(--radius); }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data th, table.data td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.data th {
  font-size: 11px;
  font-weight: 650;
  color: var(--text-3);
  letter-spacing: .06em;
  text-transform: none;
  background: #f7f9fb;
  position: sticky;
  top: 0;
  z-index: 2;
  white-space: nowrap;
}
table.data tbody tr { cursor: pointer; transition: background .12s; }
table.data tbody tr:hover { background: #f4fbf9; }
table.data tbody tr.is-off { opacity: .7; }
table.data .code {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 12.5px;
  color: var(--accent-ink);
}
.row-actions { display: flex; gap: 6px; }
.row-actions .btn { cursor: pointer; }

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef2f5;
  color: var(--text-2);
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge.stock { background: var(--success-soft); color: var(--success); }
.badge.use { background: var(--info-soft); color: var(--info); }
.badge.maint { background: var(--warning-soft); color: var(--warning); }
.badge.repair { background: var(--purple-soft); color: var(--purple); }
.badge.scrap { background: #f1f3f5; color: #64748b; }
.badge.low { background: var(--danger-soft); color: var(--danger); }
.badge.wait { background: #eef2f5; color: #52606e; }
.badge.ok { background: var(--success-soft); color: var(--success); }
.badge.fail { background: var(--danger-soft); color: var(--danger); }
.badge.pending { background: var(--warning-soft); color: var(--warning); }

/* ===== Toolbar / filters ===== */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 14px 16px 8px;
}
.search {
  flex: 1;
  min-width: 200px;
  position: relative;
}
.search input, .field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line-2);
  background: #fff;
  border-radius: 9px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search input { padding-left: 34px; }
.search svg {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--text-3);
}
.field input:focus, .field select:focus, .field textarea:focus, .search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 122, 114, .15);
}
.tabs { display: flex; gap: 4px; background: #eef2f5; padding: 3px; border-radius: 10px; }
.tab {
  border: 0;
  background: transparent;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}
.tab.is-active { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(21,32,43,.08); }

/* ===== Forms ===== */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}
.form-grid .span-2 { grid-column: span 2; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
}
.field textarea { min-height: 84px; resize: vertical; }
.req { color: var(--danger); margin-left: 2px; }

/* ===== Progress ===== */
.progress {
  height: 8px;
  background: #e8edf1;
  border-radius: 999px;
  overflow: hidden;
}
.progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--success);
}
.progress.mid > span { background: var(--warning); }
.progress.high > span { background: var(--danger); }
.prog-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 6px;
}

/* ===== Timeline ===== */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  position: relative;
  padding: 0 0 18px 22px;
}
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: "";
  position: absolute;
  left: 5px; top: 8px; bottom: -8px;
  width: 2px;
  background: var(--line);
}
.timeline li:last-child::before { display: none; }
.timeline li::after {
  content: "";
  position: absolute;
  left: 1px; top: 7px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
}
.timeline .t-title { font-size: 13px; font-weight: 650; }
.timeline .t-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.timeline .t-body { font-size: 12.5px; color: var(--text-2); margin-top: 4px; }

/* ===== Drawer / modal ===== */
.overlay {
  position: fixed; inset: 0;
  background: rgba(15, 22, 30, .36);
  z-index: 1000;
}
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(560px, 100vw);
  background: #fff;
  z-index: 1010;
  isolation: isolate;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: slideIn .22s ease;
}
@keyframes slideIn { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-h {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px;
  padding: 20px 22px 12px;
  border-bottom: 1px solid var(--line);
}
.drawer-h h2 { font-size: 18px; }
.drawer-b { padding: 18px 22px 28px; overflow: auto; flex: 1; }
.icon-btn {
  border: 0; background: #f1f4f7; width: 32px; height: 32px;
  border-radius: 8px; display: grid; place-items: center; color: var(--text-2);
}
.icon-btn:hover { background: #e6ebf0; }
.icon-btn svg { width: 16px; height: 16px; }

.modal-wrap {
  position: fixed; inset: 0;
  z-index: 1020;
  display: grid;
  place-items: center;
  background: rgba(15, 22, 30, .4);
  padding: 24px;
}
.modal {
  width: min(680px, 100%);
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  max-height: min(88vh, 900px);
  display: flex;
  flex-direction: column;
  animation: pop .18s ease;
}
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-h h2 { font-size: 16px; }
.modal-b { padding: 18px 20px; overflow: auto; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--line); }

/* ===== Attachments ===== */
.attach-list { display: flex; flex-direction: column; gap: 8px; }
.attach {
  display: flex; align-items: center; gap: 10px;
  border: 1px dashed var(--line-2);
  border-radius: 10px;
  padding: 10px 12px;
  background: #f9fbfc;
}
.attach .file-ico {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent-ink);
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
}
.attach .name { font-size: 13px; font-weight: 600; }
.attach .kind { font-size: 11px; color: var(--text-3); }

/* ===== Kanban ===== */
.kanban { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.kanban-col {
  background: #f4f7f9;
  border-radius: 14px;
  padding: 12px;
  min-height: 240px;
}
.kanban-col h3 { font-size: 13px; display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.k-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 8px;
  box-shadow: 0 1px 2px rgba(21,32,43,.04);
}
.k-card h4 { font-size: 13px; }
.k-card p { margin: 6px 0 0; font-size: 12px; color: var(--text-2); line-height: 1.55; }

/* ===== Lists ===== */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li {
  display: flex; gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.feed li:last-child { border-bottom: 0; }
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); margin-top: 6px; flex-shrink: 0;
}
.dot.warn { background: var(--warning); }
.dot.danger { background: var(--danger); }
.dot.info { background: var(--info); }
.feed .title { font-size: 13px; font-weight: 600; }
.feed .meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.due-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.due-row:last-child { border-bottom: 0; }
.due-row.overdue { background: linear-gradient(90deg, #fff6f8, transparent); margin: 0 -8px; padding-left: 8px; padding-right: 8px; border-radius: 8px; }
.due-row.soon { background: linear-gradient(90deg, #fffaf0, transparent); margin: 0 -8px; padding-left: 8px; padding-right: 8px; border-radius: 8px; }

/* ===== Toasts ===== */
.toasts {
  position: fixed; right: 20px; bottom: 20px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 1100;
}
.toast {
  background: #15202b;
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: pop .18s ease;
  min-width: 220px;
}
.toast.ok { background: #0f5c4c; }
.toast.err { background: #9e1238; }

/* ===== Misc ===== */
.section { margin-top: 18px; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 6px 10px; font-size: 13px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; }
.note {
  background: #f7f9fb;
  border: 1px dashed var(--line-2);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.6;
}
.empty {
  text-align: center;
  color: var(--text-3);
  padding: 36px 12px;
  font-size: 13px;
}
.hl-overdue td { background: #fff5f7; }
.hl-soon td { background: #fff9ee; }
.split-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chip {
  display: inline-block;
  background: #eef2f5;
  color: var(--text-2);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 6px;
  margin: 0 4px 4px 0;
}

@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .dash-split, .split-2, .kanban { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar { display: none; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
