/* Delphora VA portal — single stylesheet, light theme. */
:root {
  --bg: #f3f5f9;
  --card: #ffffff;
  --text: #16203a;
  --muted: #5a6478;        /* 6.0:1 on white */
  --faint: #8a93a6;        /* decorative only */
  --border: #e3e7ef;
  --border-strong: #c9d0dc;
  --accent: #1d5fd6;       /* 5.3:1 on white */
  --accent-dark: #164aa8;
  --accent-soft: #e9f0fd;
  --accent-ring: rgba(29, 95, 214, .35);
  --green: #12804a;        /* 5.4:1 on white */
  --green-soft: #e4f5ec;
  --red: #b42318;
  --red-soft: #fdecea;
  --amber: #7a4e00;
  --amber-soft: #fff3d6;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .04);
  --sidebar-w: 236px;
  --gutter: 16px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-dark); }
h1 { font-size: 1.5rem; line-height: 1.25; letter-spacing: -.01em; margin: 0 0 20px; }
h2 { font-size: 1rem; margin: 0 0 12px; }
h2 .muted, h1 .muted { font-weight: 500; font-size: .85em; }
p { margin: 0 0 10px; }
p:last-child { margin-bottom: 0; }
code { font: .92em ui-monospace, Menlo, Consolas, monospace; background: var(--bg); padding: 3px 7px; border-radius: 6px; word-break: break-all; }
.muted { color: var(--muted); }
.error { color: var(--red); font-weight: 600; background: var(--red-soft); border: 1px solid #f5c6c1; padding: 10px 12px; border-radius: var(--radius-sm); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -48px; background: var(--card); color: var(--accent); padding: 8px 12px; border-radius: var(--radius-sm); z-index: 10; }
.skip:focus { top: 8px; }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--card); border-right: 1px solid var(--border);
  padding: 22px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; padding: 0 8px; }
