:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --border: #e3e7ef;
  --text: #1f2430;
  --text-muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --blue: #2563eb;
  --grey: #9ca3af;
  --sidebar-bg: #111827;
  --sidebar-text: #cbd5e1;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* Auth screens */
.auth-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e293b, #0f172a);
}
.auth-card {
  background: var(--surface);
  padding: 36px 40px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 360px;
}
.auth-card h1 {
  font-size: 20px; margin: 0 0 4px 0;
  display: flex; align-items: center; gap: 10px;
  color: var(--primary);
}
.auth-sub { color: var(--text-muted); margin: 0 0 20px 0; font-size: 13px; }
.auth-card label { display: block; margin: 12px 0 4px; font-weight: 600; font-size: 12.5px; }
.auth-card input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 8px; outline: none;
}
.auth-card input:focus { border-color: var(--primary); }
.auth-error {
  background: #fef2f2; color: var(--red); padding: 8px 10px;
  border-radius: 8px; font-size: 12.5px; margin-top: 14px;
}
.btn-block { width: 100%; margin-top: 20px; }

/* Buttons */
.btn {
  border: none; border-radius: 8px; padding: 9px 16px; font-size: 13.5px;
  font-weight: 600; display: inline-flex; align-items: center; gap: 6px;
  transition: background .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: #eef1f6; color: var(--text); }
.btn-ghost:hover { background: #e2e6ee; }
.btn-danger { background: #fee2e2; color: var(--red); }
.btn-danger:hover { background: #fecaca; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.icon-btn {
  background: transparent; border: none; color: var(--text-muted);
  font-size: 16px; padding: 8px; border-radius: 8px;
}
.icon-btn:hover { background: #eef1f6; color: var(--text); }

/* App shell layout */
.app-shell { display: flex; height: 100vh; }
.sidebar {
  width: 230px; background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.sidebar-brand {
  padding: 20px 18px; font-weight: 700; font-size: 15px; color: #fff;
  display: flex; align-items: center; gap: 10px; border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand i { color: var(--primary); }
.sidebar-nav { display: flex; flex-direction: column; padding: 10px; gap: 2px; overflow-y: auto; }
.nav-link {
  color: var(--sidebar-text); text-decoration: none; padding: 10px 12px;
  border-radius: 8px; font-size: 13.5px; display: flex; align-items: center; gap: 10px;
}
.nav-link i { width: 16px; text-align: center; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.active { background: var(--primary); color: #fff; }

.main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 60px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 22px; flex-shrink: 0;
}
.topbar-title { font-size: 17px; font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.user-menu { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-muted); }

.content { flex: 1; overflow-y: auto; padding: 22px; }
.page { max-width: 1400px; }

/* Dashboard hero */
.dash-hero {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  margin-bottom: 18px; flex-wrap: wrap;
}
.dash-hero-text h2 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.dash-hero-text p { margin: 4px 0 0; color: var(--text-muted); font-size: 13px; }
.dash-hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* KPI cards */
.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px; margin-bottom: 20px;
}
.kpi-card {
  background: var(--surface); border-radius: 14px; padding: 16px;
  box-shadow: var(--shadow); border: 1px solid var(--border);
  display: flex; align-items: flex-start; gap: 13px;
  transition: box-shadow .16s ease, transform .16s ease, border-color .16s ease;
  --kpi-accent: var(--primary);
  --kpi-accent-soft: #dbeafe;
}
.kpi-card .kpi-icon {
  width: 40px; height: 40px; border-radius: 11px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--kpi-accent-soft); color: var(--kpi-accent); font-size: 16px;
}
.kpi-card .kpi-body { min-width: 0; }
.kpi-card .kpi-label { font-size: 11.5px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi-card .kpi-value { font-size: 25px; font-weight: 700; margin-top: 3px; line-height: 1.15; letter-spacing: -.02em; }
.kpi-card .kpi-meta { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.kpi-card.kpi-warn { --kpi-accent: var(--amber); --kpi-accent-soft: #fef3c7; }
.kpi-card.kpi-danger { --kpi-accent: var(--red); --kpi-accent-soft: #fee2e2; }
.kpi-card.kpi-ok { --kpi-accent: var(--green); --kpi-accent-soft: #dcfce7; }
.kpi-card.kpi-clickable { cursor: pointer; }
.kpi-card.kpi-clickable:hover {
  box-shadow: 0 6px 16px rgba(16,24,40,.10); transform: translateY(-2px); border-color: #d3d9e6;
}

/* Dashboard panels */
.panel-card h3 { display: flex; align-items: center; gap: 8px; }
.panel-list-item-click { cursor: pointer; border-radius: 8px; margin: 0 -8px; padding: 8px; }
.panel-list-item-click:hover { background: var(--bg); }

.readonly-note {
  margin-right: auto; display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--text-muted); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px;
}

/* Cards / charts */
.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 20px;
}
.card h3 { margin: 0 0 12px 0; font-size: 14px; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; }
.chart-card canvas { max-height: 260px; }

/* Toolbar / search */
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.search-box {
  display: flex; align-items: center; gap: 8px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; flex: 1; max-width: 420px;
}
.search-box input { border: none; background: transparent; outline: none; width: 100%; }
.search-box i { color: var(--text-muted); }
.toolbar-actions { display: flex; gap: 8px; }

/* Table */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; padding: 10px 12px; background: var(--bg); color: var(--text-muted);
  font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .02em;
  border-bottom: 1px solid var(--border);
}
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table tr:hover td { background: #fafbff; }
.row-actions { display: flex; gap: 4px; }
.empty-state { text-align: center; padding: 40px; color: var(--text-muted); }

/* Badges */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
}
.badge-green { background: #dcfce7; color: #15803d; }
.badge-amber { background: #fef3c7; color: #b45309; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-grey { background: #f1f5f9; color: #475569; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.5);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal {
  background: var(--surface); border-radius: var(--radius); width: 640px; max-width: 100%;
  max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 40px rgba(0,0,0,.2);
}
.modal-sm { width: 420px; }
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 16px; margin: 0; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-footer {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-field-wide { grid-column: 1 / -1; }
.form-field label { display: block; font-weight: 600; font-size: 12px; margin-bottom: 5px; }
.form-field input, .form-field select, .form-field textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; outline: none;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: var(--primary); }
.input-with-btn { display: flex; gap: 6px; }
.input-with-btn input { flex: 1; }

/* Toast */
.toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: #1f2430; color: #fff; padding: 12px 18px; border-radius: 8px;
  font-size: 13px; box-shadow: 0 8px 20px rgba(0,0,0,.2);
  animation: toast-in .2s ease-out;
}
.toast.toast-error { background: var(--red); }
.toast.toast-success { background: var(--green); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Tasks tab bar */
.tabbar { display: flex; gap: 4px; margin-bottom: 16px; flex-wrap: wrap; }
.tab-btn {
  background: var(--surface); border: 1px solid var(--border); padding: 8px 14px;
  border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--text-muted);
  display: inline-flex; align-items: center; gap: 6px;
}
.tab-btn:hover { background: #f1f5f9; }
.tab-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Books review completion checklist and progress bars */
.books-checklist {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 8px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px;
}
.books-checklist label {
  display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; cursor: pointer;
}
.books-checklist input { width: auto; }

.progress-bar {
  position: relative; height: 16px; min-width: 90px; border-radius: 999px;
  background: #e5e9f2; overflow: hidden;
}
.progress-bar span {
  position: absolute; inset: 0 auto 0 0; background: var(--primary); border-radius: 999px;
}
.progress-bar.is-done span { background: var(--green); }
.progress-bar em {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 700; font-style: normal; color: #1f2430;
}

.completed-summary {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d;
  border-radius: 8px; padding: 9px 14px; margin-bottom: 14px; font-size: 13px;
}

/* Completed Work sits apart from the live category tabs */
.tab-btn-completed { margin-left: 10px; border-color: #bbf7d0; color: #15803d; }
.tab-btn-completed:hover { background: #f0fdf4; }
.tab-btn-completed.active { background: var(--green); border-color: var(--green); color: #fff; }
.tab-btn-completed.active .badge { background: rgba(255,255,255,.22); color: #fff; }

/* Dropdown filter panel */
.dropdown-wrap { position: relative; }
.dropdown-panel {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 20; min-width: 260px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow); padding: 10px; max-height: 320px; overflow-y: auto;
}
.dropdown-panel .filter-group-label {
  font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase;
  margin: 8px 0 4px; letter-spacing: .03em;
}
.dropdown-panel label {
  display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 4px 2px; cursor: pointer;
}
.dropdown-panel input[type="checkbox"] { width: auto; }

.bulk-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #fff7ed; border: 1px solid #fed7aa; border-radius: 8px; padding: 10px 14px; margin-bottom: 14px;
  font-size: 13px; font-weight: 600;
}

/* Task modal (wide, two-column with discussion panel) */
.modal-lg { width: 900px; }
.task-modal-body { display: flex; gap: 20px; padding: 0; }
.task-form-col { flex: 1.4; padding: 20px; overflow-y: auto; max-height: 65vh; }
.task-discussion-col {
  flex: 1; border-left: 1px solid var(--border); padding: 20px; display: flex; flex-direction: column;
  max-height: 65vh;
}
.task-discussion-col h3 { margin: 0 0 12px 0; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.discussion-feed { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.discussion-empty { color: var(--text-muted); font-size: 12.5px; text-align: center; padding: 20px 0; }
.comment-bubble { background: var(--bg); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; position: relative; }
.comment-bubble .comment-meta { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 3px; color: var(--text-muted); font-size: 11px; }
.comment-bubble .comment-delete { cursor: pointer; color: var(--red); }
.discussion-input { display: flex; flex-direction: column; gap: 6px; }
.discussion-input textarea { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 8px; font-size: 13px; resize: vertical; }

/* Notes */
.notes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.note-card {
  background: var(--surface); border-radius: 8px; border-left: 5px solid #fde68a;
  padding: 14px; box-shadow: var(--shadow); cursor: pointer; display: flex; flex-direction: column; gap: 6px;
  min-height: 120px;
}
.note-card:hover { box-shadow: 0 4px 10px rgba(16,24,40,.12); }
.note-card .note-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; }
.note-card .note-card-title { font-weight: 700; font-size: 14px; }
.note-card .note-card-body { font-size: 12.5px; color: var(--text-muted); white-space: pre-wrap; overflow: hidden; flex: 1; }
.note-card .note-card-footer { font-size: 11px; color: var(--text-muted); display: flex; justify-content: space-between; }
.note-card .pin-icon { color: var(--amber); }

.color-swatch-picker { display: flex; gap: 8px; margin-top: 4px; }
.color-swatch-option {
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer; border: 2px solid transparent;
}
.color-swatch-option.selected { border-color: var(--text); }

/* Invoices */
.sortable { cursor: pointer; user-select: none; }
.sortable:hover { color: var(--text); }
.sortable .sort-arrow { margin-left: 4px; font-size: 10px; }

.invoice-summary { max-width: 360px; margin-left: auto; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.invoice-summary-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13.5px; }
.invoice-summary-total { font-weight: 700; font-size: 15px; border-top: 1px solid var(--border); margin-top: 4px; padding-top: 8px; }
#invoice-items-tbody input { width: 100%; border: 1px solid var(--border); border-radius: 6px; padding: 5px 8px; font-size: 13px; }
#invoice-items-tbody td { padding: 4px 6px; }

.status-btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.status-btn-grid .btn { justify-content: center; }
.calendar-day.att-present { background: #dcfce7; }
.calendar-day.att-absent { background: #fee2e2; }
.calendar-day.att-half-day { background: #fef3c7; }
.calendar-day.att-leave { background: #dbeafe; }
.calendar-day.att-holiday { background: #f1f5f9; }
.calendar-day .att-status-label { font-size: 10px; font-weight: 700; margin-top: 2px; }

/* Notifications */
.notif-wrap { position: relative; }
.notif-badge {
  position: absolute; top: 2px; right: 2px; background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700; border-radius: 999px; min-width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center; padding: 0 3px; line-height: 1;
}
.notif-panel {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 50; width: 340px; max-height: 420px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 28px rgba(16,24,40,.16); display: flex; flex-direction: column; overflow: hidden;
}
.notif-panel-header {
  display: flex; justify-content: space-between; align-items: center; padding: 12px 14px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.notif-panel-header h3 { margin: 0; font-size: 14px; }
.notif-list { overflow-y: auto; flex: 1; }
.notif-item {
  display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border);
  cursor: pointer; align-items: flex-start;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: #eff6ff; }
.notif-item .notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-top: 5px; flex-shrink: 0; }
.notif-item.read .notif-dot { background: transparent; }
.notif-item-body { flex: 1; min-width: 0; }
.notif-item-message { font-size: 13px; line-height: 1.4; }
.notif-item-meta { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

.mono { font-family: "SF Mono", Consolas, monospace; font-size: 12.5px; }
.external-link-btn { color: var(--text-muted); }
.external-link-btn:hover { color: var(--primary); }

/* Calendar */
.calendar-nav { display: flex; align-items: center; gap: 6px; }
.calendar-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 6px;
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); text-align: center;
}
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.calendar-day {
  min-height: 96px; border: 1px solid var(--border); border-radius: 8px; padding: 6px;
  cursor: pointer; display: flex; flex-direction: column; gap: 3px;
}
.calendar-day:hover { border-color: var(--primary); }
.calendar-day.empty { background: transparent; border: none; cursor: default; }
.calendar-day.non-working { background: #f8fafc; }
.calendar-day .day-number { font-size: 12.5px; font-weight: 700; color: var(--text-muted); }
.calendar-day.today .day-number { color: var(--primary); }
.calendar-chip {
  font-size: 10.5px; padding: 2px 5px; border-radius: 4px; color: #fff; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.calendar-more { font-size: 10.5px; color: var(--text-muted); font-weight: 600; }

/* Quick panels */
.panel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; margin-top: 20px; }
.panel-list { display: flex; flex-direction: column; gap: 10px; }
.panel-list-item { display: flex; justify-content: space-between; align-items: center; font-size: 13px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.panel-list-item:last-child { border-bottom: none; padding-bottom: 0; }
.panel-list-item .item-title { font-weight: 600; }
.panel-list-item .item-sub { color: var(--text-muted); font-size: 12px; }

/* Settings sub-tabs */
.subtabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.subtab-btn {
  background: transparent; border: none; padding: 10px 16px; font-size: 13.5px; font-weight: 600;
  color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.subtab-btn:hover { color: var(--text); }
.subtab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.subtab-pane.hidden { display: none; }

.hint-box {
  background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af;
  padding: 10px 12px; border-radius: 8px; font-size: 12.5px;
}

.color-swatch { display: inline-block; width: 16px; height: 16px; border-radius: 4px; vertical-align: middle; margin-right: 6px; border: 1px solid rgba(0,0,0,.1); }

.permissions-table th, .permissions-table td { text-align: center; }
.permissions-table td:first-child, .permissions-table th:first-child { text-align: left; }

.pan-result-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px;
}

/* ============================================================
   Mobile / tablet — the app is used from phones on the office
   LAN, so the desktop shell collapses into a drawer + stacked
   layout below 900px.
   ============================================================ */
.nav-toggle, .sidebar-close { display: none; }
.sidebar-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 110; }

@media (max-width: 900px) {
  .app-shell { height: 100vh; height: 100dvh; }

  .nav-toggle { display: inline-flex; margin-right: 2px; }
  .sidebar-close { display: inline-flex; margin-left: auto; color: #94a3b8; }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; width: 270px; z-index: 120;
    transform: translateX(-100%); transition: transform .22s ease;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 44px rgba(0,0,0,.45); }
  .sidebar-nav { padding-bottom: 24px; }
  .nav-link { padding: 13px 12px; font-size: 14.5px; }

  .topbar { padding: 0 12px; gap: 6px; height: 56px; }
  .topbar-title { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-actions { gap: 6px; margin-left: auto; }
  .content { padding: 14px; }

  /* Tap targets */
  .icon-btn { min-width: 40px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
  .btn { padding: 10px 14px; }

  /* Filter/tab strips scroll instead of wrapping into tall stacks */
  .tabbar, .subtabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tabbar::-webkit-scrollbar, .subtabs::-webkit-scrollbar { display: none; }
  .tab-btn, .subtab-btn { flex-shrink: 0; }

  .table-wrap { -webkit-overflow-scrolling: touch; }
  .toolbar { align-items: stretch; }
  .search-box { max-width: none; }
  .toolbar-actions { flex-wrap: wrap; }
  .toolbar-actions .btn, .toolbar-actions select, .toolbar-actions input { flex: 1 1 auto; }

  .chart-grid { grid-template-columns: 1fr; }
  .panel-grid { grid-template-columns: 1fr; gap: 14px; }
  .notif-panel { width: calc(100vw - 24px); right: -6px; }
}

@media (max-width: 700px) {
  html, body { font-size: 14px; }

  /* 16px keeps iOS Safari from zooming when a field is focused */
  input, select, textarea,
  .form-field input, .form-field select, .form-field textarea,
  .search-box input, .auth-card input { font-size: 16px; }

  .auth-card { width: 100%; max-width: 400px; margin: 16px; padding: 28px 24px; }

  .dash-hero-text h2 { font-size: 19px; }
  .dash-hero-actions { width: 100%; }
  .dash-hero-actions .btn { flex: 1; justify-content: center; }

  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-card { padding: 13px; gap: 10px; border-radius: 12px; }
  .kpi-card .kpi-icon { width: 34px; height: 34px; font-size: 14px; border-radius: 9px; }
  .kpi-card .kpi-value { font-size: 20px; }
  .kpi-card .kpi-meta { display: none; }

  .card { padding: 14px; margin-bottom: 14px; }

  /* Modals become bottom sheets */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal, .modal-sm, .modal-lg { width: 100%; max-width: 100%; max-height: 94vh; border-radius: 16px 16px 0 0; }
  .modal-body { padding: 16px; }
  .modal-header, .modal-footer { padding: 14px 16px; }
  .modal-footer { flex-wrap: wrap; }
  .modal-footer .btn { flex: 1; justify-content: center; }
  .readonly-note { width: 100%; margin-right: 0; margin-bottom: 8px; }

  .form-grid { grid-template-columns: 1fr; gap: 12px; }
  .status-btn-grid { grid-template-columns: 1fr; }

  /* Task modal: form above discussion instead of side-by-side */
  .task-modal-body { flex-direction: column; }
  .task-form-col, .task-discussion-col { max-height: none; padding: 16px; }
  .task-discussion-col { border-left: none; border-top: 1px solid var(--border); }
  .discussion-feed { max-height: 240px; }

  .notes-grid { grid-template-columns: 1fr; }
  .calendar-day { min-height: 64px; padding: 4px; }
  .calendar-day .day-number { font-size: 11px; }
  .calendar-chip { font-size: 9.5px; }
  .calendar-weekdays { font-size: 10px; }

  .invoice-summary { max-width: none; }
  .hide-sm { display: none; }
  .toast-container { top: auto; bottom: 16px; left: 12px; right: 12px; }
}

/* ===== Client profile: services we provide ===== */
.services-block {
  margin-top: 20px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.services-head h3 { font-size: 15px; margin: 0 0 4px; }
.services-head p { font-size: 12px; color: var(--text-muted); margin: 0 0 12px; line-height: 1.5; }
.services-list { display: flex; flex-direction: column; gap: 10px; }
.service-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--bg-subtle, #f9fafb);
}
.service-card.is-on { border-color: var(--primary); background: #fff; }
.service-toggle { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 13px; cursor: pointer; }
.service-toggle input { width: 16px; height: 16px; cursor: pointer; }
.service-toggle i { width: 16px; text-align: center; color: var(--text-muted); }
.service-card.is-on .service-toggle i { color: var(--primary); }
.service-settings { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }
.service-settings small { display: block; font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.service-checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.check-inline { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; cursor: pointer; }
.check-inline input { width: 14px; height: 14px; }
.service-cell { white-space: nowrap; }
.service-cell .badge { margin-right: 2px; }

@media (max-width: 720px) {
  .service-checks { flex-direction: column; gap: 6px; }
}

/* ===== HR & Payroll ===== */
.badge.att-present { background: #dcfce7; color: #166534; }
.badge.att-absent { background: #fee2e2; color: #991b1b; }
.badge.att-half-day { background: #fef3c7; color: #92400e; }
.badge.att-leave { background: #dbeafe; color: #1d4ed8; }
.badge.att-holiday { background: #f1f5f9; color: #475569; }

.subtab-badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  margin-left: 5px;
  border-radius: 9px;
  background: #f59e0b;
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
}
.hint-inline { font-size: 12px; color: var(--text-muted); }
.kpi-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Day cards a staff member marks their attendance from */
.attendance-days {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 10px;
}
.attendance-day-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.attendance-day-card.is-today { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.att-day-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; }
.att-day-date { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.att-day-body { display: flex; flex-direction: column; gap: 4px; min-height: 22px; }
.att-day-note { font-size: 11px; color: var(--text-muted); line-height: 1.4; }
.attendance-day-card .btn { justify-content: center; }

.payslip-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.data-table.compact th, .data-table.compact td { padding: 5px 8px; font-size: 12.5px; }

@media (max-width: 720px) {
  .payslip-grid { grid-template-columns: 1fr; }
  .attendance-days { grid-template-columns: 1fr; }
}
