:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #111827;
  --muted: #667085;
  --line: #e5e7eb;
  --primary: #1769ff;
  --primary-dark: #0e4fd1;
  --success: #14a66f;
  --warning: #f59e0b;
  --danger: #ef4444;
  --sidebar: #101828;
  --shadow: 0 12px 30px rgba(16, 24, 40, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, "Noto Sans SC", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
}

button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  background: #0b1220;
}

.login-visual {
  padding: 72px;
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    radial-gradient(circle at 30% 20%, rgba(23,105,255,.35), transparent 35%),
    linear-gradient(145deg, #0b1220, #16223b);
}

.brand-mark {
  width: 60px;
  height: 60px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: var(--primary);
  font-weight: 800;
  letter-spacing: .04em;
}

.brand-mark.small {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  font-size: 14px;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .14em;
  color: #7da8ff;
}

.login-visual h1 {
  font-size: clamp(42px, 6vw, 82px);
  line-height: 1.02;
  margin: 0;
  max-width: 800px;
}

.login-copy {
  max-width: 620px;
  margin-top: 24px;
  color: #c7d2e3;
  font-size: 18px;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  max-width: 650px;
}

.feature-grid div {
  padding: 22px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 18px;
  background: rgba(255,255,255,.05);
}

.feature-grid strong {
  display: block;
  font-size: 28px;
}

.feature-grid span {
  color: #aebbd0;
  font-size: 13px;
}

.login-panel {
  background: #f7f8fa;
  display: grid;
  place-items: center;
  padding: 40px;
}

.login-card {
  width: min(420px, 100%);
  background: white;
  border-radius: 24px;
  padding: 34px;
  box-shadow: var(--shadow);
}

.login-card h2 { margin: 0 0 6px; font-size: 28px; }
.muted, .hint { color: var(--muted); }
.hint { font-size: 12px; text-align: center; }

label {
  display: block;
  margin: 18px 0 8px;
  font-size: 13px;
  font-weight: 600;
}

input, select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--text);
  outline: none;
}

input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23,105,255,.12);
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 700;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #e9efff; color: var(--primary); }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn-block { width: 100%; margin-top: 18px; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px 1fr;
}

.sidebar {
  min-height: 100vh;
  position: sticky;
  top: 0;
  padding: 22px 16px;
  background: var(--sidebar);
  color: white;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 30px;
}

.sidebar-brand strong, .user-chip strong { display: block; }
.sidebar-brand span, .user-chip span { color: #98a2b3; font-size: 12px; }

nav { display: grid; gap: 7px; }

.nav-item {
  text-align: left;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #c9d2e3;
  padding: 12px 14px;
  font-weight: 600;
}

.nav-item.active, .nav-item:hover {
  background: rgba(255,255,255,.09);
  color: white;
}

.sidebar-footer { margin-top: auto; }
.user-chip {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 14px 0;
  border-top: 1px solid rgba(255,255,255,.08);
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #344054;
  font-size: 12px;
  font-weight: 800;
}

.sidebar .btn-ghost {
  border-color: rgba(255,255,255,.15);
  color: white;
}

.main { padding: 26px 30px 50px; min-width: 0; }

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 26px;
}

.topbar h1 { margin: 0; font-size: 30px; }
.topbar-actions { display: flex; gap: 10px; }
.topbar-actions select { min-width: 150px; }

