/* ============================================================
   The Chef's Companion — Standard Theme
   Colour palette: Navy #1B3A5C  Teal #2A9D8F  Amber #E9C46A
                   Coral #E76F51  Off-white #F4F1EC  Dark #111827
   ============================================================ */

/* ── CSS Custom Properties ─────────────────────────────────── */
:root {
  --navy:       #1B3A5C;
  --navy-light: #254d7a;
  --navy-dark:  #122840;
  --teal:       #2A9D8F;
  --teal-light: #3bbdad;
  --amber:      #E9C46A;
  --coral:      #E76F51;
  --green:      #2D9D5C;
  --red:        #CC2936;
  --orange:     #F4A261;

  --bg:         #F4F1EC;
  --bg-card:    #FFFFFF;
  --bg-sidebar: #1B3A5C;
  --text:       #111827;
  --text-muted: #6B7280;
  --text-inv:   #FFFFFF;
  --border:     #D1D5DB;
  --border-light: #E5E7EB;
  --shadow:     0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --shadow-lg:  0 4px 16px rgba(0,0,0,.15);
  --radius:     8px;
  --radius-lg:  12px;
  --sidebar-w:  240px;
  --topbar-h:   56px;

  --font-sans:  'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:  'JetBrains Mono', 'Fira Code', monospace;
  --transition: 150ms ease;
}

/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

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

img { max-width: 100%; display: block; }

/* ── Typography ─────────────────────────────────────────────── */
h1 { font-size: 1.75rem; font-weight: 700; color: var(--navy); }
h2 { font-size: 1.4rem;  font-weight: 600; color: var(--navy); }
h3 { font-size: 1.15rem; font-weight: 600; }
h4 { font-size: 1rem;    font-weight: 600; }
h5 { font-size: .875rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }

p { margin-bottom: .75rem; }
small { font-size: .8rem; color: var(--text-muted); }

code, pre {
  font-family: var(--font-mono);
  font-size: .85em;
  background: var(--border-light);
  border-radius: 4px;
}
code { padding: .1em .3em; }
pre  { padding: 1rem; overflow-x: auto; }

/* ── Layout ─────────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar content";
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────── */
#sidebar {
  grid-area: sidebar;
  background: var(--bg-sidebar);
  color: var(--text-inv);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
  min-height: var(--topbar-h);
}

.sidebar-brand .brand-icon { font-size: 1.5rem; }
.sidebar-brand .brand-name {
  font-size: .95rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-inv);
}
.sidebar-brand .brand-sub  { font-size: .7rem; color: rgba(255,255,255,.55); }

.sidebar-section {
  padding: .5rem 0;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.sidebar-section-label {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: rgba(255,255,255,.4);
  padding: .5rem 1.25rem .2rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .55rem 1.25rem;
  color: rgba(255,255,255,.75);
  font-size: .875rem;
  font-weight: 500;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
  text-decoration: none;
}
.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--teal); color: #fff; }
.nav-link .nav-icon { font-size: 1rem; width: 1.25rem; text-align: center; flex-shrink: 0; }
.nav-link .nav-badge {
  margin-left: auto;
  background: var(--coral);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  padding: .1em .4em;
  border-radius: 99px;
  min-width: 1.2em;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid rgba(255,255,255,.1);
  padding: .75rem 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .5rem 1.25rem;
  font-size: .8rem;
}
.sidebar-user .user-avatar {
  width: 28px; height: 28px;
  background: var(--teal);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .75rem;
  flex-shrink: 0;
}
.sidebar-user .user-name  { font-weight: 600; color: #fff; }
.sidebar-user .user-role  { color: rgba(255,255,255,.5); font-size: .7rem; }

/* ── Top Bar ────────────────────────────────────────────────── */
#topbar {
  grid-area: topbar;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 90;
}

.topbar-title { font-size: 1rem; font-weight: 600; color: var(--navy); flex: 1; }

