/* Rego Media Tracker — red & white theme */
:root {
  --red: #D9041A;          /* brand red, darkened slightly from the logo for readable text */
  --red-logo: #F50217;
  --red-dark: #A80314;
  --red-50: #FFF1F2;
  --red-100: #FFE0E3;
  --ink: #18181B;
  --ink-2: #3F3F46;
  --muted: #71717A;
  --line: #ECECEE;
  --line-2: #E0E0E3;
  --bg: #F7F7F8;
  --white: #FFFFFF;
  --green: #0F7B3F;
  --green-50: #EAF7EF;
  --amber: #A15C00;
  --amber-50: #FFF5E0;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(24, 24, 27, .04), 0 1px 3px rgba(24, 24, 27, .06);
  --sidebar: 248px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--red); text-decoration: none; }
a:hover { color: var(--red-dark); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 8px; }
small, .small { font-size: 12px; }
.muted { color: var(--muted); }
.red { color: var(--red); }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* ---------- App shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar);
  background: var(--red);
  color: #fff;
  position: fixed; inset: 0 auto 0 0;
  display: flex; flex-direction: column;
  z-index: 40;
  transition: transform .2s ease;
}
.sidebar-brand { background: #fff; padding: 18px 20px; border-bottom: 4px solid var(--red-dark); }
.sidebar-brand img { display: block; width: 150px; height: auto; }
.sidebar-brand span { display: block; margin-top: 6px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--red); }
.nav { padding: 14px 12px; flex: 1; overflow-y: auto; }
.nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: rgba(255,255,255,.65); padding: 14px 12px 6px; font-weight: 600; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: #fff; font-weight: 500;
}
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.nav a.active { background: #fff; color: var(--red); }
.nav a.active svg { opacity: 1; }
.nav .count { margin-left: auto; background: #fff; color: var(--red); border-radius: 999px; font-size: 11px; font-weight: 700; padding: 0 7px; line-height: 18px; }
.nav a.active .count { background: var(--red); color: #fff; }
.sidebar-user { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.18); display: flex; align-items: center; gap: 10px; }
.sidebar-user .who { flex: 1; min-width: 0; }
.sidebar-user .who strong { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .who span { font-size: 11px; color: rgba(255,255,255,.75); }
.sidebar-user button { background: none; border: 0; color: #fff; cursor: pointer; padding: 6px; border-radius: 6px; }
.sidebar-user button:hover { background: rgba(255,255,255,.15); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: #fff; color: var(--red);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex: none;
}
.avatar.sm { width: 26px; height: 26px; font-size: 10.5px; }
.avatar.red { background: var(--red-50); color: var(--red); border: 1px solid var(--red-100); }
.avatars { display: inline-flex; }
.avatars .avatar { margin-left: -6px; border: 2px solid #fff; }
.avatars .avatar:first-child { margin-left: 0; }

.main { flex: 1; margin-left: var(--sidebar); min-width: 0; max-width: 100%; display: flex; flex-direction: column; }
.topbar {
  background: #fff; border-bottom: 1px solid var(--line);
  padding: 16px 28px; display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 20;
}
.topbar .title { flex: 1; min-width: 0; }
.topbar .title p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.topbar .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.menu-btn { display: none; background: none; border: 1px solid var(--line-2); border-radius: 8px; padding: 6px; cursor: pointer; color: var(--ink); }
.content { padding: 24px 28px 48px; max-width: 1400px; width: 100%; }
.backdrop { display: none; }

/* ---------- Cards & layout ---------- */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-head h2 { flex: 1; }
.card-body { padding: 20px; }
.card-body.tight { padding: 0; }
.grid { display: grid; gap: 20px; }
.grid > * { min-width: 0; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.stack > * + * { margin-top: 20px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.stat .label { font-size: 12px; color: var(--muted); font-weight: 500; }
.stat .value { font-size: 28px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: 12px; color: var(--muted); }
.stat.is-alert { background: var(--red); border-color: var(--red); color: #fff; }
.stat.is-alert .label, .stat.is-alert .sub { color: rgba(255,255,255,.85); }
.stat a.cover { position: absolute; inset: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  font: inherit; font-weight: 500; font-size: 13.5px; line-height: 1.3;
  border: 1px solid var(--line-2); background: #fff; color: var(--ink);
  cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #c9c9ce; color: var(--ink); background: #fafafa; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); border-color: var(--red-dark); color: #fff; }
.btn-outline { border-color: var(--red); color: var(--red); }
.btn-outline:hover { background: var(--red-50); color: var(--red-dark); border-color: var(--red-dark); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-danger-text { color: var(--red); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--red); cursor: pointer; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.field label, .label { display: block; font-weight: 500; font-size: 13px; margin-bottom: 6px; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.input, select.input, textarea.input {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  font: inherit; color: var(--ink); background: #fff;
}
textarea.input { min-height: 90px; resize: vertical; }
.input:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px var(--red-100); }
.input.is-invalid { border-color: var(--red); }
.error { color: var(--red); font-size: 12px; margin-top: 4px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.check input { width: 16px; height: 16px; accent-color: var(--red); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.check-card { border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 9px 12px; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.check-card:has(input:checked) { border-color: var(--red); background: var(--red-50); }
.check-card input { accent-color: var(--red); width: 16px; height: 16px; }
.check-card small { display: block; color: var(--muted); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 20px; border-top: 1px solid var(--line); background: #fcfcfc; border-radius: 0 0 var(--radius) var(--radius); }

.day-row { display: grid; grid-template-columns: 170px 140px; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.day-row:last-child { border-bottom: 0; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; display: flex; gap: 10px; align-items: flex-start; border: 1px solid; }
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.alert-success { background: var(--green-50); border-color: #bfe5cd; color: var(--green); }
.alert-error { background: var(--red-50); border-color: var(--red-100); color: var(--red-dark); }
.alert-warning { background: var(--amber-50); border-color: #f5d79e; color: var(--amber); }
.alert ul { margin: 4px 0 0; padding-left: 18px; }
.notice-box { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; border: 1px solid var(--line-2); background: #fafafa; color: var(--ink-2); }
.notice-box.warn { background: var(--red-50); border-color: var(--red-100); color: var(--red-dark); font-weight: 500; }
.notice-box.ok { background: var(--green-50); border-color: #bfe5cd; color: var(--green); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; line-height: 18px; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.b-overdue, .b-late { background: var(--red); color: #fff; }
.b-due_soon { background: var(--amber-50); color: var(--amber); border-color: #f5d79e; }
.b-on_track { background: #F4F4F5; color: var(--ink-2); border-color: var(--line-2); }
.b-on_time { background: var(--green-50); color: var(--green); border-color: #bfe5cd; }
.b-cancelled { background: #F4F4F5; color: var(--muted); text-decoration: line-through; }
.b-overage { background: #fff; color: var(--red); border-color: var(--red); }
.b-red-soft { background: var(--red-50); color: var(--red); border-color: var(--red-100); }
.b-grey { background: #F4F4F5; color: var(--ink-2); border-color: var(--line-2); }
.b-high { background: var(--red-50); color: var(--red); border-color: var(--red-100); }
.b-urgent { background: var(--red); color: #fff; }
.b-normal { display: none; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 11px 16px; border-bottom: 1px solid var(--line); background: #fcfcfc; white-space: nowrap; }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fffafa; }
.table tfoot td { font-weight: 700; background: #fcfcfc; border-top: 2px solid var(--line-2); }
.table .title-cell { min-width: 190px; }
.table .title-cell a { color: var(--ink); font-weight: 600; }
.table .title-cell a:hover { color: var(--red); }
.table .title-cell .muted { font-size: 12px; }
.row-overdue td:first-child { box-shadow: inset 3px 0 0 var(--red); }

.empty { text-align: center; padding: 36px 20px; color: var(--muted); }
.empty svg { width: 36px; height: 36px; color: var(--red-100); margin-bottom: 8px; }

/* ---------- Tabs / filters ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--red); border-bottom-color: var(--red); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filters .input { width: auto; min-width: 160px; padding: 7px 10px; }
.filters .search { min-width: 220px; flex: 1; max-width: 320px; }

/* ---------- Stage progress ---------- */
.steps { display: flex; gap: 3px; align-items: center; }
.steps span { height: 6px; width: 22px; border-radius: 3px; background: var(--line-2); }
.steps span.done { background: var(--red); }
.steps span.current { background: var(--red-100); box-shadow: inset 0 0 0 1px var(--red); }
.stage-name { font-size: 12px; color: var(--ink-2); margin-top: 4px; font-weight: 500; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline > li { position: relative; padding: 0 0 22px 44px; }
.timeline > li::before { content: ''; position: absolute; left: 15px; top: 32px; bottom: 0; width: 2px; background: var(--line); }
.timeline > li:last-child { padding-bottom: 0; }
.timeline > li:last-child::before { display: none; }
.timeline > li.done::before { background: var(--red); }
.tl-dot { position: absolute; left: 0; top: 0; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: #fff; border: 2px solid var(--line-2); color: var(--muted); font-weight: 700; font-size: 12px; }
.tl-dot svg { width: 16px; height: 16px; }
li.done .tl-dot { background: var(--red); border-color: var(--red); color: #fff; }
li.current .tl-dot { border-color: var(--red); color: var(--red); box-shadow: 0 0 0 4px var(--red-50); }
.tl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 32px; }
.tl-head h3 { font-size: 15px; }
.tl-meta { color: var(--muted); font-size: 12.5px; }
.tl-note { margin-top: 6px; background: #fafafa; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 12px; font-size: 13px; color: var(--ink-2); white-space: pre-line; }
.tl-action { margin-top: 12px; background: var(--red-50); border: 1px solid var(--red-100); border-radius: var(--radius); padding: 14px; }
.tl-action .input { background: #fff; }
.tl-action textarea.input { min-height: 60px; }

.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--red); border-radius: 99px; }
.meter { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; display: flex; }
.meter > .in { background: var(--red); }
.meter > .over { background: repeating-linear-gradient(45deg, var(--red-dark), var(--red-dark) 4px, #ff5a6a 4px, #ff5a6a 8px); }

/* ---------- Definition lists ---------- */
.dl { display: grid; grid-template-columns: 120px 1fr; gap: 10px 12px; margin: 0; }
.dl dt { color: var(--muted); font-size: 13px; }
.dl dd { margin: 0; font-weight: 500; }

/* ---------- Activity ---------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed .what { font-size: 13px; }
.feed .when { font-size: 11.5px; color: var(--muted); }
.feed .note { font-size: 12.5px; color: var(--ink-2); margin-top: 3px; white-space: pre-line; }

/* ---------- Schedule grid ---------- */
.week { display: grid; grid-template-columns: 180px repeat(7, minmax(120px, 1fr)); min-width: 1100px; }
.week > div { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 10px; min-height: 64px; }
.week .wh { background: #fcfcfc; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; min-height: 0; }
.week .wh.today { background: var(--red); color: #fff; }
.week .wc { font-weight: 600; }
.week .cell.today { background: #fffafa; }
.slot { border-radius: var(--radius-sm); padding: 6px 8px; margin-bottom: 6px; font-size: 12px; border: 1px solid var(--line-2); background: #fff; }
.slot .t { font-weight: 700; color: var(--red); }
.slot.empty-slot { border-style: dashed; color: var(--muted); }
.slot.empty-slot.warn { border-color: var(--red); color: var(--red); background: var(--red-50); }
.slot a { color: var(--ink); font-weight: 500; display: block; }
.slot .badge { white-space: normal; }
.slot a:hover { color: var(--red); }

/* ---------- Company cards ---------- */
.co-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.co-card { padding: 18px; display: flex; flex-direction: column; gap: 12px; color: var(--ink); }
.co-card:hover { border-color: var(--red-100); color: var(--ink); }
.co-logo { width: 44px; height: 44px; border-radius: 10px; object-fit: contain; border: 1px solid var(--line); background: #fff; flex: none; }
.co-mono { width: 44px; height: 44px; border-radius: 10px; background: var(--red); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: none; }
.co-mono.lg, .co-logo.lg { width: 64px; height: 64px; font-size: 20px; }
.co-days { display: flex; gap: 4px; }
.co-days span { width: 30px; text-align: center; font-size: 11px; font-weight: 600; padding: 3px 0; border-radius: 6px; background: #F4F4F5; color: #a1a1aa; }
.co-days span.on { background: var(--red); color: #fff; }
.co-stats { display: flex; gap: 16px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 10px; }
.co-stats b { color: var(--ink); font-size: 14px; display: block; }
.co-stats .bad b { color: var(--red); }
.inactive { opacity: .55; }

/* ---------- Stage editor ---------- */
.stage-row { display: grid; grid-template-columns: 28px 1fr 220px auto; gap: 10px; align-items: center; padding: 8px 0; }
.stage-row .n { width: 26px; height: 26px; border-radius: 50%; background: var(--red-50); color: var(--red); font-weight: 700; font-size: 12px; display: flex; align-items: center; justify-content: center; }
.icon-btn { background: #fff; border: 1px solid var(--line-2); border-radius: 6px; width: 30px; height: 30px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.icon-btn:hover { color: var(--red); border-color: var(--red); }
.icon-btn svg { width: 14px; height: 14px; }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 4px; justify-content: flex-end; padding: 14px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; align-items: center; }
.pagination a, .pagination span { padding: 5px 11px; border: 1px solid var(--line-2); border-radius: 6px; font-size: 13px; color: var(--ink-2); }
.pagination .active { background: var(--red); color: #fff; border-color: var(--red); }
.pagination .disabled { color: #c4c4c8; }
.pagination .info { border: 0; color: var(--muted); margin-right: auto; padding-left: 0; }

/* ---------- Bill ---------- */
.bill-total { display: flex; align-items: baseline; justify-content: space-between; padding: 16px 20px; background: var(--red); color: #fff; border-radius: 0 0 var(--radius) var(--radius); }
.bill-total .amt { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stamp { display: inline-flex; align-items: center; gap: 6px; border: 2px solid var(--green); color: var(--green); padding: 3px 10px; border-radius: 6px; font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.print-only { display: none; }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: #fff; }
.auth-brand { background: var(--red); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-brand::after { content: ''; position: absolute; width: 520px; height: 520px; border-radius: 50%; border: 70px solid rgba(255,255,255,.07); right: -180px; bottom: -200px; }
.auth-brand img { width: 260px; max-width: 70%; }
.auth-brand h2 { font-size: 34px; font-weight: 700; line-height: 1.15; max-width: 440px; margin-bottom: 14px; }
.auth-brand p { color: rgba(255,255,255,.85); max-width: 420px; font-size: 15px; }
.auth-steps { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 24px; position: relative; z-index: 1; }
.auth-steps span { border: 1px solid rgba(255,255,255,.4); border-radius: 999px; padding: 5px 14px; font-size: 13px; font-weight: 500; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-form form { width: 100%; max-width: 360px; }
.auth-form h1 { font-size: 26px; margin-bottom: 6px; }
.auth-form .mobile-logo { display: none; width: 160px; margin-bottom: 28px; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .grid-main { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.25); }
  .backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 30; }
  .main { margin-left: 0; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
  .content { padding: 16px 16px 40px; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-form .mobile-logo { display: block; }
  .stage-row { grid-template-columns: 26px 1fr; }
  .stage-row select, .stage-row .stage-tools { grid-column: 2; }
  .day-row { grid-template-columns: 1fr 1fr; }
  .dl { grid-template-columns: 110px 1fr; }
}
@media (max-width: 520px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat .value { font-size: 22px; }
  .topbar .actions { width: 100%; }
}

@media print {
  .sidebar, .topbar .actions, .menu-btn, .no-print, .alert { display: none !important; }
  .main { margin-left: 0; }
  .topbar { position: static; border: 0; padding: 0 0 12px; }
  .content { padding: 0; }
  body { background: #fff; }
  .card { box-shadow: none; }
  .print-only { display: block; }
  .bill-total { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* =====================================================================
   Notifications: bell, panel, toasts
   ===================================================================== */
.bell-wrap { position: relative; }
.bell {
  position: relative; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--line-2); background: #fff; color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.bell:hover { border-color: var(--red); color: var(--red); background: var(--red-50); }
.bell:active { transform: scale(.94); }
.bell:focus-visible { outline: 3px solid var(--red-100); outline-offset: 2px; }
.bell-count {
  position: absolute; top: -3px; right: -3px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 999px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; border: 2px solid #fff;
  animation: pop var(--dur) var(--ease-spring);
}
.bell.ring svg { animation: bell-ring .9s var(--ease-out); transform-origin: 50% 10%; }
.bell-panel {
  position: absolute; right: 0; top: calc(100% + 10px); width: 360px; max-width: calc(100vw - 32px);
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(24,24,27,.16), 0 2px 6px rgba(24,24,27,.06);
  z-index: 60; overflow: hidden; transform-origin: top right;
  animation: panel-in var(--dur) var(--ease-out);
}
.bell-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.bell-perm { padding: 10px 16px; font-size: 12px; color: var(--ink-2); background: var(--red-50); border-bottom: 1px solid var(--red-100); }
.bell-list { list-style: none; margin: 0; padding: 0; max-height: 380px; overflow-y: auto; }
.bell-list li { border-bottom: 1px solid var(--line); animation: fade-up var(--dur) var(--ease-out) both; animation-delay: calc(var(--i, 0) * 30ms); }
.bell-list li:last-child { border-bottom: 0; }
.bell-item { display: block; padding: 11px 16px 11px 28px; color: var(--ink); position: relative; transition: background-color var(--dur-fast); }
.bell-item:hover { background: #fffafa; color: var(--ink); }
.bell-item strong { display: block; font-size: 13px; }
.bell-item span { display: block; font-size: 12.5px; color: var(--ink-2); }
.bell-item small { color: var(--muted); font-size: 11px; }
.unread .bell-item::before { content: ''; position: absolute; left: 12px; top: 17px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
.bell-empty { padding: 20px 16px; color: var(--muted); font-size: 13px; text-align: center; }
.bell-foot { display: block; text-align: center; padding: 11px; font-weight: 500; font-size: 13px; border-top: 1px solid var(--line); background: #fcfcfc; }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 90; display: flex; flex-direction: column; gap: 10px; width: 360px; max-width: calc(100vw - 32px); }
.toast {
  position: relative; display: flex; align-items: flex-start; background: #fff; border: 1px solid var(--line);
  border-left: 4px solid var(--ink-2); border-radius: var(--radius-sm); overflow: hidden;
  box-shadow: 0 14px 40px rgba(24,24,27,.18);
  animation: toast-in var(--dur-slow) var(--ease-spring) both;
}
.toast.leaving { animation: toast-out 180ms var(--ease-in) forwards; }
.toast-info { border-left-color: var(--red); }
.toast-success { border-left-color: var(--green); }
.toast-warning { border-left-color: var(--amber); }
.toast-danger { border-left-color: var(--red-dark); background: var(--red-50); }
.toast-body { flex: 1; padding: 12px 8px 14px 14px; color: var(--ink); min-width: 0; }
.toast-body:hover { color: var(--ink); }
.toast-body strong { display: block; font-size: 13.5px; }
.toast-body span { display: block; font-size: 12.5px; color: var(--ink-2); }
.toast-close { background: none; border: 0; font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer; width: 44px; height: 44px; flex: none; }
.toast-close:hover { color: var(--red); }
.toast-timer { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--red); opacity: .35; transform-origin: left; animation: timer linear forwards; }

.notif-row { display: flex; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); color: var(--ink); }
.notif-row:hover { background: #fffafa; color: var(--ink); }
.notif-row.unread { background: var(--red-50); }
.notif-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--line-2); }
.notif-row.unread .notif-dot { background: var(--red); }

/* =====================================================================
   Motion system (transform/opacity only; respects reduced motion)
   ===================================================================== */
:root {
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-in: cubic-bezier(.4, 0, 1, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --dur-fast: 150ms;
  --dur: 240ms;
  --dur-slow: 420ms;
}
@keyframes fade-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes panel-in { from { opacity: 0; transform: translateY(-6px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateX(40px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(30px); } }
@keyframes timer { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes grow-y { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes bell-ring { 0%,100% { transform: rotate(0); } 15% { transform: rotate(14deg); } 30% { transform: rotate(-12deg); } 45% { transform: rotate(8deg); } 60% { transform: rotate(-5deg); } 75% { transform: rotate(2deg); } }
@keyframes pulse-ring { 0% { box-shadow: 0 0 0 0 rgba(217,4,26,.35); } 70% { box-shadow: 0 0 0 9px rgba(217,4,26,0); } 100% { box-shadow: 0 0 0 0 rgba(217,4,26,0); } }
@keyframes float { 0%,100% { transform: translate(0,0); } 50% { transform: translate(-14px,-10px); } }
@keyframes slide-down { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* Page entrance: content blocks rise in, staggered */
.content > *, .content .stack > *, .content .grid > * { animation: fade-up var(--dur-slow) var(--ease-out) both; }
.content > *:nth-child(2), .content .grid > *:nth-child(2), .content .stack > *:nth-child(2) { animation-delay: 50ms; }
.content > *:nth-child(3), .content .grid > *:nth-child(3), .content .stack > *:nth-child(3) { animation-delay: 100ms; }
.content > *:nth-child(4), .content .stack > *:nth-child(4) { animation-delay: 150ms; }
.stats > .stat { animation: fade-up var(--dur-slow) var(--ease-out) both; }
.stats > .stat:nth-child(2) { animation-delay: 60ms; }
.stats > .stat:nth-child(3) { animation-delay: 120ms; }
.stats > .stat:nth-child(4) { animation-delay: 180ms; }
.co-grid > .card { animation: fade-up var(--dur-slow) var(--ease-out) both; }
.co-grid > .card:nth-child(2) { animation-delay: 50ms; } .co-grid > .card:nth-child(3) { animation-delay: 100ms; }
.co-grid > .card:nth-child(4) { animation-delay: 150ms; } .co-grid > .card:nth-child(n+5) { animation-delay: 200ms; }
.table tbody tr { animation: fade-in var(--dur) var(--ease-out) both; }
.table tbody tr:nth-child(2) { animation-delay: 30ms; } .table tbody tr:nth-child(3) { animation-delay: 60ms; }
.table tbody tr:nth-child(4) { animation-delay: 90ms; } .table tbody tr:nth-child(5) { animation-delay: 120ms; }
.table tbody tr:nth-child(n+6) { animation-delay: 150ms; }
.alert { animation: slide-down var(--dur) var(--ease-out) both; }

/* Interactive feedback */
.btn { transition: background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), color var(--dur-fast), transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast); }
.btn:active { transform: scale(.97); }
.btn-primary:hover { box-shadow: 0 6px 16px rgba(217,4,26,.25); }
.btn.is-busy { pointer-events: none; opacity: .75; }
.btn.is-busy::after { content: ''; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
.card, .stat { transition: transform var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out), border-color var(--dur); }
.co-card:hover, .stat:hover { transform: translateY(-3px); box-shadow: 0 12px 28px rgba(24,24,27,.09); }
.nav a { transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast); }
.nav a svg { transition: transform var(--dur) var(--ease-out); }
.nav a:hover svg { transform: translateX(2px); }
.input { transition: border-color var(--dur-fast), box-shadow var(--dur-fast); }
.check-card { transition: border-color var(--dur-fast), background-color var(--dur-fast), transform var(--dur-fast); }
.check-card:active { transform: scale(.98); }
.tabs a { transition: color var(--dur-fast), border-color var(--dur); }
.icon-btn { transition: color var(--dur-fast), border-color var(--dur-fast), transform var(--dur-fast); }
.icon-btn:active { transform: scale(.92); }

/* Data visuals grow into place */
.progress > div, .meter > div, .steps span.done { transform-origin: left; animation: grow-x .7s var(--ease-out) both; animation-delay: .15s; }
.timeline > li.done::before { transform-origin: top; animation: grow-y .5s var(--ease-out) both; }
li.current .tl-dot { animation: pulse-ring 2s var(--ease-out) infinite; }
.tl-action { animation: fade-up var(--dur-slow) var(--ease-out) both; animation-delay: .1s; }
.b-overdue { animation: pulse-ring 2.4s var(--ease-out) infinite; }
.stat.is-alert { animation: fade-up var(--dur-slow) var(--ease-out) both, pulse-ring 2.4s var(--ease-out) .6s 3; }
.slot.empty-slot.warn { animation: pulse-ring 2.4s var(--ease-out) 2; }

/* Login */
.auth-brand::after { animation: float 9s ease-in-out infinite; }
.auth-brand > * { animation: fade-up .6s var(--ease-out) both; }
.auth-brand > *:nth-child(2) { animation-delay: .12s; }
.auth-steps span { animation: pop var(--dur-slow) var(--ease-spring) both; }
.auth-steps span:nth-child(1) { animation-delay: .35s; } .auth-steps span:nth-child(2) { animation-delay: .45s; }
.auth-steps span:nth-child(3) { animation-delay: .55s; } .auth-steps span:nth-child(4) { animation-delay: .65s; }
.auth-form form { animation: fade-up .6s var(--ease-out) .1s both; }

/* Sidebar slide on mobile already transitions; give the backdrop a fade */
.backdrop.show { animation: fade-in var(--dur) var(--ease-out); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; animation-delay: 0ms !important; transition-duration: .01ms !important; }
  .co-card:hover, .stat:hover { transform: none; }
}
@media print {
  *, *::before, *::after { animation: none !important; }
  .bell-wrap, .toasts { display: none !important; }
}

/* WhatsApp button keeps brand recognisability while staying in the palette */
.btn-wa { background: #fff; border-color: #1FA855; color: #12813f; }
.btn-wa:hover { background: #EDFBF2; border-color: #12813f; color: #0d6a33; }
.cutoff { border-left: 4px solid var(--red); }
.cutoff.is-passed { background: var(--red-50); border-color: var(--red-100); border-left-color: var(--red); }
.btn-block { white-space: normal; text-align: center; overflow-wrap: anywhere; }
.dl dd { overflow-wrap: anywhere; min-width: 0; }
@media (max-width: 900px) {
  .topbar .bell-wrap { order: 2; position: static; }
  .topbar .actions { order: 3; width: 100%; }
  .bell-panel { position: fixed; left: 12px; right: 12px; top: 64px; width: auto; max-width: none; }
  .toasts { right: 12px; left: 12px; width: auto; bottom: 12px; }
}

/* Install-app button inside the bell panel */
.bell-install { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 44px; border: 0; border-top: 1px solid var(--line); background: var(--red-50); color: var(--red); font: inherit; font-weight: 600; font-size: 13px; cursor: pointer; }
.bell-install:hover { background: var(--red-100); }
.bell-install[hidden] { display: none; }
