/* Stickler Calendar — application styles (Stickler design system) */
:root {
  --accent: #005AFF;
  --accent-light: #2E77FF;
  --accent-bg: #E9F0FF;
  --bg: #F3F5FA;
  --panel: #ffffff;
  --border: #E7EBF3;
  --text: #16213E;
  --muted: #7A87A1;
  --warn: #B45309;
  --warn-bg: #FFF3D6;
  --danger: #D92D20;
  --danger-bg: #FEE4E2;
  --ok: #17954C;
  --ok-bg: #E3F6EB;
  --info: #005AFF;
  --info-bg: #E9F0FF;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(22, 33, 62, .05), 0 4px 16px rgba(22, 33, 62, .04);
  font-family: "Poppins", -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; }
h1, h2, h3 { font-weight: 600; color: var(--text); }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }

/* Layout */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 224px; background: var(--panel); color: var(--text); padding: 22px 0 18px;
  flex-shrink: 0; display: flex; flex-direction: column; position: sticky; top: 0;
  height: 100vh; border-right: 1px solid var(--border); }
.sidebar .logo { padding: 0 20px 22px; }
.sidebar .logo img { width: 128px; display: block; }
.sidebar .logo .logo-text { font-size: 17px; font-weight: 800; letter-spacing: 2px; }
.sidebar .logo span { color: var(--muted); font-weight: 500; font-size: 11px;
  letter-spacing: 1.5px; text-transform: uppercase; display: block; margin-top: 4px; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; padding: 0 12px; }
.sidebar nav a { color: #57627C; padding: 10px 12px; font-size: 14px; font-weight: 500;
  border-radius: 10px; }
.sidebar nav a:hover { background: var(--bg); color: var(--text); }
.sidebar nav a.active { background: var(--accent-bg); color: var(--accent); font-weight: 600; }
.sidebar .foot { margin-top: auto; padding: 14px 20px 0; font-size: 12px; color: var(--muted);
  border-top: 1px solid var(--border); }