/* Help button (topbar) */
.topbar-help-btn {
  display: none; /* shown via JS */
  align-items: center;
  justify-content: center;
  width: 1.85rem; height: 1.85rem;
  border-radius: 50%;
  background: var(--bg-page);
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  font-size: .85rem;
  font-weight: 700;
  text-decoration: none;
  flex-shrink: 0;
  transition: background .15s, border-color .15s, color .15s;
}
.topbar-help-btn:hover {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

/* Notification bell (topbar) */
.notif-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.notif-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
  padding: .35rem .5rem;
  border-radius: var(--radius);
  color: var(--navy);
  background: none;
  border: none;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.notif-bell:hover  { background: var(--border-light); }
/* Active state — bell is "open" */
.notif-bell[aria-expanded="true"] {
  background: var(--teal);
  color: #fff;
  border-radius: var(--radius) var(--radius) 0 0;
}
.notif-count {
  position: absolute;
  top: 2px; right: 2px;
  transform: translate(40%, -40%);
  background: var(--coral);
  color: #fff;
  font-size: .6rem;
  font-weight: 700;
  min-width: 1.4em;
  height: 1.4em;
  border-radius: 99px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 .3em;
  pointer-events: none;
}

/* Notification dropdown panel */
.notif-dropdown {
  position: absolute;
  top: calc(100% + 2px);
  right: 0;
  width: 380px;
  max-width: calc(100vw - 16px);
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: 0 8px 28px rgba(0,0,0,.14);
  z-index: 1000;
  overflow: hidden;
}
.notif-dropdown[hidden] { display: none; }
.notif-dropdown-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  background: var(--teal);
  color: #fff;
  font-weight: 600;
  font-size: .9rem;
}
.notif-read-all {
  font-size: .8rem;
  color: rgba(255,255,255,.85);
  background: none;
  border: 1px solid rgba(255,255,255,.4);
  border-radius: 4px;
  cursor: pointer;
  padding: .15rem .5rem;
  transition: background var(--transition);
}
.notif-read-all:hover { background: rgba(255,255,255,.15); }
.notif-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 400px;
  overflow-y: auto;
}
.notif-item {
  display: flex;
  gap: .85rem;
  align-items: flex-start;
  padding: .9rem 1rem;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background var(--transition);
  background: #f6f9ff;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: #eef4ff; }
.notif-item.notif-read { background: #fff; }
.notif-item.notif-read .notif-title { font-weight: 400; color: var(--text-muted); }
/* Unread indicator — teal left border */
.notif-item:not(.notif-read) { border-left: 3px solid var(--teal); }
.notif-item.notif-read       { border-left: 3px solid transparent; }
.notif-icon {
  font-size: 1.5rem;
  line-height: 1;
  flex-shrink: 0;
  margin-top: .1rem;
  width: 2rem;
  text-align: center;
}
.notif-body  { display: flex; flex-direction: column; gap: .25rem; min-width: 0; flex: 1; }
.notif-title { font-size: .88rem; font-weight: 600; color: var(--navy); line-height: 1.4; }
.notif-msg   {
  font-size: .82rem;
  color: var(--text-muted);
  line-height: 1.45;
  /* Allow up to 2 lines before clamping */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.notif-age   { font-size: .75rem; color: var(--text-muted); margin-top: .1rem; }
.notif-empty {
  padding: 2rem 1rem;
  font-size: .88rem;
  color: var(--text-muted);
  text-align: center;
}
.notif-dropdown-ftr {
  padding: .6rem 1rem;
  border-top: 1px solid var(--border-light);
  text-align: center;
  background: #fafafa;
}
.notif-dropdown-ftr a { font-size: .82rem; color: var(--teal); text-decoration: none; font-weight: 500; }
.notif-dropdown-ftr a:hover { text-decoration: underline; }

/* ── Comms tabs ──────────────────────────────────────────────── */
.comms-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
}
.comms-tab {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: .6rem 1.25rem;
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: -2px;
  transition: color var(--transition), border-color var(--transition);
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}
.comms-tab:hover  { color: var(--navy); }
.comms-tab.active { color: var(--teal); border-bottom-color: var(--teal); }

/* ── Nav tabs (settings, generic page tabs) ──────────────────── */
.nav-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
}
.nav-tabs .nav-item { margin: 0; }
.nav-tabs .nav-link {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .55rem 1.25rem;
  font-size: .9rem;
  font-weight: 600;
  color: var(--navy);
  text-decoration: none;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  background: none;
  border-radius: 0;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}
.nav-tabs .nav-link:hover  { color: var(--teal); background: none; }
.nav-tabs .nav-link.active {
  color: var(--teal);
  border-bottom-color: var(--teal);
  background: none;
}

.km-toggle {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .4rem .9rem;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}
.km-toggle:hover { background: var(--navy-light); }

/* ── Main Content ───────────────────────────────────────────── */
#content {
  grid-area: content;
  padding: 1.5rem;
  overflow-y: auto;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: .75rem;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
}
.card-header h3 { font-size: 1rem; margin: 0; }

.card-body  { padding: 1.25rem; }
.card-footer {
  padding: .75rem 1.25rem;
  border-top: 1px solid var(--border-light);
  background: rgba(0,0,0,.02);
}

