/* =============================================================
   Worksteady portals: staff admin (/admin/) and school partners (/partners/)
   Built on the site's tokens and form styles. Dense enough for daily use,
   readable on a phone. Same colours as the site: a black bar, white
   cards on light grey, black type and yellow accents. The one loud
   moment is the school's next payment.
   ============================================================= */

.portal { background: var(--paper); min-height: 100vh; }
/* Classes below set display, so make the hidden attribute always win on these pages */
.portal [hidden] { display: none !important; }
.portal h2, .portal h3 { font-weight: 800; font-stretch: 106%; letter-spacing: -0.01em; }

/* ---------- Bar ---------- */
.portal-bar { position: sticky; top: 0; z-index: 30; background: var(--ink); }
.portal-bar :focus-visible { outline-color: var(--sun); }
.portal-bar .container { display: flex; align-items: center; gap: 14px; min-height: 64px; }
.portal-brand img { display: block; height: 26px; width: auto; }
.portal-title { color: #fff; font-weight: 600; font-size: .95rem; padding-left: 14px; border-left: 1px solid rgba(255, 255, 255, .2); white-space: nowrap; }
.portal-bar-end { margin-left: auto; display: flex; align-items: center; gap: 12px; min-width: 0; }
.portal-user { color: var(--on-ink); font-size: .88rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-bar { min-height: 40px; padding: .5em 1.05em; font-size: .9rem; border-color: rgba(255, 255, 255, .45); color: #fff; background: transparent; }
.btn-bar:hover { border-color: var(--sun); background: var(--sun); color: var(--ink); }

/* ---------- Page ---------- */
.portal-main { padding-block: 28px 80px; }
.portal-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; margin-bottom: 20px; }
.portal-head h1 { font-size: clamp(1.75rem, 1.35rem + 1.3vw, 2.4rem); line-height: 1.08; }
.portal-head p { color: var(--steel); margin-top: 6px; }
.portal-section { margin-top: 28px; }
.portal-section > h2 { font-size: 1.15rem; margin-bottom: 12px; }
.muted { color: var(--steel); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Cards ---------- */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--r-md); padding: 24px; min-width: 0; }
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 12px; margin-bottom: 14px; }
.card-head h2 { font-size: 1.08rem; }
.card-head p { color: var(--steel); font-size: .9rem; }
.split-2 { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; align-items: start; margin-top: 16px; }

/* ---------- Stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--r-md); padding: 20px 20px 18px; min-width: 0; }
.stat-label { color: var(--steel); font-size: .88rem; font-weight: 500; }
.stat-value { display: block; margin-top: 8px; font-size: clamp(1.8rem, 1.45rem + 1.1vw, 2.4rem); font-weight: 800; font-stretch: 110%; color: var(--ink); line-height: 1.05; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-sub { margin-top: 6px; color: var(--steel); font-size: .86rem; }
.stat-feature { background: var(--sun); border-color: var(--sun); }
.stat-feature .stat-label, .stat-feature .stat-sub { color: var(--ink); }

/* ---------- The school's next payment ---------- */
.pay-hero { position: relative; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px 28px; align-items: end; padding: clamp(24px, 3.4vw, 44px); border-radius: var(--r-lg); background: linear-gradient(135deg, var(--sun) 0%, var(--sun-2) 100%); color: var(--ink); }
.pay-hero > * { position: relative; z-index: 1; }
.pay-label { display: inline-flex; align-items: center; gap: 9px; padding: 6px 14px 6px 12px; border-radius: 999px; background: rgba(255, 255, 255, .6); color: var(--ink); font-weight: 700; font-size: .92rem; }
.pay-label::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--signal); }
.pay-amount { display: block; margin-top: 16px; color: var(--ink); font-size: clamp(3.2rem, 2.2rem + 4vw, 5.4rem); font-weight: 800; font-stretch: 112%; line-height: .95; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.pay-when { margin-top: 14px; color: var(--ink); font-size: 1.05rem; font-weight: 700; }
.pay-note { margin-top: 6px; color: #22355C; font-size: .92rem; }
.pay-rule { justify-self: end; max-width: 250px; padding: 18px 20px; border-radius: var(--r-md); background: #fff; color: var(--text); font-size: .9rem; line-height: 1.45; }
.pay-rule strong { display: block; color: var(--ink); font-size: 1.6rem; font-weight: 800; font-stretch: 110%; letter-spacing: -0.02em; margin-bottom: 2px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); margin: -6px 0 22px; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; display: inline-flex; align-items: center; gap: 8px; padding: 12px 14px; border: 0; border-bottom: 3px solid transparent; margin-bottom: -1px; background: none; color: var(--steel); font: 600 .95rem/1.2 var(--font-body); cursor: pointer; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--sun-2); }
.tab-count { min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--sun); color: var(--ink); font-size: .75rem; font-weight: 600; text-align: center; }

