/* ==========================================================================
   Pulse and Purpose — admin area & instructor portal
   Builds on styles.css (tokens, buttons, fonts).
   ========================================================================== */

body.portal { background: var(--cream); min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- Top bar ---------- */

.portal-bar { position: sticky; top: 0; z-index: 40; background: var(--ink); color: #fff; }
.portal-bar .bar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 64px; }
.portal-bar .brand { color: #fff; font-size: 1.15rem; }
.portal-bar .brand svg { width: 32px; height: 32px; }
.portal-bar .brand em { color: #ff8b98; }
.portal-tag {
  margin-left: 4px; padding: 4px 9px; border-radius: 999px; background: rgba(255, 255, 255, .12);
  font: 700 .68rem/1 "DM Sans", system-ui, sans-serif; letter-spacing: .1em; text-transform: uppercase; color: #fff;
}
.bar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.bar-user { display: flex; align-items: center; gap: 14px; font-size: .9rem; color: rgba(255, 255, 255, .8); min-width: 0; }
.bar-user .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 34vw; }
.btn-text {
  border: 0; background: none; padding: 6px 2px; cursor: pointer; color: inherit;
  font: 600 .9rem "DM Sans", system-ui, sans-serif; text-decoration: underline; text-underline-offset: 3px;
}
.portal-bar .btn-text { color: #ffb3bb; white-space: nowrap; }
@media (max-width: 420px) { .portal-bar .brand span { font-size: 1rem; } .portal-tag { display: none; } }
@media (max-width: 560px) { .bar-user .who { display: none; } }

.demo-banner {
  background: #fff4d6; color: #6b4a00; border-bottom: 1px solid #f1dc9c;
  font-size: .9rem; padding: 10px 0;
}
.demo-banner .container { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; justify-content: space-between; }
.demo-banner .btn-text { color: #6b4a00; }

.portal-main { flex: 1; padding: 28px 0 64px; }
.portal-foot { padding: 20px 0 28px; font-size: .85rem; color: var(--muted); }
.portal-foot a { color: var(--muted); }

/* ---------- Sign-in ---------- */

.login-wrap { display: grid; place-items: center; padding: 40px 0; }
.login-card {
  width: min(440px, 100%); margin: 24px auto; background: var(--paper); border: 1px solid var(--line); border-radius: 28px;
  padding: clamp(26px, 5vw, 40px); box-shadow: var(--shadow); text-align: center;
}
.login-logo svg { width: 52px; height: 52px; margin: 0 auto 18px; }
.login-card h1 { font-size: 2rem; }
.login-form { text-align: left; display: grid; gap: 10px; margin: 22px 0 8px; }
.login-form label { font-weight: 600; font-size: .93rem; }
.login-status { margin: 4px 0 0; font-size: .92rem; }
.login-status:empty { display: none; }
.login-status.error { color: #b0142a; }
.login-status.ok { color: var(--success); background: #eaf6ef; padding: 12px 14px; border-radius: 12px; }
.demo-logins { margin-top: 18px; padding: 16px; border-radius: 16px; background: #fff8e6; border: 1px dashed #e8cf86; text-align: left; }
.demo-logins p { margin: 0 0 10px; }
.demo-login-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 12px; cursor: pointer;
  font: 500 .88rem "DM Sans", system-ui, sans-serif; color: var(--ink);
}
.chip-btn:hover { border-color: var(--red); color: var(--red-deep); }

.notice-card {
  width: min(560px, 100%); margin: 40px auto; background: var(--paper); border: 1px solid var(--line);
  border-radius: 24px; padding: 32px; text-align: center;
}

/* ---------- Page heading & tabs ---------- */

.portal-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin-bottom: 22px; }
.portal-head h1 { font-size: clamp(1.8rem, 3.4vw, 2.5rem); margin: 0; }
.portal-head p { margin: 6px 0 0; color: var(--muted); }

.ptabs {
  display: flex; gap: 4px; padding: 5px; margin-bottom: 24px; overflow-x: auto;
  background: var(--paper); border: 1px solid var(--line); border-radius: 18px; scrollbar-width: none;
}
.ptabs::-webkit-scrollbar { display: none; }
.ptab {
  flex: 1 0 auto; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 16px; border: 0; border-radius: 13px; background: transparent; cursor: pointer;
  font: 600 .95rem "DM Sans", system-ui, sans-serif; color: var(--ink-soft); white-space: nowrap;
}
.ptab:hover { background: var(--sand); color: var(--ink); }
.ptab[aria-selected="true"] { background: var(--ink); color: #fff; }
.ptab .ico svg { width: 18px; height: 18px; display: block; }
.ptab .count { font-size: .75rem; padding: 2px 7px; border-radius: 999px; background: rgba(0, 0, 0, .07); }
.ptab[aria-selected="true"] .count { background: rgba(255, 255, 255, .18); }

/* ---------- Toolbar, stats ---------- */

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.toolbar select, .toolbar input[type="search"] { width: auto; min-width: 150px; padding: 10px 40px 10px 13px; font-size: .93rem; border-radius: 12px; }
.toolbar input[type="search"] { padding-right: 13px; min-width: 200px; }
.toolbar .spacer { flex: 1; }
.toolbar .check { display: inline-flex; gap: 8px; align-items: center; font-size: .92rem; color: var(--ink-soft); cursor: pointer; }
.toolbar .check input { width: 18px; height: 18px; accent-color: var(--red); }
@media (max-width: 640px) {
  .toolbar select, .toolbar input[type="search"] { flex: 1 1 100%; min-width: 0; }
  .toolbar .spacer { display: none; }
  .toolbar .btn { flex: 1 1 100%; }
}

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 22px; }
.stat-tile { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 16px 18px; }
.stat-tile .k { font-size: .82rem; color: var(--muted); font-weight: 500; }
.stat-tile .v { font-family: "Fraunces", Georgia, serif; font-size: 2rem; font-weight: 600; line-height: 1.1; margin-top: 4px; }
.stat-tile.alert .v { color: var(--red); }
@media (max-width: 760px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }

/* ---------- Badges ---------- */

.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  font-size: .78rem; font-weight: 600; line-height: 1.3; white-space: nowrap;
  background: var(--sand); color: var(--ink-soft);
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.ok { background: #e3f3ea; color: #17633d; }
.badge.warn { background: #fff1d6; color: #8a5a00; }
.badge.bad { background: #fde3e3; color: #a3142a; }
.badge.info { background: #e6eefc; color: #234b9a; }
.badge.plain::before { display: none; }

/* ---------- Data table (cards on small screens) ---------- */

.ptable-wrap { background: var(--paper); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; }
.ptable { width: 100%; border-collapse: collapse; font-size: .93rem; }
.ptable th {
  text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
  font-weight: 700; padding: 14px 16px; background: #fcfaf7; border-bottom: 1px solid var(--line);
}
.ptable td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.ptable tr:last-child td { border-bottom: 0; }
.ptable tbody tr { transition: background .12s ease; }
.ptable tbody tr:hover { background: #fffbf6; }
.ptable .strong { font-weight: 600; }
.ptable .sub { display: block; color: var(--muted); font-size: .85rem; margin-top: 2px; }
.ptable .actions { text-align: right; white-space: nowrap; }
.ptable .when { display: flex; align-items: center; gap: 12px; }
.ptable .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 600; letter-spacing: .04em; }
.btn-sm { padding: 8px 14px; font-size: .85rem; }
.btn-danger { background: #b0142a; color: #fff; }
.btn-danger:hover { background: #8d0f21; }
.link-btn { border: 0; background: none; padding: 4px 6px; cursor: pointer; font: 600 .88rem "DM Sans", system-ui, sans-serif; color: var(--red-deep); }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
.slot-open { color: var(--red-deep); font-weight: 600; }

@media (max-width: 860px) {
  .ptable thead { display: none; }
  .ptable, .ptable tbody, .ptable tr, .ptable td { display: block; width: 100%; }
  .ptable tr { padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .ptable tr:last-child { border-bottom: 0; }
  .ptable td { border: 0; padding: 5px 0; display: flex; gap: 12px; justify-content: space-between; align-items: center; }
  .ptable td::before { content: attr(data-label); font-size: .78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; flex: none; }
  .ptable td.primary::before, .ptable td.actions::before { display: none; }
  .ptable td.primary { padding-bottom: 8px; }
  .ptable td > :last-child { text-align: right; }
  .ptable td.primary > :last-child { text-align: left; }
  .ptable .actions { justify-content: flex-end; padding-top: 8px; }
}

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty h3 { color: var(--ink); }

/* ---------- Date chip ---------- */

.date-chip {
  flex: none; width: 54px; min-height: 58px; padding: 6px 0; border-radius: 12px; background: var(--cream); border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; text-align: center;
}
.date-chip .mon { font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--red-deep); }
.date-chip .day { font-family: "Fraunces", Georgia, serif; font-size: 1.4rem; font-weight: 600; }
.date-chip .wd { font-size: .7rem; color: var(--muted); }

/* ---------- Dialogs ---------- */

.dlg {
  width: min(680px, calc(100% - 24px)); max-height: calc(100dvh - 32px); padding: 0; border: 0; border-radius: 26px;
  background: var(--paper); color: var(--ink); box-shadow: 0 30px 80px -20px rgba(27, 20, 32, .45);
}
.dlg.wide { width: min(860px, calc(100% - 24px)); }
.dlg.small { width: min(440px, calc(100% - 24px)); }
.dlg::backdrop { background: rgba(27, 20, 32, .5); backdrop-filter: blur(3px); }
.dlg-form { display: flex; flex-direction: column; max-height: calc(100dvh - 32px); }
.dlg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 24px 26px 14px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { font-size: 1.5rem; margin: 0; }
.dlg-head p { margin: 4px 0 0; }
.dlg-close { border: 0; background: var(--sand); width: 36px; height: 36px; border-radius: 50%; font-size: 1.4rem; line-height: 1; cursor: pointer; color: var(--ink); flex: none; }
.dlg-body { padding: 20px 26px; overflow-y: auto; }
.dlg-body > p { margin-top: 0; }
.dlg-error { margin: 0 26px 10px; padding: 12px 14px; border-radius: 12px; background: #fde3e3; color: #8d0f21; font-size: .92rem; font-weight: 500; }
.dlg-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 26px 22px; border-top: 1px solid var(--line); }
.dlg-actions-right { display: flex; gap: 10px; margin-left: auto; }
@media (max-width: 520px) {
  .dlg-head, .dlg-body { padding-left: 18px; padding-right: 18px; }
  .dlg-actions { padding: 14px 18px 18px; }
  .dlg-actions-right { width: 100%; }
  .dlg-actions-right .btn { flex: 1; }
}

.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.fgrid.three { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 560px) { .fgrid, .fgrid.three { grid-template-columns: 1fr; } }
.pfield { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.pfield.full { grid-column: 1 / -1; }
.pfield label { font-weight: 600; font-size: .88rem; }
.pfield .optional { font-weight: 400; color: var(--muted); }
.pfield .hint { margin: 0; font-size: .82rem; color: var(--muted); }
.pfield input, .pfield select, .pfield textarea { padding: 11px 13px; border-radius: 12px; font-size: .95rem; }
.pfield select { padding-right: 40px; }
.pfield textarea { min-height: 84px; }
.dlg-section { margin: 6px 0 14px; padding-top: 16px; border-top: 1px dashed var(--line); }
.dlg-section:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.dlg-section > h3 { font-family: "DM Sans", system-ui, sans-serif; font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; }
.dlg-note { font-size: .85rem; color: var(--muted); background: var(--cream); border: 1px solid var(--line); padding: 10px 12px; border-radius: 12px; margin: 0 0 14px; }
.dlg-note.warn { background: #fff4d6; border-color: #f1dc9c; color: #6b4a00; }
.input-row { display: flex; gap: 8px; }
.input-row > input { flex: 1; min-width: 0; }
.checks-inline { display: flex; flex-wrap: wrap; gap: 8px; }
.check-pill { position: relative; display: inline-flex; }
.check-pill input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.check-pill span { padding: 8px 13px; border-radius: 999px; border: 1.5px solid var(--line); background: #fff; font-size: .9rem; font-weight: 500; cursor: pointer; }
.check-pill input:checked + span { border-color: var(--red); background: var(--blush); color: var(--red-deep); }
.check-pill input:focus-visible + span { outline: 3px solid var(--red); outline-offset: 2px; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; font-size: .93rem; }
.switch input { width: 20px; height: 20px; accent-color: var(--red); }

/* ---------- Settings ---------- */

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 860px) { .settings-grid { grid-template-columns: 1fr; } }
.panel-card { background: var(--paper); border: 1px solid var(--line); border-radius: 22px; padding: 24px; }
.panel-card h2 { font-size: 1.35rem; margin-bottom: 6px; }
.panel-card > p { color: var(--muted); font-size: .92rem; }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; padding: 0; list-style: none; }
.tag-list li { display: inline-flex; align-items: center; gap: 6px; padding: 7px 8px 7px 13px; border-radius: 999px; background: var(--cream); border: 1px solid var(--line); font-size: .9rem; font-weight: 500; }
.tag-list button { border: 0; background: var(--sand); width: 22px; height: 22px; border-radius: 50%; cursor: pointer; line-height: 1; font-size: 1rem; color: var(--ink-soft); }
.tag-list button:hover { background: var(--red); color: #fff; }

/* ---------- Instructor portal ---------- */

.alert-card { display: flex; gap: 14px; align-items: flex-start; padding: 18px 20px; border-radius: 18px; margin-bottom: 22px; background: #fff4d6; border: 1px solid #f1dc9c; color: #5a3e00; }
.alert-card .ico svg { width: 22px; height: 22px; display: block; }
.alert-card p { margin: 2px 0 0; font-size: .93rem; }
.board-section { margin-bottom: 34px; }
.board-section > h2 { font-size: 1.5rem; margin-bottom: 4px; }
.board-section > p { color: var(--muted); margin-bottom: 16px; }
.shift-list { display: grid; gap: 12px; }
.shift-card {
  display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center;
  background: var(--paper); border: 1px solid var(--line); border-radius: 20px; padding: 16px 18px;
}
.shift-card .info { min-width: 0; }
.shift-card .info h3 { font-family: "DM Sans", system-ui, sans-serif; font-size: 1.02rem; font-weight: 700; margin: 0 0 3px; letter-spacing: 0; }
.shift-card .meta { color: var(--muted); font-size: .9rem; display: flex; flex-wrap: wrap; gap: 2px 14px; }
.shift-card .team { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.shift-card .do { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.shift-card .do .why { font-size: .8rem; color: var(--muted); max-width: 180px; text-align: right; }
@media (max-width: 640px) {
  .shift-card { grid-template-columns: auto 1fr; }
  .shift-card .do { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; }
  .shift-card .do .btn { flex: 1; }
  .shift-card .do .why { text-align: left; max-width: none; }
}
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 760px) { .profile-grid { grid-template-columns: 1fr; } }
.kv { display: grid; gap: 10px; margin: 0; }
.kv > div { display: flex; justify-content: space-between; gap: 16px; font-size: .93rem; padding-bottom: 10px; border-bottom: 1px dashed var(--line); }
.kv > div:last-child { border-bottom: 0; padding-bottom: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; text-align: right; }

/* ---------- Toast ---------- */

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 100; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 13px 20px; border-radius: 14px; background: var(--ink); color: #fff; font-weight: 500; font-size: .95rem;
  box-shadow: var(--shadow); transition: opacity .2s ease, transform .2s ease; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #8d0f21; }

.loading { padding: 60px 0; text-align: center; color: var(--muted); }