.sidebar .foot a { color: var(--muted); }
.main { flex: 1; padding: 24px 28px; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.topbar h1 { font-size: 22px; margin: 0; font-weight: 700; }
.topbar .spacer { flex: 1; }

/* Panels & tables */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.panel h2 { margin: 0 0 12px; font-size: 15px; font-weight: 600; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th { text-align: left; color: #5A6B8C; font-weight: 600; padding: 10px 12px;
  background: #EEF3FE; white-space: nowrap; }
table.grid th:first-child { border-radius: 10px 0 0 10px; }
table.grid th:last-child { border-radius: 0 10px 10px 0; }
table.grid td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.grid tr:last-child td { border-bottom: none; }
table.grid tr:hover td { background: #FAFBFE; }

/* Buttons & inputs */
.btn { background: var(--accent); color: #fff; border: none; border-radius: 999px;
  padding: 9px 18px; font-size: 13px; font-weight: 600; }
.btn:hover { background: var(--accent-light); }
.btn.secondary { background: #fff; color: var(--text); border: 1px solid #D8DFEC; }
.btn.secondary:hover { background: var(--bg); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 5px 12px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=time],
input[type=number], input[type=url], select, textarea {
  border: 1px solid #D8DFEC; border-radius: 10px; padding: 8px 12px; background: #fff;
  width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-bg);
  border-color: var(--accent); }
label.field { display: block; margin-bottom: 10px; font-size: 12px; color: var(--muted);
  font-weight: 600; }
label.field > * { margin-top: 4px; font-weight: 400; font-size: 13px; color: var(--text); }
.formgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.formgrid .wide { grid-column: 1 / -1; }

/* Badges */
.badge { display: inline-block; border-radius: 999px; padding: 3px 10px; font-size: 11px;
  font-weight: 600; white-space: nowrap; }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.muted { background: #EEF1F7; color: #5A6B8C; }
.badge.accent { background: var(--accent-bg); color: var(--accent); }

/* Calendar */
.cal-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cal-week { display: grid; grid-template-columns: 54px repeat(7, 1fr); background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); }
.cal-week .head { padding: 10px 6px; text-align: center; font-size: 12px; font-weight: 600;
  border-bottom: 1px solid var(--border); background: #F7F9FD; color: #5A6B8C; }
.cal-week .head.today { color: var(--accent); }
.cal-day-col { border-left: 1px solid var(--border); position: relative; min-height: 720px; }
.cal-hour-label { height: 60px; font-size: 10px; color: var(--muted); text-align: right;
  padding: 2px 6px 0 0; border-bottom: 1px dashed #EFF2F8; }
.cal-hour-line { height: 60px; border-bottom: 1px dashed #EFF2F8; }
.cal-event { position: absolute; left: 3px; right: 3px; border-radius: 8px; padding: 4px 7px;
  font-size: 11px; background: var(--accent-bg); border-left: 3px solid var(--accent);
  overflow: hidden; cursor: pointer; }
.cal-event:hover { filter: brightness(.97); }
.cal-event .t { font-weight: 700; }
.cal-event.has-issues { background: var(--warn-bg); border-left-color: #E8A23D; }
.cal-event.cancelled { background: #F1F2F6; border-left-color: #A6B0C3;
  text-decoration: line-through; }
.cal-event.completed { background: var(--ok-bg); border-left-color: var(--ok); }
.cal-event.ready { border-left-color: var(--ok); }
.cal-event.ready .t::before { content: "✓ "; color: var(--ok); }
.cal-month { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); }
.cal-month .mhead { padding: 10px; font-size: 12px; font-weight: 600; text-align: center;
  border-bottom: 1px solid var(--border); background: #F7F9FD; color: #5A6B8C; }
.cal-month .mcell { min-height: 108px; border-top: 1px solid var(--border);
  border-left: 1px solid var(--border); padding: 5px 7px; font-size: 12px; cursor: pointer; }
.cal-month .mcell.dim { background: #FAFBFE; color: var(--muted); }
.cal-month .mcell .d { font-weight: 600; margin-bottom: 3px; }
.cal-month .mcell .d.today { color: var(--accent); }
.mini-event { border-radius: 6px; padding: 1px 6px; margin-bottom: 2px; font-size: 11px;
  background: var(--accent-bg); border-left: 2px solid var(--accent); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.mini-event.has-issues { background: var(--warn-bg); border-left-color: #E8A23D; }
.mini-event.cancelled { background: #F1F2F6; border-left-color: #A6B0C3;
  text-decoration: line-through; }
.mini-event.completed { background: var(--ok-bg); border-left-color: var(--ok); }
.mini-event.ready { border-left-color: var(--ok); }
/* Team events (meetings, trainings): purple-tinted, dashed edge — visually
   distinct from streams on every calendar surface. */
.cal-event.team-event { background: #F4F1FE; border-left: 3px dashed #7A5AF8; }
.mini-event.team-event { background: #F4F1FE; border-left: 2px dashed #7A5AF8; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(22, 33, 62, .45); z-index: 40;
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px;
  overflow-y: auto; }
.modal { background: #fff; border-radius: 16px; width: 720px; max-width: 100%; padding: 22px;
  box-shadow: 0 20px 60px rgba(22, 33, 62, .28); }
.modal h2 { margin: 0 0 14px; font-size: 17px; font-weight: 700; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* Toast */
.toast-wrap { position: fixed; bottom: 18px; right: 18px; z-index: 60; display: flex;
  flex-direction: column; gap: 8px; }
.toast { background: var(--text); color: #fff; border-radius: 10px; padding: 10px 16px;
  font-size: 13px; box-shadow: 0 6px 20px rgba(22, 33, 62, .3); max-width: 380px; }
.toast.error { background: var(--danger); }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0B2E8A 0%, var(--accent) 100%); position: relative; }
.login-brand { position: absolute; top: 26px; right: 30px; width: 150px; }
@media (max-width: 820px) {
  .login-brand { width: 110px; top: 16px; right: 16px; }
}
.login-card { background: #fff; border-radius: 16px; padding: 34px; width: 380px;
  box-shadow: 0 24px 80px rgba(4, 18, 62, .45); }
.login-card h1 { margin: 0 0 4px; font-size: 22px; color: var(--text); }
.login-card p.sub { margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.login-card img.logo { width: 150px; margin-bottom: 14px; }

/* Misc */
.util-bar { height: 8px; border-radius: 4px; background: #EEF1F7; overflow: hidden; }
.util-bar > div { height: 100%; background: var(--accent); }
.empty { color: var(--muted); text-align: center; padding: 28px 0; font-size: 13px; }
.notif-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger); margin-left: 4px; vertical-align: top; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.seg { display: inline-flex; gap: 4px; }
/* Styled dialogs (v2.5) — replace native confirm/prompt */
.dlg-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center; z-index: 4000; }
.dlg-box { background: #fff; border-radius: 12px; padding: 18px 20px;
  max-width: 440px; width: calc(100% - 60px); box-shadow: 0 18px 50px rgba(0,0,0,.25); }
.dlg-msg { font-size: 14px; line-height: 1.5; white-space: pre-line; }
.dlg-input { width: 100%; margin-top: 12px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
/* Clickable issue tags (v2.5 demo round) */
.tag-chip { cursor: pointer; margin: 0 3px 3px 0; display: inline-block; user-select: none; }
.tag-chip.tag-on { outline: 2px solid var(--accent); }
/* Notification action-state flags */
.flag-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  margin-right: 5px; vertical-align: baseline; }
.flag-action { background: var(--danger); }
.flag-waiting { background: #E8A23D; }
.flag-done { background: var(--ok); }
/* Quiet planning batch (PRD v2.4) */
.batchbar { display: flex; align-items: center; gap: 10px; padding: 8px 14px;
  margin-bottom: 12px; border-radius: var(--radius); background: #FFF8E9;
  border: 1px dashed #E8A23D; }
.quiet-toggle { margin: 4px 14px 10px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
details.assign { margin-top: 4px; }
.tabbar { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 14px; }
.tabbar button { background: none; border: none; padding: 8px 14px; font-size: 13px;
  font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent;
  margin-bottom: -2px; }
.tabbar button.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Bulk selection bar (issues) */
.bulkbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: var(--accent-bg); border: 1px solid #C9DAFF; border-radius: 12px;
  padding: 10px 14px; margin-bottom: 12px; }
.bulkbar b { color: var(--accent); }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--accent); }

/* Batch-aware pickers (v2.6): people placed/freed by staged (uncommitted)
   changes in the current quiet-planning batch render tentative. */
option.opt-tent { color: #b45309; font-style: italic; }

/* Performance (v2.7): heat map, leaderboards, funnel */
.hm-wrap { overflow-x: auto; }
.hm { border-collapse: separate; border-spacing: 2px; width: 100%; }
.hm th { font-size: 11px; color: #667; font-weight: 600; padding: 2px 6px; text-align: center; }
.hm tbody th { text-align: right; white-space: nowrap; }
.hm-cell { min-width: 74px; height: 30px; border-radius: 4px; text-align: center;
  font-size: 11px; color: #23305a; cursor: default; }
.hm-legend { display: flex; align-items: center; gap: 5px; margin-top: 10px; font-size: 11px; }
.hm-swatch { width: 26px; height: 12px; border-radius: 3px; display: inline-block; }
.hm-dates { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 4px; }
.hm-date { border-radius: 6px; padding: 6px 8px; min-height: 44px; }
.hm-date-d { display: block; font-size: 11px; font-weight: 700; color: #556; }
.hm-date-v { display: block; font-size: 11px; color: #334; }
.lb-bar { position: relative; background: #eef1f8; border-radius: 4px; height: 20px;
  min-width: 170px; overflow: hidden; }
.lb-fill { position: absolute; inset: 0 auto 0 0; background: #005AFF; opacity: .85;
  border-radius: 4px 3px 3px 4px; }
.lb-bar span { position: relative; font-size: 12px; font-weight: 600; padding-left: 8px;
  line-height: 20px; color: #1a1a2e; text-shadow: 0 0 3px rgba(255,255,255,.75); }
.thin-row td { color: #99a; }
.thin-row .lb-fill { background: #b9c6e8; }
.thin-head td { font-size: 12px; color: #778; background: #f7f8fc; padding: 8px 10px; }
th.sortable { cursor: pointer; user-select: none; }
.funnel { max-width: 720px; }
.fn-row { display: flex; align-items: center; gap: 12px; }
.fn-label { width: 170px; text-align: right; font-size: 13px; font-weight: 600; }
.fn-track { position: relative; flex: 1; background: #eef1f8; border-radius: 5px; height: 34px; }
.fn-bar { position: absolute; inset: 0 auto 0 0; background: #005AFF; border-radius: 5px 4px 4px 5px; }
.fn-val { position: relative; line-height: 34px; padding-left: 10px; font-size: 13px;
  font-weight: 700; color: #fff; mix-blend-mode: difference; }
.fn-rate { margin: 3px 0 3px 182px; font-size: 12px; font-weight: 600; color: #b45309; }
.res-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 8px; }
.res-stat { background: #f7f8fc; border-radius: 6px; padding: 8px 10px; }
.res-stat b { display: block; font-size: 15px; color: #005AFF; }
.res-stat span { font-size: 11px; color: #667; }
.fn-hosts { display: grid; grid-template-columns: repeat(auto-fill, minmax(430px, 1fr)); gap: 16px; }
.fn-host { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.fn-host .fn-label { width: 130px; font-size: 12px; }
.fn-host .fn-track { height: 26px; }
.fn-host .fn-val { line-height: 26px; font-size: 12px; }
.fn-host .fn-rate { margin-left: 142px; font-size: 11px; }

/* v2.9: entity reports, manual entry, HR file */
.res-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px 12px; }
.res-form .field input { width: 100%; }

/* v3.1: modal fits content, selected chips ring pink, scrollable ledgers */
.modal { max-width: 94vw; }
.tbl-scroll { overflow-x: auto; }
.tag-chip { cursor: pointer; }
.tag-on { box-shadow: 0 0 0 2px #ff2d87; }
.avail-day { cursor: pointer; }

/* ------------------------------------------------------------------------ */
/* v3.3: mobile layout (PWA on staff phones)                                 */
/* ------------------------------------------------------------------------ */
@media (max-width: 820px) {
  .shell { flex-direction: column; min-height: 100dvh; }
  .sidebar { width: 100%; height: auto; position: sticky; top: 0; z-index: 30;
    flex-direction: column; padding: 8px 0 0; border-right: none;
    border-bottom: 1px solid var(--border); }
  .sidebar .logo { display: flex; align-items: baseline; gap: 8px;
    padding: 2px 14px 8px; }
  .sidebar .logo img { width: 92px; }
  .sidebar .logo span { margin-top: 0; }
  .sidebar nav { flex-direction: row; overflow-x: auto; gap: 2px;
    padding: 0 8px 8px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .sidebar nav::-webkit-scrollbar { display: none; }
  .sidebar nav a { white-space: nowrap; padding: 8px 11px; font-size: 13px; }
  .sidebar .foot { margin-top: 0; padding: 8px 14px;
    display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--border); }
  .sidebar .foot > div:first-child { flex: 1; }
  .sidebar .foot a { margin-top: 0 !important; display: inline !important; }
  .quiet-toggle { position: absolute; top: 10px; right: 12px; }
  .main { padding: 14px 12px calc(20px + env(safe-area-inset-bottom)); }
  .topbar h1 { font-size: 18px; }
  .modal { width: 100%; max-width: 100vw; border-radius: 16px 16px 0 0;
    max-height: 92dvh; overflow-y: auto; }
  .modal-backdrop { align-items: flex-end; }
  .login-card { width: 100%; max-width: 380px; margin: 0 14px; padding: 26px 22px; }
  .fn-hosts { grid-template-columns: 1fr; }
  .fn-label { width: 110px; font-size: 12px; }
  .fn-rate { margin-left: 122px; }
  table.grid { display: block; overflow-x: auto; white-space: nowrap; }
  .res-form { grid-template-columns: 1fr 1fr; }
}


/* v3.4: live demo agency bar, master-view banner, shell offset */
.demo-live-bar { position: fixed; top: 0; left: 0; right: 0; height: 46px; z-index: 90;
  background: #101220; color: #E8ECF6; display: flex; align-items: center; gap: 8px;
  padding: 0 14px; font-size: 12px; overflow-x: auto; scrollbar-width: none; }
.demo-live-bar::-webkit-scrollbar { display: none; }
.demo-live-bar .demo-tag { background: #FF2D87; color: #fff; font-weight: 800;
  border-radius: 6px; padding: 3px 8px; font-size: 11px; letter-spacing: .5px; }
.demo-live-bar .demo-text { opacity: .85; white-space: nowrap; }
.demo-live-bar .demo-persona { background: transparent; color: #E8ECF6;
  border: 1px solid rgba(255,255,255,.28); border-radius: 999px; padding: 4px 12px;
  font-size: 12px; cursor: pointer; white-space: nowrap; }
.demo-live-bar .demo-persona:hover { background: rgba(255,255,255,.12); }
.demo-live-bar .demo-clock { white-space: nowrap; font-weight: 600;
  color: #9fb4ff; margin-left: 6px; }
.shell.with-demo-bar { padding-top: 46px; }
.shell.with-demo-bar .sidebar { top: 46px; height: calc(100vh - 46px); }
@media (max-width: 820px) {
  .shell.with-demo-bar .sidebar { height: auto; }
}

.master-banner { background: #3B2A6E; color: #EDE8FF; border-radius: 10px;
  padding: 10px 16px; font-size: 13px; margin-bottom: 14px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); }
.master-banner b { color: #fff; }

/* v3.4: iPhone safe area — keep the top bar clear of the clock / Dynamic
   Island when installed to the home screen (viewport-fit=cover) */
@supports (padding: env(safe-area-inset-top)) {
  @media (max-width: 820px) {
    .sidebar { padding-top: calc(8px + env(safe-area-inset-top)); }
    .demo-live-bar { padding-top: env(safe-area-inset-top);
      height: calc(46px + env(safe-area-inset-top)); }
    .shell.with-demo-bar { padding-top: calc(46px + env(safe-area-inset-top)); }
    .shell.with-demo-bar .sidebar { top: calc(46px + env(safe-area-inset-top)); }
    .login-brand { top: calc(16px + env(safe-area-inset-top)); }
    .login-wrap { padding-top: env(safe-area-inset-top); }
  }
}

/* ------------------------------------------------------------------------ */
/* v3.4.1: portrait-phone card layout — the standing rule: action buttons    */
/* are never off-screen to the right. On narrow screens, list tables become  */
/* stacked cards; only wide data ledgers (inside .tbl-scroll) keep sideways  */
/* scrolling, since they are reading surfaces, not action surfaces.          */
/* ------------------------------------------------------------------------ */
@media (max-width: 600px) {
  table.grid { display: block; white-space: normal; overflow: visible; }
  table.grid thead { display: none; }
  table.grid tbody { display: block; }
  table.grid tr { display: block; border: 1px solid var(--border);
    border-radius: 12px; margin-bottom: 10px; padding: 9px 12px;
    background: #fff; }
  table.grid td { display: block; border: none; padding: 2px 0;
    max-width: none !important; width: auto !important; white-space: normal; }
  table.grid td:first-child { padding-top: 0; }
  table.grid td:empty { display: none; padding: 0; }
  table.grid tr:hover td { background: transparent; }
  table.grid td .row, table.grid td .btn { margin-top: 4px; }
  table.grid tr td[colspan] { border: none; background: transparent !important;
    padding: 4px 2px; margin-bottom: -4px; }

  /* wide data ledgers stay tables and scroll sideways inside their wrapper */
  .tbl-scroll table.grid { display: table; white-space: nowrap; min-width: 640px; }
  .tbl-scroll table.grid thead { display: table-header-group; }
  .tbl-scroll table.grid tbody { display: table-row-group; }
  .tbl-scroll table.grid tr { display: table-row; border: none;
    border-radius: 0; margin: 0; padding: 0; }
  .tbl-scroll table.grid td { display: table-cell; padding: 10px 12px;
    border-bottom: 1px solid var(--border); }

  /* filter/bulk toolbars breathe instead of colliding */
  .bulkbar { padding: 8px 10px; }
  .topbar h1 { font-size: 17px; }
  .panel { padding: 14px; }
}

@media (max-width: 600px) {
  .tabbar { flex-wrap: wrap; }
  .sidebar .foot select { max-width: 52vw; }
}
