/*
 * Dark only. There is no light palette and no toggle - that was the decision.
 * Colours are declared as custom properties anyway, so a light theme could be
 * added later without touching a single template.
 */
:root {
    --bg:          #0f1115;  /* never pure black - it reads badly on OLED */
    --surface:     #171a21;
    --surface-2:   #1e222b;
    --surface-3:   #262b36;
    --border:      #2a2f3a;
    --border-soft: #21252e;
    --text:        #e6e8ec;  /* never pure white - too much contrast tires the eye */
    --text-muted:  #9aa1ad;
    --text-faint:  #6b7280;
    --accent:      #4f8cff;
    --accent-soft: #1b2942;

    --status-accepted: #7c8798;
    --status-progress: #4f8cff;
    --status-blocked:  #e0603a;
    --status-done:     #3fa66b;
    --overdue:         #ff5c5c;

    --radius:   10px;
    --radius-s: 7px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* On a dark background a focus ring disappears unless it is deliberate. */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

.visually-hidden {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Topbar ---------- */

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar__inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
    height: 56px;
    display: flex;
    align-items: center;
    gap: 18px;
}

.brand {
    font-weight: 650;
    color: var(--text);
    letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }

.org-name { color: var(--text-muted); font-size: 14px; }

.org-switch select {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    padding: 5px 10px;
    font: inherit;
    font-size: 14px;
    max-width: 190px;
}

.nav { display: flex; gap: 4px; margin-left: auto; }

.nav a {
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: var(--radius-s);
    font-size: 14px;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.is-active { background: var(--accent-soft); color: var(--text); }

.topbar__user { display: flex; align-items: center; gap: 10px; }
.user-name { color: var(--text-muted); font-size: 14px; }

.inline { display: inline; margin: 0; }

/* ---------- Layout ---------- */

.main { max-width: 1100px; margin: 0 auto; padding: 24px 20px 80px; }
.main--bare { max-width: 520px; padding-top: 72px; }

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

h1 { font-size: 22px; font-weight: 650; margin: 0; letter-spacing: -0.02em; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; }

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); font-size: 13px; }

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    padding: 8px 14px;
    font: inherit;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }

.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 550; }
.btn--primary:hover { filter: brightness(1.1); }

.btn--ghost { background: transparent; }
.btn--ghost:hover { background: var(--surface-2); }

.btn--small { padding: 5px 10px; font-size: 13px; }

.btn--danger { color: var(--overdue); }
.btn--danger:hover { background: rgba(255, 92, 92, 0.12); }

/* ---------- Forms ---------- */

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }

input[type="text"], input[type="email"], input[type="date"], input[type="time"],
input[type="search"], textarea, select {
    width: 100%;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    padding: 9px 12px;
    font: inherit;
    font-size: 14px;
}
textarea { resize: vertical; min-height: 90px; }
input::placeholder, textarea::placeholder { color: var(--text-faint); }

/* The native date/time picker icon is black-on-dark without this. */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator { filter: invert(0.7); cursor: pointer; }

.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row > .field { flex: 1 1 180px; }

.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 20px; }

/* ---------- Cards and panels ---------- */

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}

/* ---------- Filters ---------- */

.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 18px;
}
.filters .field { margin: 0; flex: 0 1 auto; }
.filters select, .filters input { min-width: 150px; width: auto; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 13px;
}
.chip:hover { color: var(--text); text-decoration: none; }
.chip.is-active { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.chip__count { color: var(--text-faint); font-variant-numeric: tabular-nums; }

/* ---------- Task list ---------- */

.task-list { display: flex; flex-direction: column; gap: 1px; background: var(--border-soft);
             border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }

.task {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--surface);
    padding: 13px 16px;
}
.task:hover { background: var(--surface-2); }

.task--done .task__title { color: var(--text-muted); text-decoration: line-through; }

.task__main { flex: 1 1 auto; min-width: 0; }

.task__title { display: block; color: var(--text); font-weight: 500; }
.task__title:hover { text-decoration: none; color: var(--accent); }

.task__meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--text-faint);
    margin-top: 3px;
}

.task__side { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }

.due { font-size: 13px; color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Overdue is never signalled by colour alone - the marker carries it too. */
.due--overdue { color: var(--overdue); font-weight: 550; }
.due--overdue::before { content: "!"; display: inline-block; margin-right: 5px; font-weight: 700; }

/*
 * Status badges are tinted text on a muted wash, not a solid fill.
 * Solid colour blocks on a dark background shout far louder than intended.
 */
.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 550;
    border-radius: 999px;
    padding: 3px 10px;
    white-space: nowrap;
    border: 1px solid transparent;
}
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.status--accepted    { color: var(--status-accepted); background: color-mix(in srgb, var(--status-accepted) 16%, transparent); border-color: color-mix(in srgb, var(--status-accepted) 30%, transparent); }
.status--in-progress { color: var(--status-progress); background: color-mix(in srgb, var(--status-progress) 16%, transparent); border-color: color-mix(in srgb, var(--status-progress) 30%, transparent); }
.status--blocked     { color: var(--status-blocked);  background: color-mix(in srgb, var(--status-blocked) 16%, transparent);  border-color: color-mix(in srgb, var(--status-blocked) 30%, transparent); }
.status--done        { color: var(--status-done);     background: color-mix(in srgb, var(--status-done) 16%, transparent);     border-color: color-mix(in srgb, var(--status-done) 30%, transparent); }

.badge {
    font-size: 12px;
    color: var(--text-faint);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 1px 7px;
}

/* ---------- Status picker ---------- */

