/* ServiceTrack - application UI system (Phase C).
   Palette matches the public landing page (navy/teal) for a consistent
   brand identity from marketing site through to the logged-in app.
   Readability rules followed throughout: dark text on light backgrounds,
   white text only on genuinely dark/saturated backgrounds, no pale-on-pale
   pairings, body text never below 14px.
   Layout note: the sidebar lives INSIDE each view's existing Bootstrap
   col-md-2 column (container-fluid > row > col-md-2 + col-md-10) - it is
   sticky, not fixed, specifically so no view file needs its markup
   changed to adopt this system. */
:root {
  --st-navy: #1F3864;
  --st-navy-dark: #142647;
  --st-steel: #2E75B6;
  --st-teal: #0EA99F;
  --st-teal-dark: #0B857D;
  --st-amber: #F5A623;
  --st-bg: #F5F7FA;
  --st-surface: #FFFFFF;
  --st-text: #1F2937;
  --st-muted: #5B6B7B;
  --st-border: #DCE3EC;
  --st-success: #1E7D5A;
  --st-success-bg: #DFF3E9;
  --st-warning-bg: #FDF1DC;
  --st-warning-text: #92620A;
  --st-danger: #B3261E;
  --st-danger-bg: #FBE7E5;
  --topbar-height: 68px;
}

body { background: var(--st-bg); color: var(--st-text); font-size: 15px; }
body.has-topbar { padding-top: var(--topbar-height); }
a { color: var(--st-steel); }