/* Stat card */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: box-shadow .15s, transform .15s;
}
.stat-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
  transform: translateY(-2px);
  text-decoration: none;
}
.stat-card .stat-value { font-size: 2rem; font-weight: 700; color: var(--navy); line-height: 1; }
.stat-card .stat-label { font-size: .8rem; color: var(--text-muted); font-weight: 500; }
.stat-card .stat-icon  { font-size: 1.5rem; margin-bottom: .25rem; }

/* Stat card colour variants */
.stat-card.stat-ok    { border-color: #2E7D32; }
.stat-card.stat-ok    .stat-value { color: #2E7D32; }
.stat-card.stat-warn  { border-color: #E65100; }
.stat-card.stat-warn  .stat-value { color: #E65100; }
.stat-card.stat-alert { border-color: #C62828; background: #FFF5F5; }
.stat-card.stat-alert .stat-value { color: #C62828; }

/* Sub-list inside a stat card (overdue / low-stock items) */
.stat-sublist {
  margin-top: .5rem;
  list-style: none;
  padding: 0;
  font-size: .78rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.stat-sublist li { display: flex; justify-content: space-between; gap: .5rem; }
.stat-sublist li .item-label { font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-sublist .more { font-style: italic; }

/* Dashboard grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

/* ── Week rota grid ──────────────────────────────────────── */
.rota-week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0;
  min-width: 0;
}
.rota-day-col {
  border-right: 1px solid var(--border-light);
  padding: .4rem .3rem .5rem;
  min-width: 0;
}
.rota-day-col:last-child { border-right: none; }
.rota-day-col.rota-day-today {
  background: rgba(42, 157, 143, .07);
  border-radius: var(--radius);
}
.rota-day-hdr {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .05rem;
  margin-bottom: .35rem;
}
.rota-day-name {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
}
.rota-day-today .rota-day-name { color: var(--teal); }
.rota-day-num {
  font-size: .95rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
}
.rota-day-today .rota-day-num {
  background: var(--teal);
  color: #fff;
  border-radius: 50%;
  width: 1.6rem;
  height: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .85rem;
}
.rota-day-chips {
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.rota-day-empty {
  font-size: .8rem;
  color: var(--border);
  display: block;
  text-align: center;
  margin-top: .2rem;
}
.rota-chip {
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: .15rem .3rem;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.rota-chip-now {
  background: rgba(42, 157, 143, .12);
  border-color: var(--teal);
}
.rota-chip-name {
  font-size: .75rem;
  font-weight: 600;
  color: var(--navy);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rota-chip-now .rota-chip-name { color: var(--teal); }
.rota-chip-time {
  font-size: .65rem;
  color: var(--text-muted);
  white-space: nowrap;
}
@media (max-width: 640px) {
  .rota-week-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .rota-chip-time { display: none; }
  .rota-chip-name { font-size: .7rem; }
  .rota-day-num   { font-size: .8rem; }
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

.module-tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
}
.module-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--teal);
  text-decoration: none;
  color: var(--text);
}
.module-tile .tile-icon { font-size: 2rem; }
.module-tile .tile-name { font-size: .875rem; font-weight: 600; }
.module-tile .tile-desc { font-size: .75rem; color: var(--text-muted); }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .5rem 1.1rem;
  border: none;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), opacity var(--transition), transform var(--transition);
  text-decoration: none;
  white-space: nowrap;
  min-height: 38px;
}
.btn:hover   { opacity: .88; }
.btn:active  { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary  { background: var(--teal);  color: #fff; }
.btn-navy     { background: var(--navy);  color: #fff; }
.btn-danger   { background: var(--red);   color: #fff; }
.btn-warning  { background: var(--amber); color: var(--navy); }
.btn-success  { background: var(--green); color: #fff; }
.btn-outline  { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--teal); color: var(--teal); opacity: 1; }
.btn-ghost    { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--border-light); opacity: 1; color: var(--text); }

.btn-sm { padding: .3rem .75rem; font-size: .8rem; min-height: 30px; }
.btn-lg { padding: .75rem 1.5rem; font-size: 1rem; min-height: 46px; }
.btn-full { width: 100%; }

.btn-loading { position: relative; color: transparent !important; }
.btn-loading::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ── Forms ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }

label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: .3rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: .5rem .75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
  font-family: var(--font-sans);
  background: var(--bg-card);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  min-height: 38px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(42,157,143,.15);
}
input[type="checkbox"],
input[type="radio"] { width: auto; min-height: auto; }

.form-error { font-size: .78rem; color: var(--red); margin-top: .25rem; }
.form-hint  { font-size: .78rem; color: var(--text-muted); margin-top: .25rem; }

.input-group {
  display: flex;
  align-items: stretch;
}
.input-group input { border-radius: var(--radius) 0 0 var(--radius); }
.input-group .btn  { border-radius: 0 var(--radius) var(--radius) 0; }
.input-group-text {
  display: flex;
  align-items: center;
  padding: .5rem .75rem;
  background: var(--border-light);
  border: 1.5px solid var(--border);
  font-size: .875rem;
  color: var(--text-muted);
}

/* ── Tables ──────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
thead th {
  background: var(--bg);
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  padding: .6rem .9rem;
  text-align: left;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: rgba(42,157,143,.05); }
tbody td {
  padding: .7rem .9rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }

/* ── Badges & Chips ──────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .15em .55em;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.badge-teal    { background: rgba(42,157,143,.15); color: var(--teal); }
.badge-navy    { background: rgba(27,58,92,.12);   color: var(--navy); }
.badge-green   { background: rgba(45,157,92,.15);  color: var(--green); }
.badge-red     { background: rgba(204,41,54,.12);  color: var(--red); }
.badge-amber   { background: rgba(233,196,106,.3); color: #7c5e10; }
.badge-coral   { background: rgba(231,111,81,.15); color: var(--coral); }
.badge-muted   { background: var(--border-light);  color: var(--text-muted); }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  border-left: 4px solid transparent;
  font-size: .875rem;
  margin-bottom: 1rem;
}
.alert-info    { background: rgba(42,157,143,.1);  border-color: var(--teal);  color: #1a5c54; }
.alert-success { background: rgba(45,157,92,.1);   border-color: var(--green); color: #1a5c38; }
.alert-warning { background: rgba(233,196,106,.2); border-color: var(--amber); color: #7c5e10; }
.alert-danger  { background: rgba(204,41,54,.1);   border-color: var(--red);   color: #7c0f18; }

/* ── Toast Notifications ─────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  pointer-events: none;
}

.toast {
  min-width: 260px;
  max-width: 380px;
  padding: .75rem 1rem;
  border-radius: var(--radius);
  background: var(--navy);
  color: #fff;
  font-size: .875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  animation: slideIn .2s ease;
}
.toast-info    { background: var(--navy); }
.toast-success { background: var(--green); }
.toast-warning { background: #7c5e10; }
.toast-error   { background: var(--red); }
.toast-icon    { font-size: 1rem; flex-shrink: 0; margin-top: .05rem; }
.toast-body    { flex: 1; line-height: 1.4; }
.toast-close   { cursor: pointer; opacity: .7; flex-shrink: 0; font-size: 1rem; }
.toast-close:hover { opacity: 1; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-backdrop,
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 5000;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-backdrop[hidden],
.modal-overlay[hidden] {
  display: none !important;
}
.modal,
.modal-box {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  animation: popIn .15s ease;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 1.05rem; }
.modal-body    { padding: 1.25rem; }
.modal-footer  {
  padding: .9rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: .5rem;
}
.modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 1.25rem; color: var(--text-muted); line-height: 1;
}
.modal-close:hover { color: var(--text); }

/* ── Status indicators ───────────────────────────────────────── */
.status-ok    { color: var(--green); }
.status-warn  { color: #885500; }
.status-error { color: var(--red); }

.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-green  { background: var(--green); }
.dot-red    { background: var(--red); }
.dot-amber  { background: var(--amber); }
.dot-teal   { background: var(--teal); }
.dot-muted  { background: var(--border); }

/* ── Utility ─────────────────────────────────────────────────── */
.d-flex     { display: flex; }
.d-grid     { display: grid; }
.align-center { align-items: center; }
.gap-sm     { gap: .5rem; }
.gap-md     { gap: 1rem; }
.gap-lg     { gap: 1.5rem; }
.ml-auto    { margin-left: auto; }
.mr-auto    { margin-right: auto; }
.mt-1       { margin-top: .5rem; }
.mt-2       { margin-top: 1rem; }
.mt-3       { margin-top: 1.5rem; }
.mb-1       { margin-bottom: .5rem; }
.mb-2       { margin-bottom: 1rem; }
.mb-3       { margin-bottom: 1.5rem; }
.p-0        { padding: 0 !important; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-center{ text-align: center; }
.text-sm    { font-size: .8rem; }
.text-lg    { font-size: 1.1rem; }
.fw-bold    { font-weight: 700; }
.w-100      { width: 100%; }
.hidden     { display: none !important; }
.truncate   { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Divider ─────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

/* ── Skeleton loader ─────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--border-light) 25%, var(--border) 50%, var(--border-light) 75%);
  background-size: 200% 100%;
  border-radius: var(--radius);
  animation: shimmer 1.4s infinite;
}

/* ── Login page ──────────────────────────────────────────────── */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy) 60%, var(--teal) 100%);
  padding: 1rem;
}

.login-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  overflow: hidden;
}

.login-card-header {
  background: var(--navy);
  color: #fff;
  padding: 2rem 2rem 1.5rem;
  text-align: center;
}
.login-card-header .logo { font-size: 2.5rem; margin-bottom: .5rem; }
.login-card-header h1 { font-size: 1.4rem; color: #fff; margin-bottom: .15rem; }
.login-card-header p  { font-size: .8rem; color: rgba(255,255,255,.6); margin: 0; }

.login-card-body { padding: 1.75rem 2rem; }

/* ── Demo credentials banner ─────────────────────────────────── */
.demo-banner {
  background: #fefce8;
  border: 1px solid #fde047;
  border-radius: var(--radius);
  padding: .85rem 1rem;
  margin-bottom: 1.25rem;
  font-size: .85rem;
}
.demo-banner-title { font-weight: 700; color: #854d0e; margin-bottom: .4rem; }
.demo-banner-creds { display: flex; flex-direction: column; gap: .2rem; color: #1e293b; font-family: monospace; font-size: .82rem; }
.demo-banner-note  { margin-top: .5rem; color: #78716c; font-size: .78rem; }

.login-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
}
.login-tab {
  flex: 1;
  padding: .6rem;
  text-align: center;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color var(--transition), border-color var(--transition);
}
.login-tab.active { color: var(--teal); border-bottom-color: var(--teal); }

.login-footer {
  padding: 1rem 2rem;
  text-align: center;
  border-top: 1px solid var(--border);
  font-size: .78rem;
  color: var(--text-muted);
}

/* ── Keyframes ───────────────────────────────────────────────── */
@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes slideIn { from { opacity:0; transform:translateX(20px); } to { opacity:1; transform:translateX(0); } }
@keyframes popIn   { from { opacity:0; transform:scale(.95); } to { opacity:1; transform:scale(1); } }
@keyframes fadeIn  { from { opacity:0; } to { opacity:1; } }

/* ── Help pages ──────────────────────────────────────────────── */
.help-page { max-width: 680px; margin: 0 auto; padding-bottom: 2rem; }
.help-back { margin-bottom: 1rem; }
.help-back a { color: var(--teal); text-decoration: none; font-size: .9rem; font-weight: 500; }
.help-back a:hover { text-decoration: underline; }
.help-title { font-size: 1.6rem; font-weight: 700; color: var(--navy); margin-bottom: .25rem; }
.help-audience { font-size: .88rem; color: var(--text-muted); margin-bottom: 1.5rem; }
.help-steps { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-direction: column; gap: 1rem; }
.help-steps li { display: flex; gap: 1rem; align-items: flex-start; }
.help-step-num {
  width: 2rem; height: 2rem; border-radius: 50%;
  background: var(--teal); color: #fff;
  font-size: 1rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: .1rem;
}
.help-warning {
  border-left: 4px solid #EF4444;
  background: #FEF2F2;
  padding: .9rem 1rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 1.25rem 0; font-size: .9rem; line-height: 1.5;
}
.help-tip {
  border-left: 4px solid var(--teal);
  background: #F0FDFA;
  padding: .9rem 1rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 1.25rem 0; font-size: .9rem; line-height: 1.5;
}
@media print {
  #sidebar, #topbar, .help-back { display: none !important; }
  .help-page { max-width: 100%; }
  .help-step-num { border: 2px solid #000; background: none; color: #000; }
  .help-warning, .help-tip { border-left-width: 2px; background: none; }
}

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-h) 1fr auto;
    grid-template-areas:
      "topbar"
      "content"
      "sidebar";
  }
  #sidebar {
    height: auto;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    flex-direction: row;
    height: 60px;
    overflow-x: auto;
    overflow-y: hidden;
    top: auto;
  }
  .sidebar-brand, .sidebar-section-label, .sidebar-footer,
  .nav-link .nav-label { display: none; }
  .nav-link { flex-direction: column; gap: .1rem; padding: .5rem; font-size: .6rem; }
  .nav-link .nav-icon { font-size: 1.25rem; width: auto; }
  #content { padding: 1rem; padding-bottom: 70px; }
}
