/* ============================================================
   NerdRota, styled to the Nerdience brand kit.
   Light UI: white + Nerdience yellow, slate text (no black).
   Palette: yellow #FFD422 / #E7B200, neutrals #FFFFFF #F6F6F6,
   slate accents #2E4057 #505F72 #727E8E. Type: Poppins.
   ============================================================ */
:root {
  --bg: #f6f6f6;
  --surface: #ffffff;
  --surface-2: #f6f6f6;
  --border: #e7e8ec;
  --text: #2e4057;        /* dark slate, used instead of black */
  --text-muted: #727e8e;

  --primary: #ffd422;      /* Nerdience yellow */
  --primary-strong: #e7b200;
  --primary-soft: #fff6d1;
  --primary-shadow: rgba(231,178,0,.4);   /* brand-tinted; overridden per org */
  --primary-ring: rgba(231,178,0,.35);
  --slate: #2e4057;
  --slate-2: #505f72;
  --danger: #d9534f;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(46,64,87,.06), 0 1px 3px rgba(46,64,87,.05);
  --shadow: 0 4px 12px rgba(46,64,87,.08);
  --shadow-lg: 0 12px 32px rgba(46,64,87,.14);

  --font: "Poppins", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  /* faint grid texture from the brand kit */
  --grid: linear-gradient(#eceef1 1px, transparent 1px), linear-gradient(90deg, #eceef1 1px, transparent 1px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
h1, h2, h3, .brand-name { font-weight: 700; letter-spacing: -0.01em; }
.hidden { display: none !important; }
.tabular { font-variant-numeric: tabular-nums; }

/* ---------- Brand / logo ---------- */
.brand { display: flex; align-items: center; gap: .6rem; }
.brand-name { font-size: 1.2rem; color: var(--slate); }
.logo {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: var(--primary); display: grid; place-items: center;
  box-shadow: 0 3px 8px var(--primary-shadow);
}
.logo svg { width: 20px; height: 20px; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
  background: var(--bg); background-image: var(--grid); background-size: 28px 28px;
}
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: var(--shadow-lg); width: 100%; max-width: 380px; padding: 2.2rem; }
.login-card .brand { margin-bottom: 1.4rem; }
.subtle { color: var(--text-muted); font-size: .9rem; }

/* ---------- Controls ---------- */
label { display: block; font-size: .82rem; font-weight: 600; color: var(--text-muted); margin-bottom: .35rem; }
input:not([type=checkbox]):not([type=radio]):not([type=color]), select, textarea {
  width: 100%; font-family: inherit; font-size: .93rem; padding: .6rem .75rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s, background .15s; box-shadow: var(--shadow-2xs, 0 1px 1px rgba(46,64,87,.03)); }
input:not([type=checkbox]):not([type=radio]):not([type=color]):hover, select:hover, textarea:hover { border-color: #cdd2db; }
input:not([type=checkbox]):not([type=radio]):not([type=color]):focus, select:focus, textarea:focus { outline: none; border-color: var(--primary-strong);
  box-shadow: 0 0 0 3px var(--primary-ring); }
/* Clean, on-brand checkbox */
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--primary-strong); cursor: pointer; margin: 0; }
.field { margin-bottom: .9rem; }

