
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface2: #f8f9fb;
  --border: #e2e6ed;
  --border2: #d0d6e0;
  --accent: #1a56db;
  --accent-light: #eff4ff;
  --accent3: #059669;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --warn: #d97706;
  --warn-light: #fffbeb;
  --text: #111827;
  --text2: #374151;
  --muted: #6b7280;
  --muted2: #9ca3af;
  --sidebar-bg: #1e2535;
  --sidebar-text: #cbd5e1;
  --sidebar-muted: #64748b;
  --sidebar-border: rgba(255,255,255,0.06);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'DM Sans', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; display: flex; overflow: hidden; }

/* LOGIN */
#login-screen { position: fixed; inset: 0; background: var(--sidebar-bg); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.login-card { background: #fff; border-radius: 16px; padding: 40px; width: 400px; box-shadow: 0 24px 80px rgba(0,0,0,0.3); }
.login-logo { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 18px; color: var(--accent); margin-bottom: 4px; }
.login-firm { font-size: 12px; color: var(--muted); margin-bottom: 32px; }
.login-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 20px; margin-bottom: 6px; }
.login-sub { font-size: 13px; color: var(--muted); margin-bottom: 24px; }
.login-label { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 5px; display: block; }
.login-input { width: 100%; background: var(--surface2); border: 1px solid var(--border2); border-radius: 8px; padding: 10px 14px; font-size: 13px; font-family: 'DM Sans', sans-serif; outline: none; transition: border-color 0.12s; margin-bottom: 16px; }
.login-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(26,86,219,0.1); }
.login-btn { width: 100%; background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 12px; font-size: 14px; font-weight: 600; font-family: 'DM Sans', sans-serif; cursor: pointer; transition: background 0.13s; margin-top: 4px; }
.login-btn:hover { background: #1648c0; }
.login-btn:disabled { background: var(--muted2); cursor: not-allowed; }
.login-error { background: var(--danger-light); border: 1px solid #fecaca; border-radius: 6px; padding: 10px 12px; font-size: 12px; color: var(--danger); margin-bottom: 16px; display: none; }
.pw-wrap { position: relative; margin-bottom: 16px; }
.pw-wrap .login-input { margin-bottom: 0; padding-right: 40px; }
.pw-toggle { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); cursor: pointer; color: var(--muted); font-size: 14px; user-select: none; }

/* SIDEBAR */
.sidebar { width: 224px; min-width: 224px; background: var(--sidebar-bg); display: flex; flex-direction: column; z-index: 100; }
.logo { padding: 20px 20px 18px; border-bottom: 1px solid var(--sidebar-border); }
.logo-mark { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 13px; color: #fff; letter-spacing: 0.02em; line-height: 1.3; }
.logo-sub { font-size: 9px; color: var(--sidebar-muted); letter-spacing: 0.1em; text-transform: uppercase; margin-top: 3px; }
.sidebar-section { padding: 14px 12px 6px; }
.sidebar-label { font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--sidebar-muted); padding: 0 8px; margin-bottom: 4px; }
.nav-item { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--sidebar-text); transition: all 0.13s; user-select: none; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-icon { font-size: 13px; width: 17px; text-align: center; }
.user-info { margin-top: auto; border-top: 1px solid var(--sidebar-border); padding: 14px 16px; display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0; }
.user-name { font-size: 12px; color: #fff; font-weight: 600; }
.user-role { font-size: 10px; color: var(--sidebar-muted); }
.logout-btn { margin-left: auto; font-size: 11px; color: var(--sidebar-muted); cursor: pointer; padding: 4px 6px; border-radius: 4px; }
.logout-btn:hover { color: #fff; background: rgba(255,255,255,0.08); }

/* MAIN */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar { height: 54px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 24px; gap: 12px; flex-shrink: 0; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
.topbar-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 15px; color: var(--text); flex: 1; }
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 10px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }
.badge-owner { background: #eff4ff; color: #1a56db; border: 1px solid #c7d7fa; }
.badge-manager { background: #ecfeff; color: #0e7490; border: 1px solid #a5f3fc; }
.badge-senior { background: #fdf4ff; color: #7e22ce; border: 1px solid #e9d5ff; }
.badge-employee { background: #f0fdf4; color: #059669; border: 1px solid #bbf7d0; }
.badge-hr { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }

.btn { padding: 7px 14px; border-radius: 6px; border: none; cursor: pointer; font-family: 'DM Sans', sans-serif; font-size: 12px; font-weight: 500; transition: all 0.13s; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #1648c0; }
.btn-ghost { background: var(--surface); color: var(--text2); border: 1px solid var(--border2); }
.btn-ghost:hover { border-color: var(--muted); }
.btn-sm { padding: 5px 11px; font-size: 11px; }

.content { flex: 1; overflow-y: auto; padding: 24px; background: var(--bg); }
.view { display: none; }
.view.active { display: block; }

/* EMPLOYEE CARDS */
.emp-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; margin-bottom: 24px; }
.emp-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 18px; cursor: pointer; transition: all 0.15s; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
.emp-card:hover { border-color: var(--accent); box-shadow: 0 4px 12px rgba(26,86,219,0.1); transform: translateY(-1px); }
.emp-avatar { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700; color: #fff; margin-bottom: 10px; }
.emp-name { font-weight: 700; font-size: 14px; color: var(--text); margin-bottom: 2px; }
.emp-role { font-size: 11px; color: var(--muted); margin-bottom: 12px; }
.score-bar-wrap { background: var(--surface2); border-radius: 4px; height: 6px; overflow: hidden; border: 1px solid var(--border); margin-bottom: 6px; }
.score-bar { height: 100%; border-radius: 4px; transition: width 0.4s; }
.score-label { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); }
.score-value { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 22px; }

/* SCORING PANEL */
.panel-overlay { position: fixed; inset: 0; background: rgba(15,23,42,0.3); z-index: 200; display: none; align-items: flex-start; justify-content: flex-end; }
.panel-overlay.open { display: flex; }
.detail-panel { width: 580px; height: 100vh; background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; animation: slideIn 0.2s ease; box-shadow: -4px 0 24px rgba(0,0,0,0.08); }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.panel-header { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; background: var(--surface2); }
.panel-body { flex: 1; overflow-y: auto; padding: 20px; }
.close-btn { width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--border2); background: var(--surface); color: var(--muted); cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; }
.close-btn:hover { color: var(--text); }

/* MONTH TABS */
.month-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 20px; }
.month-tab { padding: 5px 12px; border-radius: 20px; font-size: 11px; font-weight: 500; cursor: pointer; border: 1px solid var(--border); background: var(--surface2); color: var(--muted); transition: all 0.13s; }
.month-tab:hover { border-color: var(--accent); color: var(--accent); }
.month-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.month-tab.scored { border-color: var(--accent3); color: var(--accent3); background: #f0fdf4; }
.month-tab.active.scored { background: var(--accent3); border-color: var(--accent3); color: #fff; }

/* SCORING TABLE */
.score-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.score-table thead th { padding: 10px 12px; text-align: left; font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--border); background: var(--surface2); }
.score-table tbody tr { border-bottom: 1px solid var(--border); }
.score-table tbody tr:last-child { border-bottom: none; }
.score-table tbody td { padding: 10px 12px; font-size: 13px; vertical-align: middle; }
.score-input { width: 60px; background: var(--surface2); border: 1px solid var(--border2); border-radius: 6px; padding: 5px 8px; font-size: 13px; font-family: 'DM Mono', monospace; text-align: center; outline: none; transition: border-color 0.12s; }
.score-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(26,86,219,0.1); }
.score-input:disabled { background: var(--surface2); color: var(--muted); cursor: not-allowed; }
.weightage-chip { display: inline-block; padding: 2px 7px; border-radius: 4px; font-size: 10px; font-family: 'DM Mono', monospace; background: var(--accent-light); color: var(--accent); border: 1px solid #c7d7fa; font-weight: 600; }

/* ANNUAL SUMMARY */
.annual-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-bottom: 20px; }
.annual-card { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 14px; text-align: center; }
.annual-card-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 6px; font-weight: 600; }
.annual-card-value { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 24px; }

/* MISC */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--surface2); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
.loading-spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; padding: 32px; color: var(--muted); font-size: 13px; }
.empty-icon { font-size: 32px; margin-bottom: 8px; }
.section-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 15px; color: var(--text); margin-bottom: 16px; }
.form-input, .form-select { width: 100%; background: var(--surface); border: 1px solid var(--border2); border-radius: 7px; padding: 8px 12px; color: var(--text); font-size: 13px; font-family: 'DM Sans', sans-serif; outline: none; transition: border-color 0.12s; }
.form-input:focus, .form-select:focus { border-color: var(--accent); }