.brand:hover { color: var(--text); }
.brand .mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), #4f8df7); color: #fff; display: grid; place-items: center; font-size: .85rem; font-weight: 700; flex-shrink: 0; }
.brand small { display: block; font-size: .72rem; font-weight: 600; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.sidebar ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 2px; }
.sidebar li a {
  display: block; padding: 9px 12px; border-radius: var(--radius-sm); color: var(--muted); text-decoration: none; font-weight: 600;
}
.sidebar li a:hover { background: var(--bg); color: var(--text); }
.sidebar li a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-dark); }
.sidebar .spacer { flex: 1; }
.who { padding: 10px 12px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.who .name { font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who .role { display: block; font-size: .75rem; color: var(--muted); font-weight: 500; }
.content { flex: 1; min-width: 0; padding: 32px; max-width: 1120px; width: 100%; }
.content.center { display: grid; place-items: center; max-width: none; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card.narrow { width: 100%; max-width: 420px; margin: 24px auto; }
.card h2:first-child { margin-top: -2px; }
.card-head { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.grid .card { margin-bottom: 0; }
.grid + .card { margin-top: 16px; }

/* Stats */
.stat .label { font-size: .82rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 0 0 6px; }
.big { font-size: 2.4rem; line-height: 1.1; font-weight: 700; letter-spacing: -.02em; margin: 0 0 6px; font-variant-numeric: tabular-nums; }
.earnings { color: var(--green); font-weight: 700; }
.sub { color: var(--muted); font-size: .9rem; margin: 0; }

/* Messages */
.flash { background: var(--accent-soft); border: 1px solid #c6d7f8; color: var(--accent-dark); padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-weight: 500; }
.flash:focus { outline: none; }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.empty strong { display: block; color: var(--text); font-weight: 600; margin-bottom: 2px; }
.empty .icon { width: 40px; height: 40px; margin: 0 auto 10px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; color: var(--faint); }
td.empty, li.empty { text-align: center; padding: 8px 0; }
td.empty .empty, li.empty .empty { padding: 20px 12px; }
.note { display: flex; gap: 10px; align-items: flex-start; background: var(--bg); border-radius: var(--radius-sm); padding: 12px 14px; color: var(--muted); }
.note.pending { background: var(--amber-soft); color: var(--amber); }

/* Forms */
label { display: block; font-weight: 600; font-size: .88rem; margin: 12px 0 5px; }
label:first-child { margin-top: 0; }
label.check { display: flex; gap: 10px; align-items: center; font-weight: 500; }
.hint { font-size: .82rem; color: var(--muted); margin: 4px 0 0; }
input, select, textarea {
  width: 100%; max-width: 100%; font: inherit; color: var(--text); background: #fff; min-height: 42px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 9px 12px;
}
input::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: #aab3c2; }
input[type=checkbox] { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); margin: 0; }
input[type=file] { padding: 7px 10px; }
select { appearance: none; -webkit-appearance: none; padding-right: 36px; 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='%235a6478' stroke-width='2.5' 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; }
textarea { font: .86rem/1.5 ui-monospace, Menlo, Consolas, monospace; min-height: 120px; resize: vertical; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  background: var(--accent); color: #fff; border: 1px solid var(--accent); border-radius: var(--radius-sm); padding: 9px 16px; min-height: 42px; margin: 0;
  transition: background-color .12s, border-color .12s, color .12s;
}
button:hover, .button:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
form > button:last-child, form > .button:last-child { margin-top: 16px; }
button.secondary, .button.secondary { background: #fff; color: var(--accent-dark); border-color: var(--border-strong); }
button.secondary:hover, .button.secondary:hover { background: var(--accent-soft); border-color: #b9cdf4; color: var(--accent-dark); }
button.danger { background: #fff; color: var(--red); border-color: var(--border-strong); }
button.danger:hover { background: var(--red-soft); border-color: #f1b8b3; color: var(--red); }
button.small, .button.small { padding: 5px 10px; min-height: 32px; font-size: .82rem; }
button.link { background: none; border: none; color: var(--muted); padding: 6px 8px; min-height: 0; }
button.link:hover { background: var(--bg); color: var(--text); }
button.copy { background: #fff; color: var(--accent-dark); border-color: var(--border-strong); white-space: nowrap; }
button.copy:hover { background: var(--accent-soft); color: var(--accent-dark); }
button.copy.done { background: var(--green-soft); color: var(--green); border-color: #b9e3c9; }
button.copy svg { width: 15px; height: 15px; flex-shrink: 0; }
a:focus-visible, button:focus-visible, .button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--accent-ring); outline-offset: 2px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--accent); outline-offset: 0; }

.inline-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.inline-form > div { flex: 1 1 180px; min-width: 0; }
.inline-form label { margin-top: 0; }
.inline-form > button, .inline-form > .button { margin-top: 0; flex: 0 0 auto; }
td .inline-form.compact { flex-wrap: nowrap; gap: 8px; }
td .inline-form.compact select, td .inline-form.compact input { min-width: 150px; }
.inline-form.compact > div, .inline-form.compact select, .inline-form.compact input { flex: 1 1 140px; min-height: 36px; padding-top: 6px; padding-bottom: 6px; }
.inline-form.compact { gap: 8px; }
.inline-form.compact button { min-height: 36px; padding: 6px 12px; font-size: .88rem; }
form.inline { display: inline; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions form { margin: 0; }
.actions .muted { font-size: .9rem; }
td .actions { flex-wrap: nowrap; }
td .actions button { min-height: 34px; padding: 5px 12px; font-size: .85rem; white-space: nowrap; }

/* Link rows (chat link / invite) */
.linkrow { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0; }
.linkrow code { flex: 1 1 240px; display: block; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); line-height: 1.4; }
.linkrow button { margin: 0; flex: 0 0 auto; }

/* Tables */
.table-wrap { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -22px; padding: 0 22px; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
th { color: var(--muted); font-weight: 600; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafbfd; }
tfoot th, tfoot td { border-top: 2px solid var(--border); border-bottom: none; font-weight: 700; text-transform: none; letter-spacing: 0; font-size: .95rem; color: var(--text); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap { word-break: break-all; max-width: 320px; }
td.date { white-space: nowrap; font-variant-numeric: tabular-nums; }
td.low { color: var(--red); font-weight: 700; }
td .muted { font-size: .85rem; }
.handle { font-weight: 600; white-space: nowrap; }
.yes { color: var(--green); font-weight: 600; }
.no { color: var(--faint); }

/* Badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .76rem; font-weight: 600; background: var(--bg); color: var(--muted); white-space: nowrap; text-transform: capitalize; }
.badge.active, .badge.free, .badge.paid { background: var(--green-soft); color: var(--green); }
.badge.pending, .badge.assigned, .badge.open, .badge.progress { background: var(--amber-soft); color: var(--amber); }
.badge.removed, .badge.retired, .badge.unpaid { background: #eef1f5; color: var(--muted); }
.badge.accent { background: var(--accent-soft); color: var(--accent-dark); }

/* Lists */
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 12px 0; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
ul.plain li:last-child { border-bottom: none; }
ul.plain li a { font-weight: 600; word-break: break-word; }
ul.links { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
ul.links a { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); text-decoration: none; font-weight: 600; background: #fff; }
ul.links a:hover { border-color: #b9cdf4; background: var(--accent-soft); }
ul.links a svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--faint); margin-left: auto; }

/* Media */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 14px; }
.media-grid figure { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.media-grid img, .media-grid video { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: var(--radius-sm); background: var(--bg); display: block; border: 1px solid var(--border); }
.media-grid a { display: block; border-radius: var(--radius-sm); }
.media-grid form { margin: 0; }
.media-grid form button { width: 100%; }

/* Week navigation */
.weeknav { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.weeknav .button { flex: 0 0 auto; }
.weeknav > div { flex: 1 1 160px; }

/* Auth */
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; font-weight: 700; }
.auth-brand .mark { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--accent), #4f8df7); color: #fff; display: grid; place-items: center; font-weight: 700; }
.auth-brand small { display: block; font-size: .72rem; font-weight: 600; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.card.narrow h1 { font-size: 1.3rem; margin-bottom: 14px; }
.card.narrow form > button { width: 100%; }
.card.narrow .muted { margin-top: 16px; font-size: .9rem; }
.error-code { font-size: .8rem; font-weight: 700; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; margin: 0 0 6px; }

/* Phone: sidebar becomes a top bar */
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: sticky; top: 0; z-index: 5; border-right: none; border-bottom: 1px solid var(--border);
    padding: 0 var(--gutter); display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "brand who" "nav nav"; gap: 0; align-items: center; overflow: hidden;
  }
  .brand { grid-area: brand; padding: 12px 0; }
  .brand small { display: none; }
  .brand .mark { width: 28px; height: 28px; }
  .sidebar .spacer { display: none; }
  .who { grid-area: who; border-top: none; padding: 0; gap: 6px; }
  .who .name { display: none; }
  .sidebar ul { grid-area: nav; min-width: 0; flex-direction: row; gap: 4px; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter) 10px; }
  .sidebar ul::-webkit-scrollbar { display: none; }
  .sidebar li { flex: 0 0 auto; }
  .sidebar li a { padding: 7px 12px; font-size: .9rem; }
  .content { padding: 20px var(--gutter) 32px; }
  .card { padding: 18px; }
  .table-wrap { margin: 0 -18px; padding: 0 18px; }
  .card.narrow { margin: 12px auto; }
  h1 { font-size: 1.3rem; margin-bottom: 16px; }
  .big { font-size: 2.1rem; }
  .inline-form > button, .inline-form > .button { flex: 1 1 100%; }
  .linkrow button { flex: 1 1 100%; }
  td .actions { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