/* ---------- Toolbar and inputs ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar .grow { flex: 1 1 240px; min-width: 0; }
.toolbar .end { margin-left: auto; }
.input, .select { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: #fff; color: var(--ink); font: inherit; font-size: .95rem; }
.select {
  -webkit-appearance: none; appearance: none; padding-right: 38px; width: auto; max-width: 100%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234A576F' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.input:focus, .select:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(10, 111, 204, .18); }
.form-grid input[type="password"], .form-grid input[type="number"], .form-grid input[type="search"] {
  width: 100%; min-height: 52px; padding: 13px 14px; border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: #fff; color: var(--ink); font: inherit; font-size: 1rem; transition: border-color .15s, box-shadow .15s;
}
.check-row { display: flex; align-items: center; gap: 10px; font-weight: 500; color: var(--ink); }
.check-row input { width: 20px; height: 20px; accent-color: var(--ink); }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filter { min-height: 38px; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: #fff; color: var(--ink); font: 500 .9rem/1.2 var(--font-body); cursor: pointer; }
.filter[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---------- Lists ---------- */
.list { display: grid; gap: 8px; }
.item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 16px; align-items: center; width: 100%; padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: inherit; font: inherit; text-align: left; }
button.item { cursor: pointer; transition: border-color .15s, box-shadow .15s; }
button.item:hover { border-color: var(--line-strong); box-shadow: 0 12px 26px -22px rgba(18, 20, 23, .45); }
.item-title { font-weight: 600; color: var(--ink); min-width: 0; overflow-wrap: anywhere; }
.item-meta { grid-column: 1; color: var(--steel); font-size: .9rem; min-width: 0; overflow-wrap: anywhere; }
.item-contact { color: var(--ink); font-weight: 600; }
.item-side { grid-column: 2; grid-row: 1 / span 3; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; text-align: right; }
.item-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.list-more { margin-top: 12px; text-align: center; color: var(--steel); font-size: .9rem; }

/* ---------- Pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); color: var(--steel); font-size: .8rem; font-weight: 600; line-height: 1.5; white-space: nowrap; }
.pill-blue { background: #E8F2FC; border-color: #CFE3F8; color: #0858A3; }
.pill-green { background: #E5F6EE; border-color: #C5EBD9; color: #0F7A50; }
.pill-amber { background: #FFF4DB; border-color: #F3DDA0; color: #845500; }
.pill-red { background: #FDECEE; border-color: #F6CDD2; color: #A3222D; }
.pill-ink { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th { padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--steel); font-size: .84rem; font-weight: 600; text-align: left; white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; }
.table tfoot td { border-top: 1px solid var(--ink); border-bottom: 0; font-weight: 700; color: var(--ink); }

/* ---------- School cards (staff) ---------- */
.school-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.school-card h3 { font-size: 1.12rem; }
.school-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.school-meta { margin-top: 6px; color: var(--steel); font-size: .9rem; overflow-wrap: anywhere; }
.code-chip { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 6px; background: var(--paper); border: 1px solid var(--line); color: var(--ink); font-weight: 700; font-size: .85rem; letter-spacing: .04em; }
.minis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 16px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.mini { padding: 10px 12px; border-right: 1px solid var(--line); min-width: 0; }
.mini:last-child { border-right: 0; }
.mini span { display: block; color: var(--steel); font-size: .78rem; }
.mini strong { display: block; margin-top: 2px; color: var(--ink); font-size: 1.12rem; font-variant-numeric: tabular-nums; }

