/* CloudBook's design language (cloudBook/design.md), written as plain CSS: this app has no Tailwind
   build. The colours are Tailwind's own values, so a slate-500 here is the slate-500 in CloudBook.
   Sizes follow design.md: 14px body, 20px page title, 36px fields and buttons (44px on a phone). */

:root {
    --slate-50: oklch(98.4% 0.003 247.858);
    --slate-100: oklch(96.8% 0.007 247.896);
    --slate-200: oklch(92.9% 0.013 255.508);
    --slate-300: oklch(86.9% 0.022 252.894);
    --slate-400: oklch(70.4% 0.04 256.788);
    --slate-500: oklch(55.4% 0.046 257.417);
    --slate-600: oklch(44.6% 0.043 257.281);
    --slate-700: oklch(37.2% 0.044 257.287);
    --slate-900: oklch(20.8% 0.042 265.755);
    --indigo-50: oklch(96.2% 0.018 272.314);
    --indigo-100: oklch(93% 0.034 272.788);
    --indigo-300: oklch(78.5% 0.115 274.713);
    --indigo-500: oklch(58.5% 0.233 277.117);
    --indigo-600: oklch(51.1% 0.262 276.966);
    --indigo-700: oklch(45.7% 0.24 277.023);
    --red-50: oklch(97.1% 0.013 17.38);
    --red-100: oklch(93.6% 0.032 17.717);
    --red-200: oklch(88.5% 0.062 18.334);
    --red-600: oklch(57.7% 0.245 27.325);
    --red-700: oklch(50.5% 0.213 27.518);
    --green-50: oklch(98.2% 0.018 155.826);
    --green-100: oklch(96.2% 0.044 156.743);
    --green-200: oklch(92.5% 0.084 155.995);
    --green-700: oklch(52.7% 0.154 150.069);
    --amber-50: oklch(98.7% 0.022 95.277);
    --amber-100: oklch(96.2% 0.059 95.617);
    --amber-200: oklch(92.4% 0.12 95.746);
    --amber-700: oklch(55.5% 0.163 48.998);
    --amber-900: oklch(41.4% 0.112 45.904);
    /* Sign-in pages only (design.md "Colour"): Cloudwalker's blues. */
    --brand-dark: #134fa0;
    --brand-light: #45aae2;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --ring-card: 0 0 0 1px rgb(15 23 42 / 0.05);

    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.25rem;
    color: var(--slate-700);
    -webkit-font-smoothing: antialiased;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--slate-50); }
a { color: var(--indigo-700); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.25rem; line-height: 1.75rem; font-weight: 600; color: var(--slate-900); margin: 0 0 1rem; }
h2 { font-size: 1.125rem; line-height: 1.75rem; font-weight: 600; color: var(--slate-900); margin: 1.5rem 0 0.75rem; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.75rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }

/* ---- Frame (DashboardLayout): sidebar from 1024px, top bar, content on slate-50 ---- */
.frame { display: flex; min-height: 100dvh; }
.sidebar { display: none; width: 16rem; flex-shrink: 0; flex-direction: column; border-right: 1px solid var(--slate-200); background: #fff; }
.sidebar-brand { display: flex; height: 4rem; align-items: center; padding: 0 1rem; border-bottom: 1px solid var(--slate-200); font-size: 1.125rem; font-weight: 600; color: var(--slate-900); }
.sidebar nav { flex: 1; padding: 1rem 0.75rem; display: flex; flex-direction: column; gap: 0.25rem; }
.nav-link { display: flex; min-height: 2.5rem; align-items: center; gap: 0.75rem; padding: 0.5rem 0.75rem; border-radius: 0.375rem; font-weight: 500; color: var(--slate-700); }
.nav-link:hover { background: var(--slate-100); text-decoration: none; }
.nav-link.active { background: var(--indigo-50); color: var(--indigo-700); }
.nav-link svg { width: 1.25rem; height: 1.25rem; flex-shrink: 0; }
.content { display: flex; min-width: 0; flex: 1; flex-direction: column; }
.topbar { display: flex; height: 3.5rem; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0 0.75rem; border-bottom: 1px solid var(--slate-200); background: #fff; }
.crumbs { display: flex; min-width: 0; align-items: center; gap: 0.5rem; font-weight: 500; }
.crumbs .org { color: var(--slate-500); }
.crumbs .sep { color: var(--slate-300); }
.crumbs .page { color: var(--slate-900); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account { display: flex; align-items: center; gap: 1rem; }
.account-who { text-align: right; display: none; }
.account-who .email { font-weight: 500; color: var(--slate-900); }
.account-who .role { color: var(--slate-500); }
.account-who .role a { color: var(--indigo-600); font-weight: 500; }
.avatar { display: inline-flex; height: 2.5rem; width: 2.5rem; align-items: center; justify-content: center; border-radius: 9999px; background: var(--indigo-100); color: var(--indigo-700); font-weight: 600; text-transform: uppercase; }
.phone-nav { display: flex; overflow-x: auto; gap: 0.25rem; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--slate-200); background: #fff; }
.phone-nav .nav-link { white-space: nowrap; min-height: 2.75rem; }
main.page { flex: 1; padding: 1rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }

@media (min-width: 640px) {
    .topbar { padding: 0 1.5rem; }
    main.page { padding: 1.5rem; }
}
@media (min-width: 768px) {
    .account-who { display: block; }
    .account .avatar { display: none; }
}
@media (min-width: 1024px) {
    .sidebar { display: flex; }
    .phone-nav { display: none; }
    .topbar { height: 4rem; }
    main.page { padding: 2rem; }
}

/* ---- Card ---- */
.card { border-radius: 0.5rem; background: #fff; padding: 1.5rem; box-shadow: var(--shadow), var(--ring-card); margin-bottom: 1rem; }
.card > h2:first-child { margin-top: 0; }
.card-title { font-size: 0.875rem; font-weight: 600; color: var(--slate-900); margin: 0 0 0.75rem; }

/* ---- Fields (Input.tsx) ---- */
label { display: block; font-weight: 500; color: var(--slate-700); }
label:has(input[type=checkbox]) { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 400; }
input:not([type=checkbox]):not([type=radio]):not([type=hidden]), select, textarea {
    display: block; width: 100%; margin-top: 0.25rem; min-height: 2.25rem; padding: 0.375rem 0.75rem;
    font: inherit; font-size: 1rem; color: var(--slate-900); background-color: #fff;
    border: 0; border-radius: 0.375rem; box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--slate-300);
}
input::placeholder { color: var(--slate-400); }
input:focus, select:focus, textarea:focus { outline: none; box-shadow: inset 0 0 0 2px var(--indigo-600); }
select {
    appearance: none; -webkit-appearance: none; padding-right: 2.1rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%2364748b' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 0.6rem center; background-size: 1.1rem;
}
input[type=checkbox] { width: 1rem; height: 1rem; accent-color: var(--indigo-600); }
@media (min-width: 640px) {
    input:not([type=checkbox]):not([type=radio]):not([type=hidden]), select, textarea { font-size: 0.875rem; line-height: 1.25rem; }
}
form .row { margin-bottom: 1rem; }
.grid { display: grid; gap: 0 1rem; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
fieldset { border: 0; padding: 0; margin: 0 0 0.5rem; min-width: 0; }
fieldset > legend { font-size: 0.875rem; font-weight: 600; color: var(--slate-900); margin-bottom: 0.75rem; padding: 0; }
@media (min-width: 640px) { fieldset.grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.hint { display: block; margin-top: 0.25rem; font-size: 0.75rem; line-height: 1rem; color: var(--slate-500); }
.form-actions, .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 1rem; }
.form-actions { justify-content: flex-end; }

/* ---- Buttons (Button.tsx): primary indigo, secondary white with a ring, danger red text ---- */
button, .button {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem;
    min-height: 2.75rem; padding: 0.5rem 0.875rem; border: 0; border-radius: 0.375rem;
    font: inherit; font-size: 0.875rem; font-weight: 600; cursor: pointer; text-decoration: none;
    background: var(--indigo-600); color: #fff; box-shadow: var(--shadow-sm);
}
button:hover, .button:hover { background: var(--indigo-500); text-decoration: none; }
button:disabled { background: var(--indigo-300); cursor: not-allowed; }
button:focus-visible, .button:focus-visible, a:focus-visible { outline: 2px solid var(--indigo-600); outline-offset: 2px; }
button.secondary, .button.secondary { background: #fff; color: var(--slate-700); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--slate-300); }
button.secondary:hover, .button.secondary:hover { background: var(--slate-50); }
button.danger, .button.danger { background: #fff; color: var(--red-600); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--red-200); }
button.danger:hover, .button.danger:hover { background: var(--red-50); }
button.link { min-height: 0; padding: 0; background: none; box-shadow: none; color: var(--indigo-600); font-weight: 500; }
button.link:hover { background: none; color: var(--indigo-500); }
@media (min-width: 640px) { button, .button { min-height: 2.25rem; } }
form.inline { display: inline; }

/* ---- Tables (TableHead.tsx) ---- */
.table-wrap { overflow-x: auto; border-radius: 0.5rem; background: #fff; padding: 0.5rem 1.5rem; box-shadow: var(--shadow), var(--ring-card); margin-bottom: 1rem; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead tr { border-bottom: 1px solid var(--slate-200); }
th { text-align: left; padding: 0.375rem 1rem 0.375rem 0; font-size: 0.75rem; line-height: 1rem; font-weight: 500; color: var(--slate-500); white-space: nowrap; }
td { padding: 0.5rem 1rem 0.5rem 0; border-bottom: 1px solid var(--slate-100); color: var(--slate-600); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
td:first-child { font-weight: 500; color: var(--slate-900); }
td .num, td.num { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.75rem; }
.empty { font-size: 0.875rem; color: var(--slate-500); margin: 0 0 1rem; }

/* Read-first details (<dl>): small grey term above the value. */
dl.terms { display: grid; gap: 1rem 1.5rem; margin: 0; }
@media (min-width: 640px) { dl.terms { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
dl.terms dt { font-size: 0.75rem; line-height: 1rem; color: var(--slate-500); }
dl.terms dd { margin: 0.125rem 0 0; color: var(--slate-900); }

/* ---- Status badge (StatusBadge.tsx) and messages (Alert.tsx) ---- */
.state { display: inline-flex; align-items: center; border-radius: 9999px; padding: 0.125rem 0.625rem; font-size: 0.75rem; line-height: 1rem; font-weight: 500; white-space: nowrap; background: var(--slate-100); color: var(--slate-700); box-shadow: inset 0 0 0 1px rgb(100 116 139 / 0.2); vertical-align: middle; }
.state-Active { background: var(--green-100); color: var(--green-700); box-shadow: inset 0 0 0 1px rgb(22 163 74 / 0.2); }
.state-Ending-soon, .state-Grace { background: var(--amber-100); color: var(--amber-700); box-shadow: inset 0 0 0 1px rgb(217 119 6 / 0.2); }
.state-Expired, .state-Revoked { background: var(--red-100); color: var(--red-700); box-shadow: inset 0 0 0 1px rgb(220 38 38 / 0.2); }
.message { border-radius: 0.375rem; padding: 0.75rem 1rem; margin: 0 0 1rem; font-size: 0.875rem; }
.message.error { background: var(--red-50); color: var(--red-700); box-shadow: inset 0 0 0 1px var(--red-200); }
.message.ok { background: var(--green-50); color: var(--green-700); box-shadow: inset 0 0 0 1px var(--green-200); }
.message.warn { background: var(--amber-50); color: var(--amber-900); box-shadow: inset 0 0 0 1px var(--amber-200); }

/* ---- Search bar above lists ---- */
.search { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-bottom: 1.5rem; }
.search input { margin-top: 0; max-width: 20rem; }

/* ---- Sign-in pages (LoginPage.tsx): the only place with the company blues ---- */
.auth { position: relative; display: flex; min-height: 100dvh; align-items: center; justify-content: center; overflow: hidden; background: #fff; padding: 2.5rem 1rem; }
.auth-band { pointer-events: none; position: absolute; top: 0; left: 0; height: 6rem; width: 100%; }
.auth-cloud { pointer-events: none; position: absolute; bottom: -1.5rem; right: -6rem; display: none; width: 34rem; }
@media (min-width: 640px) { .auth-band { height: 8rem; } }
@media (min-width: 768px) { .auth-cloud { display: block; } }
@media (min-width: 1024px) { .auth-cloud { width: 42rem; } }
.auth-box { position: relative; width: 100%; max-width: 28rem; }
.auth-logo { display: block; margin: 0 auto 1.25rem; width: 16rem; height: auto; }
@media (min-width: 640px) { .auth-logo { width: 18rem; } }
.auth-title { text-align: center; font-size: 1.5rem; line-height: 2rem; font-weight: 600; color: var(--brand-dark); margin: 0; }
.auth-sub { text-align: center; margin: 0.25rem 0 1.5rem; color: var(--slate-600); }
.auth-card { border-radius: 0.75rem; background: #fff; padding: 1.5rem; box-shadow: var(--shadow-lg), var(--ring-card); border-top: 4px solid var(--brand-light); }
.auth-card form > * + * { margin-top: 1rem; }
.auth-card form .row { margin-bottom: 0; }
.auth-card p { margin: 0 0 0.75rem; }
.auth-card ol { padding-left: 1.25rem; margin: 0 0 0.75rem; }
.auth-card button.brand, .auth-card .button.brand { width: 100%; min-height: 2.75rem; background: var(--brand-dark); }
.auth-card button.brand:hover, .auth-card .button.brand:hover { background: var(--brand-dark); opacity: 0.9; }
.auth-card button.brand:focus-visible { outline-color: var(--brand-dark); }
.auth-foot { margin-top: 2rem; text-align: center; font-size: 0.75rem; color: var(--slate-500); }
.auth-foot a { color: var(--brand-dark); letter-spacing: 0.1em; }

.qr { display: flex; justify-content: center; margin: 0.5rem 0; }
.qr img { width: 240px; height: 240px; image-rendering: pixelated; }
code.key { font-size: 0.875rem; letter-spacing: 0.08em; word-break: break-all; color: var(--slate-900); }
pre { background: var(--slate-100); padding: 0.75rem; border-radius: 0.375rem; overflow-x: auto; font-size: 0.875rem; color: var(--slate-900); }

/* Controls inside a table row: one line, no stretching. */
td form.inline select { display: inline-block; width: auto; margin: 0 0.5rem 0 0; vertical-align: middle; }
td.row-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
dl.terms code { word-break: break-all; }
td:first-child a { white-space: nowrap; }
dl.confirm + form { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--slate-200); }

/* Phone: a list's rows become cards (TableHead.tsx stackOnPhone); the headings stay for screen readers. */
@media (max-width: 767px) {
    .table-wrap { padding: 0; background: none; box-shadow: none; overflow: visible; }
    .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; }
    .table-wrap thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
    .table-wrap tr { margin-bottom: 0.5rem; border: 1px solid var(--slate-200); border-radius: 0.375rem; background: #fff; padding: 0.75rem; }
    .table-wrap td { padding: 0.125rem 0; border: 0; }
    .table-wrap td:empty { display: none; }
    .topbar .account form button { padding: 0.5rem 0.75rem; }
}

/* ---- B.S. date field (BsDateInput.tsx): text box + calendar button, B.S. calendar below ---- */
[hidden] { display: none !important; }
.bs-field { position: relative; }
.bs-row { display: flex; margin-top: 0.25rem; border-radius: 0.375rem; box-shadow: var(--shadow-sm); }
.bs-row input[data-bs-date] { margin-top: 0; min-width: 0; border-radius: 0.375rem 0 0 0.375rem; box-shadow: inset 0 0 0 1px var(--slate-300); }
.bs-row input[data-bs-date]:focus { box-shadow: inset 0 0 0 2px var(--indigo-600); }
.bs-row input[aria-invalid] { box-shadow: inset 0 0 0 1px var(--red-600); }
.bs-open { margin-left: -1px; min-height: 2.25rem; padding: 0 0.75rem; border-radius: 0 0.375rem 0.375rem 0; background: #fff; color: var(--slate-500); box-shadow: inset 0 0 0 1px var(--slate-300); }
.bs-open:hover { background: var(--slate-50); }
.bs-open svg { width: 1rem; height: 1rem; }
.bs-error { margin: 0.25rem 0 0; font-size: 0.75rem; line-height: 1rem; color: var(--red-600); }
.bs-pop { position: absolute; left: 0; right: 0; z-index: 20; margin-top: 0.25rem; border-radius: 0.375rem; background: #fff; padding: 0.75rem; box-shadow: var(--shadow-lg), 0 0 0 1px var(--slate-200); }
@media (min-width: 640px) { .bs-pop { right: auto; width: 20rem; } }
.bs-head { display: flex; align-items: center; gap: 0.25rem; margin-bottom: 0.5rem; }
.bs-head select { margin-top: 0; min-height: 2rem; padding-top: 0.25rem; padding-bottom: 0.25rem; }
.bs-head select:first-of-type { flex: 1; }
.bs-head select:last-of-type { width: auto; }
.bs-nav, .bs-link, .bs-day { min-height: 0; background: none; box-shadow: none; font-weight: 400; }
.bs-nav { padding: 0.25rem 0.5rem; color: var(--slate-600); font-size: 1rem; }
.bs-nav:hover, .bs-link.muted:hover { background: var(--slate-100); }
table.bs-grid { table-layout: fixed; text-align: center; }
table.bs-grid th { padding: 0 0 0.25rem; text-align: center; font-size: 0.75rem; font-weight: 500; color: var(--slate-500); }
table.bs-grid th.sat { color: oklch(63.7% 0.237 25.331); }
table.bs-grid td { padding: 0.125rem; border: 0; font-weight: 400; color: inherit; }
.bs-day { display: flex; width: 100%; height: 2.25rem; flex-direction: column; align-items: center; justify-content: center; gap: 0.125rem; border-radius: 0.375rem; padding: 0; line-height: 1; color: var(--slate-900); }
.bs-day:hover { background: var(--slate-100); }
.bs-day .ad { font-size: 9px; color: var(--slate-400); }
.bs-day.other { color: var(--slate-300); }
.bs-day.sat { color: var(--red-600); }
.bs-day.sat:hover { background: var(--red-50); }
.bs-day.today { box-shadow: inset 0 0 0 1px oklch(67.3% 0.182 276.935); }
.bs-day.selected, .bs-day.selected:hover { background: var(--indigo-600); color: #fff; }
.bs-day.selected .ad { color: var(--indigo-100); }
.bs-foot { display: flex; justify-content: space-between; margin-top: 0.5rem; }
.bs-link { padding: 0.25rem 0.5rem; color: var(--indigo-600); font-weight: 500; }
.bs-link:hover { background: var(--indigo-50); }
.bs-link.muted { color: var(--slate-500); font-weight: 400; }

/* ---- Feature ticks ---- */
.features { margin-bottom: 1rem; }
.feature-grid { display: grid; gap: 0.5rem; }
@media (min-width: 640px) { .feature-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
label.feature { display: flex; align-items: flex-start; gap: 0.625rem; min-height: 2.75rem; padding: 0.625rem 0.75rem; border-radius: 0.375rem; background: #fff; box-shadow: inset 0 0 0 1px var(--slate-300); cursor: pointer; font-weight: 400; }
label.feature:hover { background: var(--slate-50); }
label.feature:has(input:checked) { background: var(--indigo-50); box-shadow: inset 0 0 0 1px var(--indigo-300); }
label.feature input { margin-top: 0.125rem; flex-shrink: 0; }
.feature-name { display: block; font-weight: 500; color: var(--slate-900); }
.feature-note { display: block; font-size: 0.75rem; line-height: 1rem; color: var(--slate-500); }
