:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --sidebar: #0f172a;
  --sidebar-text: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-soft: #eff6ff;
  --primary-hover: #1d4ed8;
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .04);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
code { background: #f1f5f9; padding: 2px 6px; border-radius: 6px; font-size: 12px; }

/* Buttons & Inputs */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 15px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 14px; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: all .15s ease;
}
button:hover, .btn:hover { background: var(--surface-2); }
button.primary, .btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
button.primary:hover, .btn.primary:hover { background: var(--primary-hover); }
button.danger { color: var(--danger); border-color: #fecaca; background: #fff; }
button.danger:hover { background: var(--danger-soft); }
button.sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
input, select, textarea {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 14px; font-family: inherit; background: var(--surface); color: var(--text);
  outline: none; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }

.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* Desktop Shell */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 256px; background: var(--sidebar); color: var(--sidebar-text);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 0; height: 100vh; flex-shrink: 0;
}
.sidebar .logo { color: #fff; font-weight: 800; font-size: 18px; padding: 8px 12px 18px; display: flex; align-items: center; justify-content: space-between; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 10px;
  color: var(--sidebar-text); font-weight: 500; font-size: 14px; cursor: pointer; border: none; background: transparent; width: 100%; text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.1); font-size: 13px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 12px 24px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  position: sticky; top: 0; z-index: 20;
}
.content { padding: 24px; max-width: 1360px; width: 100%; margin: 0 auto; }

/* Cards & KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 14px; margin-bottom: 22px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi .label { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi .val { font-size: 28px; font-weight: 800; margin-top: 4px; letter-spacing: -0.02em; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--primary-soft); color: var(--primary); }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #f1f5f9; color: #334155; }
.pill.dang_thuc_hien { background: #dbeafe; color: #1d4ed8; }
.pill.hoan_thanh { background: var(--ok-soft); color: #15803d; }
.pill.tam_dung { background: var(--warn-soft); color: #b45309; }
.pill.superadmin { background: #fae8ff; color: #86198f; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr.clickable:hover { background: var(--surface-2); cursor: pointer; }

.progress-bar { height: 8px; background: #e2e8f0; border-radius: 999px; overflow: hidden; width: 96px; display: inline-block; vertical-align: middle; }
.progress-bar > span { display: block; height: 100%; background: linear-gradient(90deg, #2563eb, #3b82f6); border-radius: 999px; }

/* Kanban */
.kanban { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 14px; }
.col { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px; min-height: 240px; }
.col h4 { margin: 0 0 10px; font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; text-transform: uppercase; letter-spacing: .03em; }
.task { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 10px; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.task-title { font-weight: 600; font-size: 14px; }
.task-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: radial-gradient(circle at top right, #dbeafe, #f1f5f9 55%); }
.login-box { max-width: 430px; width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 32px; box-shadow: 0 20px 45px rgba(15,23,42,.08); }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.5); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 60; }
.modal { background: var(--surface); border-radius: 16px; padding: 24px; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; box-shadow: 0 25px 50px rgba(0,0,0,.2); }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: #334155; }
.field input, .field select, .field textarea { width: 100%; }

/* Mobile-First Smartphone Mode */
.bottom-nav, .fab { display: none; }
body.is-mobile .sidebar { display: none; }
body.is-mobile .topbar { padding: 10px 14px; }
body.is-mobile .content { padding: 14px 14px 88px; }
body.is-mobile .kpis { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
body.is-mobile .kpi { padding: 12px 14px; }
body.is-mobile .kpi .val { font-size: 22px; }
body.is-mobile .card { padding: 14px; border-radius: 14px; }
body.is-mobile .bottom-nav {
  display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  background: rgba(255,255,255,.95); backdrop-filter: blur(10px);
  border-top: 1px solid var(--border); padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  justify-content: space-around;
}
body.is-mobile .bottom-nav button {
  flex: 1; flex-direction: column; gap: 2px; border: none; background: transparent;
  padding: 6px 4px; font-size: 11px; color: var(--muted); min-height: 48px;
}
body.is-mobile .bottom-nav button.active { color: var(--primary); font-weight: 700; }
body.is-mobile .fab {
  display: flex; position: fixed; right: 16px; bottom: 78px; z-index: 39;
  width: 54px; height: 54px; border-radius: 50%; background: var(--primary); color: #fff;
  border: none; font-size: 26px; box-shadow: 0 8px 20px rgba(37,99,235,.4);
}
body.is-mobile .modal-bg { align-items: flex-end; padding: 0; }
body.is-mobile .modal { border-radius: 20px 20px 0 0; max-width: 100%; max-height: 88vh; }
body.is-mobile .kanban { grid-template-columns: 1fr; }
.seg-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-top: 10px; }
.seg-tab { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: 13px; white-space: nowrap; }
.seg-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.proj-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px; margin-bottom: 10px; }
.split-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
body.is-mobile .split-2 { grid-template-columns: 1fr; }

/* IBM Stage-Gate Stepper & Gantt */
.stepper { display: flex; gap: 6px; overflow-x: auto; margin: 12px 0; }
.step-btn {
  flex: 1; min-width: 110px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); font-size: 12px; font-weight: 600; color: var(--muted); text-align: center;
}
.step-btn.done { background: var(--ok-soft); color: #15803d; border-color: #bbf7d0; }
.step-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.gantt-row { display: grid; grid-template-columns: 200px 1fr; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
body.is-mobile .gantt-row { grid-template-columns: 1fr; gap: 6px; }
.gantt-track { height: 18px; background: #e2e8f0; border-radius: 999px; position: relative; overflow: hidden; }
.gantt-bar { position: absolute; top: 0; bottom: 0; border-radius: 999px; background: linear-gradient(90deg, #2563eb, #60a5fa); }
.item-tag { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.item-tag.epic { background: #f3e8ff; color: #7e22ce; }
.item-tag.story { background: #dcfce7; color: #15803d; }
.item-tag.task { background: #dbeafe; color: #1d4ed8; }
.item-tag.defect { background: #fee2e2; color: #b91c1c; }
