:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: rgba(17, 24, 39, .10);
  --border-strong: rgba(17, 24, 39, .16);
  --text: #1f2328;
  --text-muted: #5b616b;
  --text-faint: #8b919b;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef0fe;
  --radius: 12px;
  --radius-sm: 8px;
  --ok-bg: #e7f5ee;  --ok-fg: #16794c;
  --warn-bg: #fdf3e2; --warn-fg: #8a5a00;
  --danger-bg: #fde8e6; --danger-fg: #b42318;
  --info-bg: #e8f1fb; --info-fg: #1d6fb8;
}

* { box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  margin: 0;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); text-decoration: underline; }

h1, h2, h3, h4 { color: var(--text); font-weight: 600; margin-top: 0; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
.text-muted { color: var(--text-muted) !important; }
.text-faint { color: var(--text-faint) !important; }

/* Layout shell */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1rem .75rem;
  display: flex; flex-direction: column;
}
.sidebar .brand {
  font-weight: 600;
  font-size: 15px;
  padding: .5rem .5rem 1rem;
  display: flex; align-items: center; gap: .5rem;
  color: var(--text);
}
.sidebar .brand .badge-2fa {
  font-size: 11px; font-weight: 500;
  background: var(--ok-bg); color: var(--ok-fg);
  padding: 2px 8px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 4px;
}
.sidebar .nav-link {
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: .5rem .75rem;
  display: flex; gap: .6rem; align-items: center;
  margin-bottom: 2px;
  font-size: 13.5px;
}
.sidebar .nav-link:hover {
  background: #f1f2f5;
  color: var(--text);
  text-decoration: none;
}
.sidebar .nav-link.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 500;
}
.sidebar .nav-link i { font-size: 18px; flex-shrink: 0; }

.main {
  display: flex; flex-direction: column;
  background: var(--bg);
}
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .75rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
}
.topbar .page-title { font-size: 16px; font-weight: 600; margin: 0; }
.topbar .topbar-right { display: flex; align-items: center; gap: 1rem; }
.topbar .user-chip {
  display: flex; align-items: center; gap: .5rem;
  font-size: 13px; color: var(--text-muted);
}
.topbar .avatar {
  width: 32px; height: 32px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px;
}
.topbar .lang-switch a {
  font-size: 12px; padding: 2px 6px; color: var(--text-muted);
}
.topbar .lang-switch a.active { color: var(--primary); font-weight: 500; }

.content { padding: 1.5rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: none;
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
  background: transparent; border-bottom: none; padding: 0;
}
.card-header h2 { margin: 0; }

.metric {
  background: #f1f2f5;
  border-radius: var(--radius-sm);
  padding: 1rem;
}
.metric .label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.metric .value { font-size: 24px; font-weight: 600; margin-top: 4px; }
.metric .sub { font-size: 12px; color: var(--text-faint); margin-top: 2px; }

.btn-primary {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
}
.btn-primary:hover {
  background: var(--primary-hover) !important;
  border-color: var(--primary-hover) !important;
}
.btn { border-radius: var(--radius-sm); font-size: 13.5px; }
.btn-sm { padding: .25rem .6rem; }
.btn-outline-secondary { border-color: var(--border-strong); color: var(--text); }
.btn-outline-secondary:hover { background: var(--bg); border-color: var(--border-strong); color: var(--text); }

.badge {
  font-weight: 500; font-size: 11.5px;
  padding: 3px 8px; border-radius: 999px;
}
.badge-ok    { background: var(--ok-bg);    color: var(--ok-fg); }
.badge-warn  { background: var(--warn-bg);  color: var(--warn-fg); }
.badge-danger{ background: var(--danger-bg); color: var(--danger-fg); }
.badge-info  { background: var(--info-bg);  color: var(--info-fg); }
.badge-muted { background: #ececef;         color: var(--text-muted); }

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { padding: .65rem .5rem; border-top: 1px solid var(--border); }
.table thead th {
  border-top: none; border-bottom: 1px solid var(--border);
  color: var(--text-muted); font-weight: 500; text-align: left; font-size: 12px;
  text-transform: uppercase; letter-spacing: .03em;
}
.table-hover tbody tr:hover { background: #fafbfc; }
.table .actions { white-space: nowrap; }

.breadcrumb {
  font-size: 12.5px; color: var(--text-muted);
  padding: 0; margin: 0 0 1rem; background: transparent;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb .sep { margin: 0 .35rem; color: var(--text-faint); }

.module-tile {
  display: flex; gap: .75rem; align-items: flex-start;
  padding: 1rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: inherit;
}
.module-tile:hover { border-color: var(--border-strong); text-decoration: none; color: inherit; }
.module-tile .icon-box {
  background: #f1f2f5; border-radius: var(--radius-sm);
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.module-tile .icon-box i { font-size: 22px; color: var(--text-muted); }
.module-tile .title { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.module-tile .meta { color: var(--text-muted); font-size: 12.5px; }

.week-pills {
  display: flex; gap: .4rem; flex-wrap: wrap; margin: 0 0 1rem;
}
.week-pills a {
  padding: .35rem .75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-muted);
  background: var(--surface);
}
.week-pills a.active {
  background: var(--primary); border-color: var(--primary); color: #fff;
}
.week-pills a:hover { text-decoration: none; }

.day-row { display: grid; grid-template-columns: 28px 110px 1fr 1fr; gap: .75rem; padding: .5rem 0; border-top: 1px solid var(--border); align-items: flex-start; }
.day-row:first-child { border-top: none; }
.day-row .day-no { font-weight: 600; color: var(--text-muted); }
.day-row .weekday { color: var(--text-muted); font-size: 12.5px; }

.progress { background: #ececef; border-radius: 999px; height: 6px; overflow: hidden; }
.progress-bar { background: var(--primary); height: 100%; }

.alert { border-radius: var(--radius-sm); border: 1px solid transparent; padding: .6rem .9rem; font-size: 13.5px; margin-bottom: 1rem; }
.alert-info    { background: var(--info-bg);    color: var(--info-fg);    border-color: rgba(29,111,184,.15); }
.alert-success { background: var(--ok-bg);      color: var(--ok-fg);      border-color: rgba(22,121,76,.15); }
.alert-warning { background: var(--warn-bg);    color: var(--warn-fg);    border-color: rgba(138,90,0,.15); }
.alert-danger  { background: var(--danger-bg);  color: var(--danger-fg);  border-color: rgba(180,35,24,.15); }

.form-control, .form-select, textarea {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
}
.form-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.form-text { font-size: 12px; color: var(--text-faint); }

.empty-state {
  text-align: center; padding: 2rem 1rem; color: var(--text-muted);
}
.empty-state i { font-size: 32px; color: var(--text-faint); margin-bottom: .5rem; display: block; }

/* Auth pages */
.auth-shell {
  min-height: 100vh;
  display: grid; place-items: center;
  background: var(--bg);
  padding: 1rem;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%; max-width: 420px;
}
.auth-card h1 { font-size: 20px; margin-bottom: .25rem; }
.auth-card .sub { color: var(--text-muted); margin-bottom: 1.5rem; font-size: 13.5px; }

/* Mobile */
@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .content { padding: 1rem; }
}