/* ---------- Buttons ---------- */
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.btn-sm { min-height: 40px; padding: .55em 1em; font-size: .92rem; }
.btn-danger { background: #fff; border-color: #EFC0C6; color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); color: #A3222D; }
.btn-confirm { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-confirm:hover { background: #A5222E; color: #fff; }
.btn-block { width: 100%; }
.link-btn { padding: 0; border: 0; background: none; color: var(--signal); font: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* ---------- Referral link ---------- */
.ref-box { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--paper); }
.ref-url { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-size: .92rem; }

/* ---------- Activity ---------- */
.feed { display: grid; list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: .93rem; color: var(--steel); }
.feed li:last-child { border-bottom: 0; }
.feed strong { color: var(--ink); font-weight: 600; }
.feed time { color: var(--steel); font-size: .84rem; white-space: nowrap; }

/* ---------- Dialog (editor) ---------- */
.sheet { width: min(660px, calc(100vw - 32px)); max-height: min(860px, calc(100dvh - 40px)); padding: 0; border: 0; border-radius: 20px; background: #fff; color: var(--ink); box-shadow: 0 30px 80px -20px rgba(18, 20, 23, .4); overflow: hidden; }
.sheet::backdrop { background: rgba(18, 20, 23, .4); }
.sheet[open] { display: flex; flex-direction: column; animation: ws-sheet-in .2s ease both; }
.sheet-form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 1.12rem; }
.sheet-close { flex: none; width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink); cursor: pointer; }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 20px 22px; }
.sheet .form-grid { margin-top: 16px; }
.sheet-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); background: #fff; }
.sheet-foot .form-status { margin-right: auto; }
.info-list { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; margin-top: 16px; padding: 14px 16px; border-radius: 10px; background: var(--paper); font-size: .93rem; }
.info-list dt { color: var(--steel); }
.info-list dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
.sub-head { grid-column: 1 / -1; margin-top: 8px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 1rem; }
@keyframes ws-sheet-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- Toast, notices, empty states ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 100; transform: translateX(-50%); width: max-content; max-width: min(92vw, 520px); padding: 12px 18px; border-radius: 12px; background: var(--ink); color: #fff; font-size: .95rem; box-shadow: 0 16px 40px -16px rgba(0, 0, 0, .55); }
.toast.is-error { background: var(--danger); }
.toast[hidden] { display: none; }
.notice { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 16px; padding: 14px 16px; border: 1px solid #CFE3F8; border-radius: 10px; background: #E8F2FC; color: var(--ink); font-size: .95rem; }
.notice-amber { background: #FFF4DB; border-color: #F3DDA0; }
.notice .icon { flex: none; margin-top: 2px; color: var(--signal); }
.notice-amber .icon { color: #845500; }
.empty { padding: 36px 20px; border: 1px dashed var(--line-strong); border-radius: var(--r-md); background: #fff; color: var(--steel); text-align: center; }
.empty strong { display: block; margin-bottom: 6px; color: var(--ink); font-size: 1.05rem; }
.empty .btn { margin-top: 14px; }

/* ---------- Sign-in ---------- */
.gate { max-width: 480px; margin: clamp(24px, 6vw, 64px) auto 0; }
.gate h1 { font-size: clamp(1.85rem, 1.45rem + 1.2vw, 2.4rem); line-height: 1.08; }
.gate > p { margin-top: 10px; color: var(--steel); }
.gate .form-grid { grid-template-columns: 1fr; margin-top: 22px; }
.gate-done { margin-top: 18px; }
.preview-flag { display: inline-flex; margin-bottom: 14px; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split-2, .school-grid { grid-template-columns: 1fr; }
  .pay-hero { grid-template-columns: 1fr; }
  .pay-rule { justify-self: start; max-width: none; }
}
@media (max-width: 600px) {
  .portal-bar .container { min-height: 58px; }
  .portal-brand img { height: 22px; }
  .portal-title { display: none; }
  .portal-user { display: none; }
  .portal-main { padding-block: 18px 64px; }
  .card { padding: 20px 16px; }
  .stat-grid { gap: 10px; }
  .stat { padding: 16px 14px 14px; }
  .stat-value { font-size: 1.6rem; }
  .minis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mini:nth-child(2) { border-right: 0; }
  .mini:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .item { grid-template-columns: minmax(0, 1fr); }
  .item-side { grid-column: 1; grid-row: auto; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: flex-start; text-align: left; margin-top: 4px; }
  .toolbar .end { margin-left: 0; }
  .toolbar .select { flex: 1 1 140px; }
  .sheet { width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: 20px 20px 0 0; }
  .sheet .form-grid { grid-template-columns: 1fr; }
  .sheet-foot .btn { flex: 1 1 auto; }
  .info-list { grid-template-columns: 1fr; gap: 2px; }
  .info-list dd { margin-bottom: 8px; }
  .feed li { grid-template-columns: 1fr; gap: 2px; }
  .table th, .table td { padding: 10px 8px; }
}
@media (prefers-reduced-motion: reduce) { .sheet[open] { animation: none; } }
