:root {
  --primary: #0f766e;
  --primary-dark: #115e59;
  --primary-soft: #ccfbf1;
  --secondary: #2563eb;
  --secondary-soft: #dbeafe;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --info: #0284c7;
  --info-soft: #e0f2fe;
  --ink: #172033;
  --muted: #64748b;
  --line: #e2e8f0;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --canvas: #eef4f6;
  --sidebar: #0b3b3a;
  --shadow: 0 12px 32px rgba(15, 23, 42, .08);
  --shadow-sm: 0 4px 16px rgba(15, 23, 42, .07);
  --radius: 16px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }

.app-shell { min-height: 100vh; display: flex; }
.sidebar {
  width: 238px;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  color: #d8f5f0;
  background: linear-gradient(180deg, #0b3b3a 0%, #0c4d49 58%, #083331 100%);
  box-shadow: 8px 0 28px rgba(4, 47, 46, .12);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 22px 18px 18px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center;
  background: linear-gradient(145deg, #5eead4, #14b8a6); color: #073b38;
  font-size: 23px; font-weight: 900; box-shadow: inset 0 1px 0 rgba(255,255,255,.55);
}
.brand h1 { margin: 0; color: #fff; font-size: 16px; letter-spacing: .02em; }
.brand p { margin: 2px 0 0; color: #94d7ce; font-size: 11px; }
.nav-section-title { padding: 14px 20px 7px; color: #7fc6bd; font-size: 11px; letter-spacing: .12em; }
.nav { padding: 0 10px; }
.nav-item {
  width: 100%; min-height: 42px; margin: 3px 0; padding: 0 12px; border: 0; border-radius: 10px;
  display: flex; align-items: center; gap: 11px; color: #c8ebe6; background: transparent; text-align: left;
  transition: background .2s, color .2s, transform .2s;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,.08); transform: translateX(2px); }
.nav-item.active { color: #fff; background: rgba(45, 212, 191, .2); box-shadow: inset 3px 0 0 #5eead4; }
.nav-icon { width: 22px; text-align: center; font-size: 17px; }
.nav-badge { margin-left: auto; min-width: 20px; padding: 1px 6px; border-radius: 999px; color: #fff; background: var(--danger); font-size: 11px; text-align: center; }
.sidebar-footer { margin-top: auto; padding: 14px; }
.user-box { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 12px; background: rgba(255,255,255,.08); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #064e49; background: #99f6e4; font-weight: 800; }
.user-box strong { display: block; color: #fff; font-size: 13px; }
.user-box small { color: #93d5cd; }

.main { width: calc(100% - 238px); min-height: 100vh; margin-left: 238px; }
.topbar {
  height: 68px; position: sticky; top: 0; z-index: 20; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,.92); border-bottom: 1px solid rgba(226,232,240,.8); backdrop-filter: blur(14px);
}
.page-heading h2 { margin: 0; font-size: 20px; }
.page-heading p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: #fff; }
.icon-button:hover { color: var(--primary); border-color: #99d8d1; background: #f0fdfa; }
.role-switch { padding: 8px 11px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: #fff; }
.content { padding: 22px 24px 38px; }
.page { display: none; animation: fadeUp .26s ease; }
.page.active { display: block; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.toolbar { margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.btn {
  min-height: 38px; padding: 0 15px; border: 1px solid transparent; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-weight: 650;
  transition: transform .18s, box-shadow .18s, background .18s;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn-primary { color: #fff; background: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { color: var(--primary-dark); border-color: #b7dfda; background: #fff; }
.btn-danger { color: #fff; background: var(--danger); }
.btn-ghost { color: var(--muted); border-color: var(--line); background: #fff; }
.btn-small { min-height: 30px; padding: 0 10px; font-size: 12px; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-bottom: 16px; }
.kpi-card { position: relative; min-height: 126px; padding: 18px; overflow: hidden; border: 1px solid rgba(226,232,240,.9); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.kpi-card::after { content: ""; width: 80px; height: 80px; position: absolute; right: -23px; top: -23px; border-radius: 50%; background: var(--primary-soft); opacity: .65; }
.kpi-head { display: flex; align-items: center; justify-content: space-between; color: var(--muted); }
.kpi-icon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: var(--primary); background: var(--primary-soft); font-size: 17px; }
.kpi-value { margin-top: 9px; font-size: 29px; line-height: 1.1; font-weight: 800; letter-spacing: -.03em; }
.kpi-foot { margin-top: 8px; color: var(--muted); font-size: 12px; }
.trend-up { color: var(--success); font-weight: 700; }
.trend-down { color: var(--danger); font-weight: 700; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0,1.35fr) minmax(320px,.65fr); gap: 16px; }
.card { border: 1px solid rgba(226,232,240,.95); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.card-header { min-height: 57px; padding: 14px 17px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.card-header h3 { margin: 0; font-size: 15px; }
.card-header p { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
.card-body { padding: 17px; }

.progress-list { display: grid; gap: 15px; }
.progress-row { display: grid; grid-template-columns: 110px 1fr 48px; align-items: center; gap: 10px; }
.progress-track { height: 9px; overflow: hidden; border-radius: 999px; background: #e9eef3; }
.progress-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), #2dd4bf); }
.progress-value { color: var(--muted); font-size: 12px; text-align: right; }

.status-list { display: grid; gap: 9px; }
.status-item { padding: 11px 12px; display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 11px; background: #fff; }
.status-dot { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; }
.status-item strong { display: block; font-size: 13px; }
.status-item small { color: var(--muted); }
.status-time { margin-left: auto; color: var(--muted); font-size: 11px; }

.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge-success { color: #166534; background: var(--success-soft); }
.badge-warning { color: #92400e; background: var(--warning-soft); }
.badge-danger { color: #991b1b; background: var(--danger-soft); }
.badge-info { color: #075985; background: var(--info-soft); }
.badge-neutral { color: #475569; background: #eef2f7; }
.badge-primary { color: #115e59; background: var(--primary-soft); }

.filters { margin-bottom: 14px; padding: 13px; display: flex; align-items: center; gap: 9px; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.field { display: grid; gap: 5px; }
.field label { color: var(--muted); font-size: 12px; font-weight: 650; }
.input, .select, .textarea {
  width: 100%; min-height: 38px; padding: 8px 11px; border: 1px solid #cfd8e3; border-radius: 9px; outline: none; color: var(--ink); background: #fff;
  transition: border-color .18s, box-shadow .18s;
}
.input:focus, .select:focus, .textarea:focus { border-color: #3cb8aa; box-shadow: 0 0 0 3px rgba(20,184,166,.12); }
.textarea { min-height: 84px; resize: vertical; }
.search { min-width: 230px; padding-left: 35px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='m11 11 4 4'/%3E%3C/svg%3E") no-repeat 11px center; }

.table-wrap { width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
table { width: 100%; border-collapse: collapse; }
th { position: sticky; top: 0; z-index: 1; padding: 11px 13px; color: #536075; background: #f4f7fa; border-bottom: 1px solid var(--line); font-size: 12px; text-align: left; white-space: nowrap; }
td { padding: 12px 13px; border-bottom: 1px solid #edf1f5; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fffd; }
.cell-main { font-weight: 650; }
.cell-sub { margin-top: 2px; color: var(--muted); font-size: 11px; }

.store-heatmap { display: grid; grid-template-columns: repeat(8, minmax(68px,1fr)); gap: 8px; }
.store-cell { padding: 11px 7px; border: 1px solid transparent; border-radius: 10px; text-align: center; font-size: 12px; transition: transform .18s; }
.store-cell:hover { transform: translateY(-2px); }
.store-good { color: #166534; border-color: #bbf7d0; background: #f0fdf4; }
.store-warn { color: #92400e; border-color: #fde68a; background: #fffbeb; }
.store-bad { color: #991b1b; border-color: #fecaca; background: #fff1f2; }
.store-idle { color: #64748b; border-color: #e2e8f0; background: #f8fafc; }

.task-list { display: grid; gap: 10px; }
.task-item { padding: 13px; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.task-check { width: 23px; height: 23px; border: 2px solid #9db0bd; border-radius: 7px; display: grid; place-items: center; color: #fff; background: #fff; }
.task-item.done .task-check { border-color: var(--success); background: var(--success); }
.task-item.done .task-title { color: var(--muted); text-decoration: line-through; }
.task-title { font-weight: 700; }
.task-meta { margin-top: 3px; color: var(--muted); font-size: 12px; }

.mobile-frame { width: 375px; min-height: 720px; margin: 0 auto; overflow: hidden; border: 8px solid #132a35; border-radius: 32px; background: #f4f7f8; box-shadow: 0 24px 60px rgba(15,23,42,.22); }
.mobile-status { height: 29px; padding: 5px 17px 0; display: flex; justify-content: space-between; color: #fff; background: var(--primary-dark); font-size: 11px; }
.mobile-header { padding: 15px 17px 18px; color: #fff; background: linear-gradient(140deg, var(--primary-dark), var(--primary)); }
.mobile-header h2 { margin: 0; font-size: 19px; }
.mobile-header p { margin: 4px 0 0; color: #b8ebe4; font-size: 12px; }
.mobile-body { padding: 14px 13px 78px; }
.mobile-card { margin-bottom: 12px; padding: 14px; border-radius: 15px; background: #fff; box-shadow: var(--shadow-sm); }
.mobile-stat-row { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.mobile-stat { padding: 11px 6px; border-radius: 11px; background: #f0fdfa; text-align: center; }
.mobile-stat strong { display: block; color: var(--primary-dark); font-size: 20px; }
.mobile-stat span { color: var(--muted); font-size: 10px; }
.mobile-tabs { height: 63px; position: absolute; inset: auto 8px 8px; display: grid; grid-template-columns: repeat(4,1fr); background: rgba(255,255,255,.96); border-radius: 0 0 24px 24px; border-top: 1px solid var(--line); }
.mobile-tab { border: 0; color: var(--muted); background: transparent; font-size: 10px; }
.mobile-tab span { display: block; font-size: 19px; }
.mobile-tab.active { color: var(--primary); font-weight: 700; }
.phone-holder { position: relative; }

.stepper { display: flex; align-items: center; margin-bottom: 19px; }
.step { flex: 1; position: relative; text-align: center; color: var(--muted); font-size: 11px; }
.step::before { content: ""; width: 24px; height: 24px; margin: 0 auto 5px; border: 2px solid #cbd5e1; border-radius: 50%; display: block; background: #fff; }
.step:not(:last-child)::after { content: ""; height: 2px; position: absolute; left: calc(50% + 13px); right: calc(-50% + 13px); top: 11px; background: #dbe3ea; }
.step.active::before, .step.done::before { border-color: var(--primary); background: var(--primary); }
.step.active, .step.done { color: var(--primary-dark); font-weight: 700; }
.step.done::after { background: var(--primary); }

.modal-backdrop { position: fixed; inset: 0; z-index: 80; display: none; place-items: center; padding: 20px; background: rgba(15,23,42,.52); backdrop-filter: blur(3px); }
.modal-backdrop.show { display: grid; }
.modal { width: min(580px,100%); max-height: 90vh; overflow: auto; border-radius: 18px; background: #fff; box-shadow: 0 30px 80px rgba(15,23,42,.28); animation: pop .2s ease; }
@keyframes pop { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: scale(1); } }
.modal-header, .modal-footer { padding: 15px 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.modal-footer { justify-content: flex-end; border-top: 1px solid var(--line); border-bottom: 0; }
.modal-header h3 { margin: 0; }
.modal-body { padding: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.form-grid .span-2 { grid-column: span 2; }
.upload-box { min-height: 92px; padding: 15px; border: 1.5px dashed #9fcfc9; border-radius: 12px; display: grid; place-items: center; color: var(--primary); background: #f0fdfa; text-align: center; }

.toast { min-width: 260px; position: fixed; right: 22px; bottom: 22px; z-index: 100; padding: 13px 15px; display: none; align-items: center; gap: 9px; color: #fff; border-radius: 12px; background: #173c3a; box-shadow: var(--shadow); }
.toast.show { display: flex; animation: fadeUp .2s ease; }
.empty-state { padding: 38px 15px; color: var(--muted); text-align: center; }
.empty-icon { margin-bottom: 7px; font-size: 36px; }

@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .store-heatmap { grid-template-columns: repeat(6,minmax(68px,1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .sidebar { width: 72px; }
  .brand { padding: 17px 14px; }
  .brand-copy, .nav-section-title, .nav-label, .nav-badge, .sidebar-footer { display: none; }
  .nav { padding: 0 8px; }
  .nav-item { padding: 0; justify-content: center; }
  .nav-icon { font-size: 20px; }
  .main { width: calc(100% - 72px); margin-left: 72px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .store-heatmap { grid-template-columns: repeat(4,minmax(60px,1fr)); }
}

@media (max-width: 560px) {
  .sidebar { display: none; }
  .main { width: 100%; margin-left: 0; }
  .topbar { height: auto; min-height: 62px; padding: 11px 14px; }
  .page-heading h2 { font-size: 17px; }
  .role-switch { max-width: 130px; }
  .content { padding: 14px 12px 26px; }
  .kpi-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
  .kpi-card { min-height: 108px; padding: 14px; }
  .kpi-value { font-size: 23px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-left, .toolbar-right { width: 100%; }
  .search { width: 100%; min-width: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
  .mobile-frame { width: 100%; min-height: 700px; border-width: 0; border-radius: 0; }
  .mobile-tabs { inset: auto 0 0; border-radius: 0; }
  .store-heatmap { grid-template-columns: repeat(3,minmax(60px,1fr)); }
}
