/* =============================================================
   TOKENS — bảng màu & kiểu chữ riêng cho dashboard vận hành
   ============================================================= */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --border: #e3e8f2;
  --ink: #132043;
  --ink-soft: #5b6b8c;
  --accent: #2f6fed;
  --accent-soft: #e7eeff;
  --warn: #e0a430;
  --warn-soft: #fdf3e2;
  --danger: #d64545;
  --danger-soft: #fbe9e9;
  --success: #2e9e6d;
  --success-soft: #e7f6ef;

  --font-display: "Space Grotesk", sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(19, 32, 67, 0.06), 0 8px 24px -12px rgba(19, 32, 67, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 18px 14px;
  background: var(--ink);
  color: #fff;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  font-family: var(--font-display);
  font-weight: 700;
  background: var(--accent);
  color: #fff;
  width: 32px; height: 32px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: 16px; }
.topbar-user {
  font-size: 12px;
  color: #b9c3de;
  background: rgba(255,255,255,0.08);
  padding: 5px 10px;
  border-radius: 20px;
}

/* ---------- View root ---------- */
.view-root { padding: 18px; max-width: 720px; margin: 0 auto; }

.section-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  margin: 22px 0 10px;
}
.section-title:first-child { margin-top: 4px; }

/* ---------- Cards tổng quan ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.stat-card .value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.1;
}
.stat-card .label {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 4px;
}
.stat-card.warn .value { color: var(--warn); }
.stat-card.danger .value { color: var(--danger); }
.stat-card.success .value { color: var(--success); }

/* ---------- List items (công việc / đơn hàng) ---------- */
.list-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  box-shadow: var(--shadow);
}
.list-item-main { flex: 1; min-width: 0; }
.list-item-title {
  font-weight: 600;
  font-size: 14.5px;
  color: var(--ink);
  margin-bottom: 3px;
}
.list-item-meta {
  font-size: 12.5px;
  color: var(--ink-soft);
}
.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 20px;
  white-space: nowrap;
}
.badge.status-chua-bat-dau { background: var(--accent-soft); color: var(--accent); }
.badge.status-dang-lam { background: var(--warn-soft); color: var(--warn); }
.badge.status-hoan-thanh { background: var(--success-soft); color: var(--success); }
.badge.status-qua-han { background: var(--danger-soft); color: var(--danger); }

/* ---------- Form tạo nhanh ---------- */
.fab {
  position: fixed;
  right: 18px;
  bottom: calc(88px + env(safe-area-inset-bottom));
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 26px;
  border: none;
  box-shadow: 0 10px 24px -6px rgba(47, 111, 237, 0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 5;
}

.quick-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.quick-form input, .quick-form select, .quick-form textarea {
  width: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg);
  color: var(--ink);
}
.quick-form button.submit-btn {
  width: 100%;
  padding: 11px;
  background: var(--ink);
  color: #fff;
  border: none;
  border-radius: 9px;
  font-weight: 600;
  font-size: 14px;
}

/* ---------- Chart container ---------- */
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

/* ---------- Empty / loading states ---------- */
.loading-state, .empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-soft);
  font-size: 13.5px;
}
.spinner {
  width: 26px; height: 26px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Tabbar ---------- */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  z-index: 10;
}
.tab-btn {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none;
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-size: 11px;
  padding: 6px 0;
}
.tab-btn.active { color: var(--accent); }
.tab-icon { font-size: 17px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 20;
  max-width: 85%;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
