:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #1f2733;
  --ink-2: #5b6675;
  --ink-3: #8a93a3;
  --line: #e7ebf1;
  --brand: #2563eb;
  --brand-soft: #eaf1ff;
  --sidebar: #111827;
  --sidebar-2: #1f2937;
  --ok: #16a34a;
  --ok-soft: #e7f6ec;
  --warn: #d97706;
  --warn-soft: #fdf2e3;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --info: #0891b2;
  --info-soft: #e3f5f9;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 4px 16px rgba(16,24,40,.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

.app { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
.sidebar {
  width: 232px; background: var(--sidebar); color: #cbd5e1;
  display: flex; flex-direction: column; padding: 18px 14px; flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 18px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 18px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { color: #fff; font-size: 15px; }
.brand-text span { color: #94a3b8; font-size: 11px; }

.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px;
  border-radius: 9px; color: #cbd5e1; text-decoration: none; cursor: pointer;
  font-size: 13.5px; transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--sidebar-2); color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-foot { margin-top: auto; }
.env-tag {
  font-size: 11px; color: #94a3b8; background: var(--sidebar-2);
  padding: 7px 10px; border-radius: 8px; text-align: center;
}

/* Main */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  height: 60px; background: var(--panel); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px; flex-shrink: 0;
}
.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.search { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 7px 11px; width: 280px; }
.search svg { width: 16px; height: 16px; color: var(--ink-3); }
.search input { border: 0; background: transparent; outline: none; flex: 1; font-size: 13px; color: var(--ink); }
.user { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 600; }

.content { flex: 1; overflow-y: auto; padding: 24px; }

/* Cards / grids */
.grid { display: grid; gap: 16px; }
.stats { grid-template-columns: repeat(4, 1fr); margin-bottom: 18px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.stat .label { color: var(--ink-3); font-size: 12.5px; }
.stat .value { font-size: 26px; font-weight: 700; margin: 6px 0 2px; }
.stat .delta { font-size: 12px; color: var(--ok); }
.stat .delta.down { color: var(--danger); }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; margin-bottom: 18px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel-head h3 { font-size: 14.5px; font-weight: 600; }
.panel-body { padding: 16px 18px; }

/* Table */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--ink-3); font-weight: 500; padding: 10px 12px; border-bottom: 1px solid var(--line); }
td { padding: 11px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfd; }
tbody tr.sel { background: var(--brand-soft); }
.muted { color: var(--ink-3); }
.mono { font-variant-numeric: tabular-nums; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 500; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-ok { color: var(--ok); background: var(--ok-soft); }
.b-warn { color: var(--warn); background: var(--warn-soft); }
.b-danger { color: var(--danger); background: var(--danger-soft); }
.b-info { color: var(--info); background: var(--info-soft); }
.b-brand { color: var(--brand); background: var(--brand-soft); }
.b-gray { color: var(--ink-2); background: #eef1f5; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 13px; border-radius: 8px; font-size: 13px; cursor: pointer; transition: .15s; }
.btn:hover { border-color: #cdd5e0; background: #fafbfd; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: #1d4fd8; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn svg { width: 15px; height: 15px; }

/* Tabs */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); padding: 0 18px; }
.tab { padding: 11px 4px; margin-right: 18px; font-size: 13.5px; color: var(--ink-2); cursor: pointer; border-bottom: 2px solid transparent; }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 500; }

/* Avatar / thumb */
.thumb { width: 38px; height: 38px; border-radius: 8px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 600; flex-shrink: 0; }
.row { display: flex; align-items: center; gap: 12px; }
.col { display: flex; flex-direction: column; }

/* Modal */
.modal-mount { position: fixed; inset: 0; display: none; }
.modal-mount.open { display: block; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15,23,42,.45); }
.modal {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 560px; max-width: 92vw; max-height: 88vh; overflow-y: auto;
  background: #fff; border-radius: 14px; box-shadow: 0 20px 60px rgba(2,6,23,.3);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 15px; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); }
.x { cursor: pointer; color: var(--ink-3); font-size: 20px; line-height: 1; }

/* Form */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; outline: none; font-family: inherit; color: var(--ink); background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.upload-zone { border: 1.5px dashed var(--line); border-radius: 10px; padding: 22px; text-align: center; color: var(--ink-3); font-size: 13px; cursor: pointer; }
.upload-zone:hover { border-color: var(--brand); color: var(--brand); }

/* Work order detail */
.detail-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.steps { display: flex; gap: 0; margin: 4px 0 18px; }
.step { flex: 1; text-align: center; position: relative; font-size: 12px; color: var(--ink-3); }
.step::before { content: ""; position: absolute; top: 11px; left: -50%; width: 100%; height: 2px; background: var(--line); z-index: 0; }
.step:first-child::before { display: none; }
.step .dot { width: 24px; height: 24px; border-radius: 50%; background: #fff; border: 2px solid var(--line); display: grid; place-items: center; margin: 0 auto 6px; position: relative; z-index: 1; font-size: 11px; color: var(--ink-3); }
.step.active { color: var(--brand); }
.step.active .dot { border-color: var(--brand); background: var(--brand); color: #fff; }
.step.done .dot { border-color: var(--brand); color: var(--brand); }

.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 14px; font-size: 13px; }
.kv dt { color: var(--ink-3); }
.kv dd { color: var(--ink); }

.two-col { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; }
@media (max-width: 1100px) { .two-col { grid-template-columns: 1fr; } .stats { grid-template-columns: repeat(2,1fr); } }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 11px 18px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow); opacity: 0; transition: opacity .2s; z-index: 50; }
.toast.show { opacity: 1; }