/* Premium select: custom caret, no native arrow */
select { -webkit-appearance: none; appearance: none; padding-right: 2rem; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23727e8e' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right .6rem center; }
/* Premium date & time pickers: branded calendar/clock icon, aligned spacing */
input[type="date"], input[type="time"] { position: relative; cursor: pointer; font-variant-numeric: tabular-nums; }
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator { opacity: .55; cursor: pointer; border-radius: 4px; padding: 3px; transition: opacity .15s, background .15s; }
input[type="date"]:hover::-webkit-calendar-picker-indicator,
input[type="time"]:hover::-webkit-calendar-picker-indicator { opacity: 1; background: var(--primary-soft); }
input[type="date"]::-webkit-datetime-edit,
input[type="time"]::-webkit-datetime-edit { padding: 0; color: var(--text); font-weight: 500; }
input[type="time"]::-webkit-datetime-edit-hour-field:focus,
input[type="time"]::-webkit-datetime-edit-minute-field:focus,
input[type="time"]::-webkit-datetime-edit-ampm-field:focus,
input[type="date"]::-webkit-datetime-edit-day-field:focus,
input[type="date"]::-webkit-datetime-edit-month-field:focus,
input[type="date"]::-webkit-datetime-edit-year-field:focus { background: var(--primary); color: var(--slate); border-radius: 3px; }

.btn { font-family: inherit; font-weight: 600; font-size: .88rem; padding: .55rem 1rem; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer; background: var(--surface-2); color: var(--text);
  transition: transform .05s, box-shadow .15s, background .15s; }
.btn:hover { box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: var(--slate); border-color: var(--primary-strong); }
.btn-primary:hover { background: var(--primary-strong); }
.btn-accent { background: var(--slate); color: #fff; }
.btn-accent:hover { background: var(--slate-2); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-danger { background: transparent; color: var(--danger); border-color: transparent; }
.btn-block { width: 100%; }
.btn-sm { padding: .32rem .6rem; font-size: .8rem; }
.error-msg { color: var(--danger); font-size: .84rem; margin-top: .5rem; min-height: 1rem; }

/* ---------- Shell ---------- */
.app { display: grid; grid-template-columns: 244px 1fr; min-height: 100vh; align-items: start; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border);
  padding: 1.4rem 1rem; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand-name { color: var(--slate); }
.org-switch-wrap { margin-top: 1rem; padding: .5rem .6rem; border: 1px solid var(--primary); border-radius: var(--radius-sm); background: var(--primary-soft); }
.org-switch-label { display: block; font-size: .62rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--slate-2); margin-bottom: .25rem; }
.org-switch-control { display: flex; align-items: center; gap: .45rem; color: var(--slate); }
.org-logo { width: 22px; height: 22px; object-fit: contain; border-radius: 4px; flex: none; }
.org-switch-control select { flex: 1; font-weight: 700; font-size: .92rem; border: none; box-shadow: none; padding: .1rem 1.5rem .1rem 0; color: var(--slate);
  background-color: transparent;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%232e4057' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right .1rem center; }
.org-switch-control select:focus { box-shadow: none; }
.org-name { flex: 1; font-weight: 700; font-size: .92rem; color: var(--slate); }
.nav { display: flex; flex-direction: column; gap: .15rem; margin-top: 1.2rem; flex: 1; }
.nav-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin: 1rem .75rem .35rem; }
.nav-item { display: flex; align-items: center; gap: .6rem; text-align: left; border: none; background: transparent;
  font-family: inherit; font-size: .92rem; font-weight: 500; padding: .55rem .75rem; border-radius: var(--radius-sm);
  cursor: pointer; color: var(--slate-2); }
.nav-item:hover { background: var(--surface-2); color: var(--slate); }
.nav-item.active { background: var(--primary); color: var(--slate); font-weight: 600; box-shadow: 0 3px 8px var(--primary-ring); }
.side-foot { border-top: 1px solid var(--border); padding-top: .9rem; }
.who { font-size: .85rem; margin-bottom: .6rem; color: var(--text-muted); }
.who strong { display: block; color: var(--slate); }

.main { padding: 1.9rem 2.2rem; overflow-x: auto; background: var(--bg); background-image: var(--grid); background-size: 28px 28px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.page-title { font-size: 1.55rem; color: var(--slate); }
.page-sub { color: var(--text-muted); margin-top: .15rem; }

/* ---------- Cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.6rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; box-shadow: var(--shadow-sm); }
.card .metric { font-size: 1.9rem; font-weight: 700; color: var(--slate); }
.card .metric-label { color: var(--text-muted); font-size: .84rem; margin-top: .1rem; }
.card .metric.accent { color: var(--primary-strong); }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.3rem 1.4rem; box-shadow: var(--shadow-sm); margin-bottom: 1.4rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.panel h3 { font-size: 1.02rem; color: var(--slate); }
.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 150px; }
.check { display: flex; align-items: center; gap: .5rem; }
.check input { width: auto; }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .62rem .7rem; border-bottom: 1px solid var(--border); }
th { font-weight: 600; color: var(--text-muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:hover { background: var(--surface-2); }
tfoot td { font-weight: 700; color: var(--slate); border-top: 2px solid var(--border); border-bottom: none; }

.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .74rem; font-weight: 600; }
.badge-bill { background: var(--primary-soft); color: var(--primary-strong); }
.badge-nonbill { background: var(--surface-2); color: var(--text-muted); }
.badge-cat { background: #eef1f5; color: var(--slate-2); }
.badge-arch { background: #eef1f5; color: var(--text-muted); }
.badge-lock { background: transparent; padding: 0; }
.pill-count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: .4rem;
  background: var(--danger); color: #fff; border-radius: 999px; font-size: .7rem; font-weight: 700; }
.nav-item.active .pill-count { background: var(--slate); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .45rem; vertical-align: -1px; }
.proj-cell { display: flex; align-items: center; }

.filters { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1.25rem; }
.filters .field { margin-bottom: 0; }
.empty { color: var(--text-muted); padding: 2rem; text-align: center; }
.pill-tabs { display: inline-flex; gap: .25rem; background: var(--surface); border: 1px solid var(--border); padding: .25rem; border-radius: 999px; margin-bottom: 1rem; }
.pill-tabs button { border: none; background: transparent; font-family: inherit; font-weight: 600; font-size: .84rem; padding: .35rem .85rem; border-radius: 999px; cursor: pointer; color: var(--text-muted); }
.pill-tabs button.active { background: var(--primary); color: var(--slate); }

/* ---------- Legend ---------- */
.legend { display: flex; align-items: center; gap: .9rem; font-size: .8rem; color: var(--text-muted); flex-wrap: wrap; }
.legend .lg { display: inline-flex; align-items: center; gap: .35rem; }
.legend .sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend .sw-bill { background: var(--primary); }
.legend .sw-nonbill { background: var(--slate-2); }

/* ---------- Grouped + stacked bar chart ---------- */
.chart-grouped { display: flex; align-items: flex-end; gap: .4rem; height: 220px; padding-top: 1rem; overflow-x: auto; }
.gcol { flex: 1 0 auto; min-width: 46px; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
.gpair { display: flex; align-items: flex-end; gap: 4px; height: 100%; }
.gwrap { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.gbar { position: relative; width: 16px; display: flex; flex-direction: column-reverse; justify-content: flex-start; height: 100%; }
.seg { width: 100%; min-height: 2px; }
.seg-bill { background: var(--primary); border-radius: 4px 4px 0 0; }
.seg-nonbill { background: var(--slate-2); }
.gbar .seg-bill:not(:first-child) { border-radius: 0; }
.gbar-val { position: absolute; top: -1.1rem; left: 50%; transform: translateX(-50%); font-size: .64rem; font-weight: 600; color: var(--slate); }
.gsub { font-size: .62rem; color: var(--text-muted); margin-top: .2rem; }
.gcol-label { font-size: .72rem; color: var(--text-muted); margin-top: .3rem; text-align: center; }
.chart-grouped { position: relative; }
.goal-line { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--slate-2); opacity: .55; pointer-events: none; }
.goal-line span { position: absolute; right: 0; top: -0.9rem; font-size: .66rem; color: var(--slate-2); background: var(--surface); padding: 0 .3rem; }
.daystat { margin-top: .35rem; color: #fff; font-size: .68rem; font-weight: 700; padding: .05rem .4rem; border-radius: 999px; }
.goal-banner { display: flex; align-items: center; gap: .5rem; background: var(--primary-soft); border: 1px solid var(--primary); color: var(--slate); border-radius: var(--radius-sm); padding: .5rem .8rem; font-size: .86rem; font-weight: 500; margin-bottom: 1.1rem; }
/* Modal overlay */
.modal-overlay { position: fixed; inset: 0; background: rgba(46,64,87,.45); display: grid; place-items: center; z-index: 9998; padding: 1rem; }
.modal-overlay.hidden { display: none; }
.modal-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); width: 100%; max-width: 420px; padding: 1.4rem 1.5rem; }
.assign-list { max-height: 50vh; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .3rem; }
.assign-list label { display: flex; align-items: center; gap: .55rem; padding: .45rem .5rem; border-radius: var(--radius-sm); cursor: pointer; color: var(--text); font-weight: 500; text-transform: none; font-size: .92rem; margin: 0; }
.assign-list label:hover { background: var(--surface-2); }

/* Transient top-center confirmation toast */
.toast { position: fixed; top: 1rem; left: 50%; transform: translateX(-50%) translateY(-12px); background: var(--slate); color: #fff; padding: .6rem 1.15rem; border-radius: 999px; font-weight: 600; font-size: .9rem; box-shadow: var(--shadow-lg); z-index: 9999; opacity: 0; transition: opacity .18s ease, transform .18s ease; pointer-events: none; display: flex; align-items: center; gap: .45rem; }
.toast::before { content: "✓"; color: #6ee7b7; font-weight: 800; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.hidden { display: none; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 3.6rem; }
.pw-toggle { position: absolute; right: .4rem; top: 50%; transform: translateY(-50%); border: none; background: transparent; color: var(--primary-strong); font-family: inherit; font-weight: 600; font-size: .8rem; cursor: pointer; padding: .2rem .4rem; border-radius: 6px; }
.pw-toggle:hover { background: var(--primary-soft); }
.swatches { display: flex; gap: .5rem; flex-wrap: wrap; padding-top: .15rem; }
.swatch { width: 30px; height: 30px; border-radius: 8px; border: 2px solid transparent; cursor: pointer; padding: 0; box-shadow: var(--shadow-2xs, 0 1px 2px rgba(46,64,87,.12)); transition: transform .08s; }
.swatch:hover { transform: scale(1.08); }
.swatch.active { border-color: var(--slate); box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--slate); }
#durationHint { display: inline-block; background: var(--primary-soft); color: var(--slate); font-weight: 600; padding: .35rem .7rem; border-radius: 999px; font-size: .82rem; border: 1px solid var(--primary); }
.pill-tabs { box-shadow: var(--shadow-2xs, 0 1px 1px rgba(46,64,87,.04)); }
.pill-tabs button { transition: background .15s, color .15s; }
.chart-caption { text-align: center; font-size: .78rem; color: var(--text-muted); margin-top: .5rem; }
/* ---------- Daily roster grid ---------- */
.rosterwrap { max-height: 68vh; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.roster-table { border-collapse: separate; border-spacing: 0; }
.roster-table th, .roster-table td { background: var(--surface); }
.roster-table thead th { position: sticky; top: 0; z-index: 2; box-shadow: inset 0 -1px 0 var(--border); }
/* Freeze the first three columns (Operator, Alloc, Left) on the left */
.roster-table thead th:nth-child(1), .roster-table tbody td:nth-child(1) { position: sticky; left: 0; z-index: 1; min-width: 150px; box-shadow: inset -1px 0 0 var(--border); }
.roster-table thead th:nth-child(1) { z-index: 3; }
.roster-table td { vertical-align: top; }
.saved-tag { display: inline-block; background: var(--accent-soft, #e6f7f1); color: #0b7a58; font-size: .68rem; font-weight: 700; padding: .1rem .45rem; border-radius: 999px; margin-left: .4rem; }
.roster-alloc { font-weight: 700; border-radius: 6px; text-align: center; }
.roster-alloc.over { color: #8b0000; background: #fde2e1; }
.roster-alloc.full { color: #0b7a58; background: var(--accent-soft, #e6f7f1); }
.roster-alloc.under { color: var(--text-muted); }
.roster-cell { min-width: 150px; }
.roster-h { width: 100%; font-weight: 600; margin-bottom: .25rem; }
.roster-n { width: 100%; font-size: .8rem; }
.roster-act { font-size: .7rem; color: var(--text-muted); margin-top: .2rem; }
.roster-act.over { color: #8b0000; font-weight: 600; }
.notif { padding: .8rem 1.1rem; border-bottom: 1px solid var(--border); }
.notif.unread { background: var(--primary-soft); }
.gcol-off { opacity: .6; }
.status-legend { display: flex; gap: .8rem; flex-wrap: wrap; font-size: .74rem; color: var(--text-muted); margin-top: .6rem; }
.status-legend span { display: inline-flex; align-items: center; gap: .3rem; }
.status-legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

/* ---------- About / How this works ---------- */
.about { max-width: 760px; }
.about h3 { margin-bottom: .6rem; }
.about p { color: var(--text); line-height: 1.6; margin-bottom: .7rem; }
.about ul { list-style: none; margin: .3rem 0 .7rem; }
.about li { padding: .2rem 0; color: var(--text); }
.ac-dot { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: .5rem; vertical-align: -1px; }

@media (max-width: 780px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { flex-direction: column; }
  .nav { flex-direction: row; flex-wrap: wrap; margin-top: 1rem; }
  .nav-label { display: none; }
}