/* WIDE TABLES (Annual Summary, Scoring Status) — scroll sideways, keep name column pinned */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.grid-table { width: 100%; border-collapse: collapse; min-width: 780px; }
.grid-table th:first-child, .grid-table td:first-child { position: sticky; left: 0; z-index: 1; box-shadow: 1px 0 0 var(--border); }
.grid-table td:first-child { background: var(--surface); }
.swipe-hint { display: none; font-size: 11px; color: var(--muted2); margin: -4px 0 8px; }

/* MOBILE */
@media (max-width: 768px) {
  body { overflow: hidden; }
  #app { flex-direction: column !important; height: 100dvh !important; }

  /* login / access-denied cards fit the screen */
  .login-card { width: calc(100vw - 32px); max-width: 400px; padding: 28px 22px; }
  .login-input { font-size: 16px; } /* stops iOS zooming into the field */
  #access-denied-screen > div { width: calc(100vw - 32px) !important; padding: 32px 22px !important; }

  /* sidebar becomes a compact top bar: logo + user on row 1, scrollable tabs on row 2 */
  .sidebar { width: 100%; min-width: 0; flex-direction: row; flex-wrap: wrap; align-items: center; flex-shrink: 0; }
  .logo { padding: 10px 14px; border-bottom: none; flex: 1; min-width: 0; }
  .logo-mark { font-size: 12px; }
  .logo-sub { display: none; }
  .user-info { order: 2; margin-top: 0; border-top: none; padding: 8px 12px; gap: 8px; }
  .user-info .user-name, .user-info .user-role { display: none; }
  .user-avatar { width: 28px; height: 28px; font-size: 11px; }
  .logout-btn { font-size: 16px; padding: 6px 8px; }
  .sidebar-section { order: 3; width: 100%; display: flex; gap: 6px; overflow-x: auto; padding: 6px 10px 10px; border-top: 1px solid var(--sidebar-border); -webkit-overflow-scrolling: touch; }
  .sidebar-label { display: none; }
  .nav-item { white-space: nowrap; flex: 1 0 auto; justify-content: center; gap: 5px; padding: 8px 9px; font-size: 12px; }
  .nav-icon { width: auto; font-size: 12px; }
  .sidebar-section { gap: 4px; }

  /* wide tables: slimmer pinned name column, show the swipe hint */
  .grid-table th:first-child, .grid-table td:first-child { padding-left: 12px !important; padding-right: 8px !important; min-width: 118px; max-width: 132px; }
  .grid-table td:first-child > div:first-child { font-size: 12px !important; }
  .swipe-hint { display: block; }

  /* top bar: title + badge, then year/month selectors */
  .topbar { height: auto; flex-wrap: wrap; padding: 10px 14px; gap: 8px; }
  .topbar-title { flex: 1 1 auto; font-size: 14px; }
  .topbar .badge { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; order: 3; flex: 1 0 100%; text-align: center; }
  .topbar > div:last-child { order: 2; }
  .form-select { font-size: 16px !important; } /* iOS zoom guard */

  .content { padding: 14px; }
  .emp-grid { grid-template-columns: 1fr; gap: 10px; }
  .emp-card { padding: 14px 16px; }
  .annual-grid { grid-template-columns: 1fr; }

  /* scoring panel goes full screen */
  .detail-panel { width: 100%; max-width: 100%; height: 100dvh; border-left: none; }
  .panel-body { padding: 14px; }
  .month-tab { padding: 6px 11px; }
  .score-table thead th, .score-table tbody td { padding: 9px 6px; }
  .score-input { width: 52px; font-size: 16px; }
}