.page { display: none; }
.page.active { display: block; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.kpi-grid.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.kpi-card {
  padding: 20px;
  background: var(--panel);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.kpi-card span, .kpi-card small { color: var(--muted); }
.kpi-card strong { display: block; font-size: 28px; margin: 12px 0 8px; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}

.panel {
  background: var(--panel);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.span-2 { grid-column: span 1; }

.panel-head, .section-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-head h3 { margin: 0 0 4px; }
.panel-head p { margin: 0; color: var(--muted); font-size: 13px; }

.country-performance { display: grid; gap: 12px; }
.country-row {
  display: grid;
  grid-template-columns: 130px 1fr 90px;
  gap: 14px;
  align-items: center;
}

.progress {
  height: 10px;
  background: #edf0f4;
  border-radius: 999px;
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  background: var(--primary);
  border-radius: inherit;
}

.target-list, .todo-list { display: grid; gap: 12px; }

.target-item, .todo-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}

.target-item strong, .todo-item strong { display: block; margin-bottom: 5px; }
.target-item small, .todo-item small { color: var(--muted); }
.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 7px;
}
.good { background: var(--success); }
.warn { background: var(--warning); }
.bad { background: var(--danger); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 820px; }
th, td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
}
th { color: var(--muted); font-weight: 600; background: #fafbfc; }
td strong { font-size: 13px; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.badge-success { background: #e9f8f2; color: #087b51; }
.badge-warning { background: #fff6dd; color: #9a6700; }
.badge-danger { background: #feecec; color: #b42318; }
.badge-neutral { background: #eef2f6; color: #475467; }

.action-link {
  color: var(--primary);
  background: none;
  border: 0;
  padding: 0;
  font-weight: 700;
}

.search-box { width: min(360px, 100%); }

.import-grid, .settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.upload-zone {
  border: 1.5px dashed #aab3c1;
  border-radius: 14px;
  padding: 28px;
  text-align: center;
  position: relative;
  background: #fafbfc;
}

.upload-zone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-zone strong, .upload-zone span { display: block; }
.upload-zone span { color: var(--muted); font-size: 12px; margin-top: 8px; }

.rules-list { margin: 0; padding-left: 20px; color: #475467; line-height: 1.9; }

.task-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.task-card {
  background: white;
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.task-card h3 { margin: 12px 0 6px; }
.task-card p { color: var(--muted); font-size: 13px; min-height: 40px; }
.task-meta {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  font-size: 13px;
}

.payroll-summary span { color: var(--muted); font-size: 13px; display: block; }
.payroll-summary strong { font-size: 26px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.form-grid label { margin: 0; }

.icon-btn {
  border: 0;
  background: transparent;
  font-size: 28px;
  color: var(--muted);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(16,24,40,.48);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 20;
}

.modal-card {
  width: min(580px, 100%);
  background: white;
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 30px 60px rgba(16,24,40,.25);
}

.modal-head, .modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-head h3 { margin: 0; }
.modal-actions { justify-content: flex-end; gap: 10px; margin-top: 22px; }

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: #101828;
  color: white;
  padding: 12px 16px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 30;
}

@media (max-width: 1080px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-visual { min-height: 45vh; padding: 40px; }
  .feature-grid { display: none; }
  .app-shell { grid-template-columns: 86px 1fr; }
  .sidebar-brand div:last-child, .nav-item { font-size: 0; }
  .nav-item::first-letter { font-size: 15px; }
  .user-chip div:last-child { display: none; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .task-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .app-shell { display: block; }
  .sidebar {
    min-height: auto;
    position: static;
    flex-direction: row;
    overflow-x: auto;
    padding: 10px;
  }
  .sidebar-brand, .sidebar-footer { display: none; }
  nav { display: flex; }
  .nav-item { white-space: nowrap; font-size: 12px; }
  .main { padding: 18px 14px 40px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .topbar-actions { width: 100%; }
  .topbar-actions select { min-width: 0; }
  .kpi-grid, .kpi-grid.compact, .dashboard-grid, .import-grid, .settings-grid, .task-grid {
    grid-template-columns: 1fr;
  }
  .panel-head, .section-actions { align-items: flex-start; flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
}


/* Bilingual hierarchy */
.bi-cn {
  display: block;
  font-weight: 700;
  line-height: 1.25;
}
.bi-en {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.2;
}
button .bi-en,
.nav-item .bi-en,
.btn-primary .bi-en {
  color: inherit;
  opacity: .78;
}
.nav-item {
  min-height: 52px;
}
.nav-item .bi-cn,
.nav-item .bi-en {
  pointer-events: none;
}
th .bi-cn {
  font-size: 12px;
}
th .bi-en {
  font-size: 10px;
}
.login-copy .bi-cn {
  font-size: 20px;
  color: white;
}
.login-copy .bi-en {
  font-size: 14px;
  color: #b8c5d8;
}
h2 .bi-en, h3 .bi-en {
  font-size: 12px;
}
.panel-head h3 .bi-en {
  margin-top: 4px;
}
.kpi-card > span .bi-en {
  margin-top: 4px;
}
label .bi-en {
  font-size: 10px;
}
@media (max-width:1080px){
  .nav-item {font-size: 0;}
  .nav-item .bi-cn,.nav-item .bi-en{font-size:11px}
}

/* Role based access control */
.access-scope {
  margin: 0 0 18px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f7faff;
  color: var(--text);
  font-size: 13px;
}
.access-scope strong { margin-right: 8px; }
.permission-hidden { display: none !important; }
.readonly-note { color: var(--muted); font-size: 12px; }
.login-error { color: #c0392b !important; }