/* TOPBAR */
.st-topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-height); z-index: 1030;
  background: var(--st-navy); color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; box-shadow: 0 1px 6px rgba(0,0,0,.12);
}
.st-topbar-brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.05rem; }
.st-topbar-brand .icon-badge { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, var(--st-teal), var(--st-steel)); display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; }
.st-topbar-context { font-size: .78rem; color: rgba(255,255,255,.65); margin-left: 8px; padding-left: 12px; border-left: 1px solid rgba(255,255,255,.2); }
.st-sidebar-toggle { background: none; border: none; color: #fff; font-size: 1.1rem; margin-right: 12px; cursor: pointer; display: none; }
.st-topbar-right { display: flex; align-items: center; gap: 6px; }
.st-topbar-icon-btn { position: relative; width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: rgba(255,255,255,.9); text-decoration: none; font-size: 1.05rem; transition: background .15s; border: none; background: none; }
.st-topbar-icon-btn:hover { background: rgba(255,255,255,.12); color: #fff; }
.st-notif-badge { position: absolute; top: 4px; right: 4px; background: var(--st-amber); color: #1F2937; font-size: .62rem; font-weight: 700; min-width: 16px; height: 16px; border-radius: 8px; display: flex; align-items: center; justify-content: center; padding: 0 3px; }
.st-profile-btn { display: flex; align-items: center; gap: 9px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14); border-radius: 24px; padding: 5px 14px 5px 6px; color: #fff; cursor: pointer; }
.st-profile-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--st-teal); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .78rem; flex-shrink: 0; }
.st-profile-btn .name { font-size: .84rem; font-weight: 600; line-height: 1.1; }
.st-profile-btn .role { font-size: .68rem; color: rgba(255,255,255,.6); line-height: 1.1; }
.st-notif-menu, .dropdown-menu { border: 1px solid var(--st-border); box-shadow: 0 10px 30px rgba(31,56,100,.15); border-radius: 12px; padding: 6px; }
.st-notif-menu { width: 320px; max-height: 380px; overflow-y: auto; }
.st-notif-item { display: block; padding: 10px 12px; border-radius: 8px; color: var(--st-text); text-decoration: none; font-size: .85rem; }
.st-notif-item:hover { background: var(--st-bg); }
.st-notif-item .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--st-danger); margin-right: 7px; }
.st-notif-empty { padding: 22px 12px; text-align: center; color: var(--st-muted); font-size: .85rem; }
.dropdown-item { font-size: .87rem; padding: 8px 12px; border-radius: 8px; }
.dropdown-item:active, .dropdown-item.active { background: var(--st-teal); color: #fff; }

/* SIDEBAR */
.st-sidebar {
  position: sticky; top: var(--topbar-height); height: calc(100vh - var(--topbar-height));
  background: var(--st-navy-dark); overflow-y: auto; padding: 14px 10px 20px;
  margin: 0 -12px; width: calc(100% + 24px); scrollbar-width: thin;
}
.st-nav-link, .st-nav-group-toggle {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 8px;
  color: rgba(255,255,255,.72); text-decoration: none; font-size: .87rem; font-weight: 500;
  margin-bottom: 2px; width: 100%; background: none; border: none; text-align: left; cursor: pointer;
}
.st-nav-link i, .st-nav-group-toggle i.st-nav-icon { width: 18px; text-align: center; font-size: .95rem; flex-shrink: 0; }
.st-nav-link:hover, .st-nav-group-toggle:hover { background: rgba(255,255,255,.06); color: #fff; }
.st-nav-link.active { background: var(--st-teal); color: #fff; font-weight: 600; }
.st-nav-group-toggle.active-parent { color: #fff; }
.st-nav-group-toggle .chev { margin-left: auto; font-size: .7rem; transition: transform .2s; }
.st-nav-group-toggle[aria-expanded="true"] .chev { transform: rotate(90deg); }
.st-nav-group-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; color: rgba(255,255,255,.35); padding: 14px 12px 6px; }
.st-nav-sublist { padding-left: 6px; }
.st-nav-sublist .st-nav-link { padding-left: 34px; font-size: .84rem; }

/* MAIN CONTENT - still the existing Bootstrap col-md-10, just adds spacing */
.st-breadcrumb { font-size: .82rem; color: var(--st-muted); margin-bottom: 14px; }
.st-breadcrumb a { color: var(--st-muted); text-decoration: none; }
.st-breadcrumb a:hover { color: var(--st-teal-dark); }

/* CARDS / KPI / BADGES (design system) */
.st-card { border: 1px solid var(--st-border); border-radius: 12px; box-shadow: 0 1px 3px rgba(31,56,100,.06); background: var(--st-surface); }
.st-kpi-card { padding: 18px 20px; border-radius: 14px; background: var(--st-surface); border: 1px solid var(--st-border); position: relative; overflow: hidden; text-decoration: none; display: block; color: var(--st-text); }
.st-kpi-card:hover { box-shadow: 0 8px 20px rgba(31,56,100,.1); color: var(--st-text); }
.st-kpi-card .kpi-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.05rem; margin-bottom: 10px; background: rgba(46,117,182,.1); color: var(--st-navy); }
.st-kpi { font-size: 1.7rem; font-weight: 800; color: var(--st-navy); line-height: 1.1; }
.st-kpi-label { color: var(--st-muted); font-size: .8rem; margin-top: 3px; }
.st-kpi-card.tone-danger .kpi-icon { background: var(--st-danger-bg); color: var(--st-danger); }
.st-kpi-card.tone-warning .kpi-icon { background: var(--st-warning-bg); color: var(--st-warning-text); }
.st-kpi-card.tone-success .kpi-icon { background: var(--st-success-bg); color: var(--st-success); }
.st-kpi-card.tone-teal .kpi-icon { background: rgba(14,169,159,.12); color: var(--st-teal-dark); }

.st-badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: .74rem; font-weight: 600; }
.st-badge-success { background: var(--st-success-bg); color: var(--st-success); }
.st-badge-warning { background: var(--st-warning-bg); color: var(--st-warning-text); }
.st-badge-danger { background: var(--st-danger-bg); color: var(--st-danger); }
.st-badge-muted { background: #EEF1F5; color: var(--st-muted); }
.st-badge-teal { background: rgba(14,169,159,.12); color: var(--st-teal-dark); }

.st-attention-card { border-left: 4px solid var(--st-amber); background: var(--st-warning-bg); border-radius: 10px; padding: 14px 16px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; text-decoration: none; color: var(--st-text); }
.st-attention-card:hover { background: #FBEACE; color: var(--st-text); }
.st-attention-card.tone-danger { border-left-color: var(--st-danger); background: var(--st-danger-bg); }
.st-attention-card.tone-danger:hover { background: #F8D9D6; }
.st-attention-card .att-title { font-weight: 600; font-size: .89rem; }
.st-attention-card .att-sub { font-size: .78rem; color: var(--st-muted); }

.st-activity-item { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--st-border); font-size: .85rem; }
.st-activity-item:last-child { border-bottom: none; }
.st-activity-dot { width: 30px; height: 30px; border-radius: 50%; background: rgba(46,117,182,.1); color: var(--st-navy); display: flex; align-items: center; justify-content: center; font-size: .82rem; flex-shrink: 0; }
.st-activity-time { color: var(--st-muted); font-size: .74rem; }

.st-hero-band { background: linear-gradient(135deg, var(--st-navy), var(--st-steel)); color: #fff; border-radius: 14px; padding: 22px 26px; }
.st-hero-band h4, .st-hero-band .text-muted { color: #fff !important; opacity: .95; }

/* Standard buttons */
.btn-primary { background: var(--st-teal); border-color: var(--st-teal); }
.btn-primary:hover, .btn-primary:focus { background: var(--st-teal-dark); border-color: var(--st-teal-dark); }
.btn-outline-primary { color: var(--st-navy); border-color: var(--st-border); }
.btn-outline-primary:hover { background: var(--st-navy); border-color: var(--st-navy); }

/* Empty state */
.st-empty-state { text-align: center; padding: 46px 20px; color: var(--st-muted); }
.st-empty-state i { font-size: 2rem; color: var(--st-border); margin-bottom: 14px; display: block; }

@media (max-width: 767px) {
  .st-topbar-context { display: none; }
  .st-profile-btn .name, .st-profile-btn .role { display: none; }
}

/* Report printing (existing behaviour preserved) */
@media print {
  .st-topbar, .st-sidebar, .btn, form, .no-print { display: none !important; }
  body { background: #fff; padding-top: 0 !important; }
  .card, .st-card { box-shadow: none !important; border: 1px solid #ddd !important; }
}

/* Guest pages (login, forgot-pin, change-password) — footer + WhatsApp
   help button. Gated to logged-out pages only in footer.php, so this
   never appears on the authenticated dashboard. */
.st-guest-footer {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 900;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 12px 16px; background: rgba(255,255,255,.92); backdrop-filter: blur(6px);
  border-top: 1px solid var(--st-border); font-size: .8rem; color: var(--st-muted); text-align: center;
}
.st-guest-whatsapp {
  position: fixed; bottom: 70px; right: 20px; z-index: 950;
  background: #25D366; color: #fff; width: 50px; height: 50px; border-radius: 50%;
  font-size: 23px; box-shadow: 0 8px 20px rgba(37,211,102,.4);
  display: flex; align-items: center; justify-content: center; text-decoration: none;
  transition: transform .2s;
}
.st-guest-whatsapp:hover { transform: scale(1.08); color: #fff; }

/* Sep 2026 - show/hide toggle for password/PIN fields, used with the
   .st-pw-toggle button app.js already wires up. Positioned inside the
   input on the right, same visual weight as a normal form control icon -
   not a separate floating button. */
.st-pw-wrap { position: relative; }
.st-pw-wrap input { padding-right: 42px; }
.st-pw-toggle {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  background: none; border: none; padding: 6px 8px; color: var(--st-muted);
  cursor: pointer; line-height: 1;
}
.st-pw-toggle:hover { color: var(--st-navy, #1F3864); }

/* Sep 2026 - structured notification body rendering (morning briefing/
   EOD summary style: "━━ SECTION ━━" markers become real headings).
   Dark, readable text throughout - no pale-on-pale, per readability
   rules; headings distinguished by weight/color, not just size. */
.st-notif-body { margin-top: 4px; line-height: 1.55; }
.st-notif-heading {
  font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .02em;
  color: #1F3864; margin-top: 10px; margin-bottom: 2px;
}
.st-notif-body .st-notif-heading:first-child { margin-top: 2px; }
.st-notif-line { color: #1F2937; font-size: .85rem; }
.st-notif-spacer { height: 4px; }

/* =====================================================================
   V1.76 - READABILITY PATCH (standing rule: users aged 40-70, no grey
   text on white, no faint text, body text >= 14px). One block, appended
   last so it wins; delete this block to revert completely.
   Found: .text-muted (Bootstrap grey #6c757d) used on 527 places and
   <small> on 617 places across the web screens; sidebar/topbar labels at
   35-65% white on navy.
   ===================================================================== */
:root {
  --st-muted: #374151;             /* was #5B6B7B - now dark grey, clearly readable */
  --bs-secondary-color: #374151;   /* Bootstrap's .text-muted / .text-secondary source */
}
.text-muted, .text-secondary, .form-text { color: #374151 !important; }
small, .small { font-size: .9em; }            /* Bootstrap default .875em */
.form-text { font-size: .9rem; }
.st-kpi-label, .st-breadcrumb, .st-activity-time, .st-attention-card .att-sub { font-size: .875rem; }
.st-badge { font-size: .8rem; }
/* Dark sidebar / topbar - raise faint white text to comfortable contrast */
.st-nav-link { color: rgba(255,255,255,.92); }
.st-nav-group-label { color: rgba(255,255,255,.75); font-size: .75rem; }
.st-topbar-context { color: rgba(255,255,255,.88); }
.st-profile-btn .role { color: rgba(255,255,255,.85); font-size: .74rem; }
/* Warning buttons: never white-on-yellow */
.btn-warning, .btn-outline-warning:hover { color: #1F2937 !important; }
.btn-outline-warning { color: #7A4F00; border-color: #B7791F; }