.status-form { display: flex; gap: 6px; flex-wrap: wrap; }
.status-form button { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; }
.status-form .status { opacity: 0.45; transition: opacity 0.12s; }
.status-form button:hover .status { opacity: 0.85; }
.status-form .status.is-current { opacity: 1; }

/* ---------- Detail ---------- */

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }

.detail-description { white-space: pre-wrap; color: var(--text); margin: 0; }

.meta-list { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 14px; margin: 0; }
.meta-list dt { color: var(--text-muted); }
.meta-list dd { margin: 0; }

/* ---------- Attachments ---------- */

.attachments { display: flex; flex-wrap: wrap; gap: 10px; }

.attachment {
    display: block;
    /* A light photo would bleed into the card edge without this outline. */
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    overflow: hidden;
    background: var(--surface-2);
    width: 120px;
}
.attachment img { display: block; width: 100%; height: 90px; object-fit: cover; }
.attachment__name { display: block; font-size: 11.5px; color: var(--text-muted); padding: 5px 7px;
                    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Tables ---------- */

table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
    text-align: left;
    font-weight: 550;
    color: var(--text-muted);
    font-size: 13px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}
table.data td { padding: 10px; border-bottom: 1px solid var(--border-soft); }
table.data tr:last-child td { border-bottom: 0; }

/* ---------- Flashes and empty states ---------- */

.flashes { margin-bottom: 18px; display: flex; flex-direction: column; gap: 8px; }

.flash {
    border-radius: var(--radius-s);
    padding: 11px 14px;
    font-size: 14px;
    border: 1px solid;
}
.flash--ok    { background: color-mix(in srgb, var(--status-done) 12%, transparent);  border-color: color-mix(in srgb, var(--status-done) 35%, transparent);  color: var(--text); }
.flash--error { background: color-mix(in srgb, var(--overdue) 12%, transparent); border-color: color-mix(in srgb, var(--overdue) 35%, transparent); color: var(--text); }

.empty {
    text-align: center;
    padding: 56px 20px;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}
.empty h2 { color: var(--text); }

/* ---------- Login and setup ---------- */

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    text-align: center;
}
.auth-card h1 { margin-bottom: 8px; }
.auth-card p { color: var(--text-muted); margin: 0 0 22px; }

.btn--sso {
    width: 100%;
    justify-content: center;
    background: var(--surface-2);
    padding: 12px;
    font-size: 15px;
}

/* ---------- Today ---------- */

.today-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }

.invite {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-soft);
}
.invite:last-child { border-bottom: 0; padding-bottom: 0; }
.invite__main { flex: 1 1 240px; min-width: 0; }

/* ---------- Agenda ---------- */

.agenda { display: flex; flex-direction: column; }

.agenda__row {
    display: flex;
    gap: 16px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border-soft);
}
.agenda__row:last-child { border-bottom: 0; }
.agenda__row:first-child { padding-top: 0; }

.agenda__time {
    flex: 0 0 92px;
    font-size: 13px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    line-height: 1.35;
}

.agenda__body { flex: 1 1 auto; min-width: 0; }

.day-group { margin-bottom: 22px; }

.day-group__heading {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--text-muted);
    text-transform: lowercase;
    padding-bottom: 8px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--border);
}
.day-group--today .day-group__heading { color: var(--accent); border-bottom-color: var(--accent); }

/* Invitation responses reuse the status pill shape. */
.response--invited   { color: var(--status-accepted); background: color-mix(in srgb, var(--status-accepted) 16%, transparent); border-color: color-mix(in srgb, var(--status-accepted) 30%, transparent); }
.response--accepted  { color: var(--status-done);     background: color-mix(in srgb, var(--status-done) 16%, transparent);     border-color: color-mix(in srgb, var(--status-done) 30%, transparent); }
.response--declined  { color: var(--status-blocked);  background: color-mix(in srgb, var(--status-blocked) 16%, transparent);  border-color: color-mix(in srgb, var(--status-blocked) 30%, transparent); }
.response--tentative { color: var(--status-progress); background: color-mix(in srgb, var(--status-progress) 16%, transparent); border-color: color-mix(in srgb, var(--status-progress) 30%, transparent); }

.checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    padding: 8px;
    background: var(--surface-2);
}

.checkbox-row { display: flex; align-items: center; gap: 9px; padding: 5px 6px; border-radius: 5px; cursor: pointer; margin: 0; }
.checkbox-row:hover { background: var(--surface-3); }
.checkbox-row input { width: auto; }

code, pre, .mono {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 13px;
}
code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; }
pre {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    padding: 12px 14px;
    overflow-x: auto;   /* wide content scrolls inside its own box, the page never does */
    text-align: left;
}

.token-value {
    display: block;
    background: var(--surface-2);
    border: 1px solid var(--accent);
    border-radius: var(--radius-s);
    padding: 12px;
    word-break: break-all;
    margin: 10px 0;
}

ol.steps { text-align: left; color: var(--text-muted); padding-left: 20px; }
ol.steps li { margin-bottom: 10px; }

/* ---------- Mobile ---------- */

@media (max-width: 900px) {
    .today-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 720px) {
    .agenda__time { flex-basis: 66px; }
    .topbar__inner { height: auto; padding: 10px 14px; flex-wrap: wrap; gap: 10px; }
    .nav { margin-left: 0; order: 3; width: 100%; }
    .topbar__user { margin-left: auto; }
    .main { padding: 16px 14px 60px; }
    .detail-grid { grid-template-columns: minmax(0, 1fr); }
    .task { flex-wrap: wrap; gap: 8px; }
    .task__side { width: 100%; justify-content: space-between; }
    .filters select, .filters input { min-width: 0; width: 100%; }
    .filters .field { flex: 1 1 100%; }
}