/* ===== Compatibility layer: this version's markup, drawn in the live look ===== */
:root { --radius: 10px; }
body { display: block; }
#app { display: flex; width: 100%; height: 100vh; overflow: hidden; }
h1, h2, h3, h4 { font-family: 'Syne', sans-serif; font-weight: 700; }
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
.hint { color: var(--muted); font-size: 12px; margin-top: 2px; }
.btn { border: 1px solid var(--border2); background: var(--surface); color: var(--text2); }
.btn:hover { border-color: var(--muted); }
.btn-primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.btn-primary:hover { background: #1648c0; }

/* login */
.login-screen { position: fixed; inset: 0; background: var(--sidebar-bg); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.login-card { text-align: left; }
.login-card .login-logo-img { display: block; height: 44px; max-width: 100%; margin: 0 auto 18px; object-fit: contain; }
.login-card h1 { font-size: 20px; margin-bottom: 6px; }
.login-card .hint { margin-bottom: 22px; font-size: 13px; }
.login-card .field label { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.field input { width: 100%; background: var(--surface2); border: 1px solid var(--border2); border-radius: 8px; padding: 10px 14px; font-size: 13px; font-family: inherit; outline: none; }
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(26,86,219,.1); }
.login-card .btn-primary { padding: 12px; font-size: 14px; font-weight: 600; border-radius: 8px; }

/* sidebar */
.logo img { display: block; max-width: 100%; height: 36px; object-fit: contain; object-position: left; background: #fff; border-radius: 6px; padding: 4px 6px; }
.sidebar .user-info { gap: 8px; }
.sidebar .user-info .who { min-width: 0; flex: 1; }
.sidebar .user-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-icon { font-size: 15px; }

/* top bar */
.topbar h2.topbar-title { margin: 0; }
.topbar-tools { display: flex; gap: 6px; align-items: center; }
.filter-select { background: var(--surface); border: 1px solid var(--border2); border-radius: 6px; padding: 6px 10px; font-size: 12px; font-family: inherit; color: var(--text2); outline: none; }
.filter-select:focus { border-color: var(--accent); }
.topbar .role-badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 10px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; white-space: nowrap; }

/* overview groups */
.emp-group-title { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; padding-bottom: 8px; margin: 4px 0 12px; border-bottom: 1px solid var(--border); }
.emp-card .score-note { font-size: 11px; color: var(--muted2); margin-top: 4px; }
.emp-card .score-month { font-size: 10px; color: var(--muted2); margin-top: 6px; }
.empty-state .hint { margin-top: 6px; }

/* KPI tiles (My Rating) */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.kpi-card .label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; margin-bottom: 4px; }
.kpi-card .value { font-size: 24px; font-weight: 800; font-family: 'Syne', sans-serif; }

/* sections, tables */
.section { margin-bottom: 18px; }
.section h4 { font-size: 13px; }
.section-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 15px; margin-bottom: 8px; }
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: auto; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table-wrap th { text-align: left; padding: 10px 12px; background: var(--surface2); border-bottom: 1px solid var(--border); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.table-wrap td { padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table-wrap tbody tr:last-child td { border-bottom: none; }
.table-wrap td.num, .table-wrap th.num { text-align: right; }
.table-wrap tbody tr[data-open] { cursor: pointer; }
.table-wrap tbody tr[data-open]:hover td { background: var(--surface2); }
.grid-table th:first-child { background: var(--surface2); }
.scoring-table { min-width: 0; }
.scoring-table:not(.editable) td.num { color: var(--muted); }
.status-cell { font-family: 'DM Mono', monospace; font-weight: 600; }
.status-done { background: #ecfdf5; color: #065f46; }
.status-partial { background: var(--warn-light); color: var(--warn); }
.status-none { background: var(--danger-light); color: var(--danger); }
.status-future { color: var(--muted2); }

/* panel */
.detail-panel-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.3); z-index: 200; display: flex; align-items: flex-start; justify-content: flex-end; }
.panel-header h3 { font-size: 16px; margin: 0; }
.composite-box { display: flex; align-items: center; justify-content: space-between; font-family: 'Syne', sans-serif; font-size: 28px; font-weight: 800; border: 2px solid; border-radius: 10px; padding: 12px 18px; margin-bottom: 16px; background: var(--surface); }
.composite-box small { font-family: 'DM Sans', sans-serif; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.lock-msg { color: var(--muted); font-size: 12.5px; padding: 8px 0 14px; }
.month-tabs .tab { padding: 5px 12px; border-radius: 20px; font-size: 11px; font-weight: 500; cursor: pointer; border: 1px solid var(--border); background: var(--surface2); color: var(--muted); }
.month-tabs .tab:hover { border-color: var(--accent); color: var(--accent); }
.month-tabs .tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.month-tabs .tab.scored { border-color: var(--accent3); color: var(--accent3); background: #f0fdf4; }
.month-tabs .tab.active.scored { background: var(--accent3); border-color: var(--accent3); color: #fff; }
.month-tabs.tab-strip { margin-bottom: 16px; }

/* modal + toast */
.overlay { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; z-index: 500; }
.modal { background: var(--surface); border-radius: 12px; width: 480px; max-width: calc(100vw - 32px); max-height: calc(100vh - 48px); overflow: auto; padding: 22px; }
.modal h3 { margin-bottom: 12px; }
.toast-stack { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 900; }
.toast { background: var(--text); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13px; box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.toast.error { background: var(--danger); }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 11px; font-weight: 700; flex-shrink: 0; }

/* My Rating */
.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 90px; padding: 10px 0; }
.bar-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; flex: 1; height: 100%; }
.bar { width: 100%; max-width: 22px; border-radius: 3px 3px 0 0; min-height: 2px; }
.bar-label { font-size: 10px; color: var(--muted); margin-top: 4px; }
.activity-item { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 12.5px; }

/* phone bar + More sheet */
#mobile-nav { display: none; }
.mobile-nav-item { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--sidebar-text); cursor: pointer; }
.mobile-nav-item.active { color: #fff; background: rgba(26,86,219,.35); }
#more-sheet-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 600; display: flex; align-items: flex-end; }
#more-sheet { background: var(--surface); width: 100%; border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px)); animation: slideUp .22s ease; }
#more-sheet h3 { font-size: 14px; margin: 0 0 12px; }
.more-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.more-grid-item { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 6px; border: 1px solid var(--border); border-radius: 10px; font-size: 11px; font-weight: 600; color: var(--text2); text-align: center; cursor: pointer; background: var(--surface2); }
.more-grid-item .nav-icon { font-size: 22px; width: auto; }
.more-grid-item.active { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
@keyframes slideUp { from { transform: translateY(60px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

@media (max-width: 768px) {
  #app { flex-direction: column; }
  /* phone: the sidebar goes; logo bar on top, icon bar at the bottom */
  .sidebar { display: none; }
  .phone-head { display: flex; align-items: center; gap: 10px; background: var(--sidebar-bg); padding: 8px 14px; flex-shrink: 0; }
  .phone-head img { height: 28px; background: #fff; border-radius: 5px; padding: 3px 5px; }
  #mobile-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--sidebar-bg); padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px)); z-index: 150; border-top: 1px solid var(--sidebar-border); }
  #mobile-nav .mobile-nav-item { flex: 1 1 0; min-width: 0; padding: 6px 2px; font-size: 10px; border-radius: 8px; }
  #mobile-nav .mobile-nav-item .nav-icon { font-size: 19px; width: auto; }
  .main { min-height: 0; }
  .topbar-tools { order: 2; }
  .topbar-tools .filter-select { font-size: 16px; padding: 7px 10px; }
  .content { padding: 12px 12px 84px; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .detail-panel { max-width: 100%; height: 100dvh; }
  .detail-panel .panel-header { padding-top: 14px; }
  .close-btn { width: 36px; height: 36px; }
  .field input { font-size: 16px; }
  .topbar .role-badge { flex: 1 0 100%; text-align: center; display: block; }
}
@media (min-width: 769px) { #mobile-nav, .phone-head { display: none; } }

/* line icons */
.icon { display: block; flex-shrink: 0; }
.nav-icon { display: inline-flex; align-items: center; justify-content: center; }
.logout-btn { display: inline-flex; align-items: center; }

/* ===== phone: bigger tap areas, folding filters, full-screen details with a Back link ===== */
.fb-toggle { display: none; }
@media (max-width: 768px) {
  .fb-toggle { display: inline-flex; align-items: center; justify-content: center; width: 100%; height: 40px; font-weight: 600; }
  .filter-bar.fb-collapsed > *:not(.fb-toggle):not([type=search]) { display: none !important; }
  .btn, .btn-sm { min-height: 40px; }
  .nav-item, .more-grid-item { min-height: 44px; }
  select, .filter-select, .form-select, input[type=text], input[type=search], input[type=date], input[type=number] { min-height: 40px; font-size: 16px; }
  table td, table th { padding-top: 12px; padding-bottom: 12px; }
  .tab, .tabs .tab { padding-top: 12px; padding-bottom: 12px; }
  /* detail panels: whole screen, Back link on top-left instead of a small cross */
  .detail-panel { width: 100vw !important; max-width: 100vw; height: 100dvh !important; max-height: 100dvh !important; border-radius: 0 !important; }
  .detail-panel::before { display: none !important; }
  .detail-panel .panel-header { padding-top: 14px; flex-direction: row-reverse; justify-content: flex-end; gap: 12px; align-items: center; }
  .detail-panel .panel-header .close-btn, .detail-panel .panel-header [data-action=close-panel], .detail-panel .panel-header #panel-close {
    width: auto !important; height: 40px !important; padding: 0 14px; border-radius: 20px; font-size: 0 !important; display: inline-flex; align-items: center; flex-shrink: 0;
  }
  .detail-panel .panel-header .close-btn::before, .detail-panel .panel-header [data-action=close-panel]::before, .detail-panel .panel-header #panel-close::before { content: '‹ Back'; font-size: 14px; font-weight: 600; color: var(--accent); }
}

.kpi-link { cursor: pointer; transition: all .15s; }
.kpi-link:hover { border-color: var(--accent); box-shadow: 0 4px 12px rgba(26,86,219,.1); }
.kpi-card.kpi-selected { outline: 2px solid var(--accent); outline-offset: -1px; }
.section h4 { font-size: 13px; line-height: 2; margin-bottom: 8px; }
.section + .section, .table-wrap + .section { margin-top: 18px; }

/* ===== phone: tables become cards ===== */
@media (max-width: 768px) {
  table.rt-cards { min-width: 0 !important; width: 100%; border-collapse: separate; border-spacing: 0; }
  table.rt-cards thead { display: none; }
  table.rt-cards tbody { display: block; }
  table.rt-cards tr { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; margin: 0 0 10px; padding: 10px 14px; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
  table.rt-cards td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0 !important; border: none !important; white-space: normal !important; text-align: right; min-height: 0; background: transparent !important; }
  table.rt-cards td:first-child { display: block; text-align: left; font-weight: 700; font-size: 15px; padding: 2px 0 8px !important; margin-bottom: 4px; border-bottom: 1px solid var(--border) !important; position: static; box-shadow: none; }
  table.rt-cards td::before { content: attr(data-label); font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); text-align: left; flex-shrink: 0; }
  table.rt-cards td:first-child::before { content: none; }
  table.rt-cards td.rt-empty { display: none; }
  table.rt-cards td.rt-span { display: block; text-align: center; }
  table.rt-cards td.rt-span::before { content: none; }
  .table-wrap:has(table.rt-cards), .table-scroll:has(table.rt-cards), .card:has(> table.rt-cards) { background: transparent; border: none; box-shadow: none; overflow: visible; }
}
@media (max-width: 768px) {
  table.rt-cards td.rt-lead { display: none; }
  table.rt-cards td.rt-title { display: block; text-align: left; font-weight: 700; font-size: 15px; padding: 2px 0 8px !important; margin-bottom: 4px; border-bottom: 1px solid var(--border) !important; }
  table.rt-cards td.rt-title::before { content: none; }
}

/* PES Setup (owner) */
.setup-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.setup-h { margin: 22px 0 6px; font-size: 15px; }
.setup-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin: 10px 0; }
.setup-card-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; align-items: flex-start; }
.setup-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.setup-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.setup-table th, .setup-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.setup-table th { background: var(--surface2); font-weight: 600; color: var(--muted); font-size: 11px; text-transform: uppercase; }
.setup-total { margin-top: 8px; font-size: 12px; font-weight: 600; }
.setup-total.good { color: #059669; } .setup-total.bad { color: #dc2626; }
.setup-check { display: inline-flex; gap: 8px; align-items: center; min-height: 32px; }
