/* Mictco WhatsApp Platform. One stylesheet, system fonts, no external resources. */

:root {
    --brand: #0062d6;
    --brand-hover: #0052b3;
    --brand-pressed: #004391;
    --brand-soft: #e8f1fd;
    --ink: #14213d;
    --ink-muted: #4b5563;
    --line: #d9dee7;
    --surface: #ffffff;
    --page: #f3f5f9;
    --success: #0f7a4a;
    --success-soft: #e3f6ec;
    --danger: #b42318;
    --danger-soft: #fdeceb;
    --warn: #8a5a00;
    --warn-soft: #fff4d6;
    --info: #0b4fa8;
    --info-soft: #e8f1fd;
    --neutral-soft: #eceff4;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 2px rgba(20, 33, 61, 0.06), 0 4px 14px rgba(20, 33, 61, 0.06);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    --sidebar-width: 15rem;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.5;
    color: var(--ink);
    background: var(--page);
}

img { max-width: 100%; height: auto; }

h1 { font-size: 1.5rem; line-height: 1.25; margin: 0 0 1rem; }
h2 { font-size: 1.125rem; line-height: 1.3; margin: 1.5rem 0 0.75rem; }
p { margin: 0 0 0.75rem; }
small { color: var(--ink-muted); }
code { font-family: var(--font-mono); font-size: 0.9em; background: var(--neutral-soft); padding: 0.1rem 0.3rem; border-radius: 4px; overflow-wrap: anywhere; }

a { color: var(--brand); text-underline-offset: 2px; }
a:hover { color: var(--brand-hover); }
a:active { color: var(--brand-pressed); }

:focus-visible {
    outline: 3px solid var(--brand);
    outline-offset: 2px;
    border-radius: 4px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- skip link ---------- */
.skip-link {
    position: absolute;
    left: 0.5rem;
    top: -4rem;
    z-index: 100;
    background: var(--surface);
    color: var(--brand);
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    font-weight: 600;
}
.skip-link:focus { top: 0.5rem; }

/* ---------- app shell ---------- */
.app { display: block; min-height: 100vh; }

.sidebar {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    color: var(--ink);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 1.25;
}
.brand:hover { color: var(--ink); }
.brand img { width: 32px; height: 32px; flex: none; }

.nav-toggle:checked ~ .app .site-nav { display: block; }

.site-nav { display: none; padding: 0 0.5rem 0.75rem; }
.site-nav ul { list-style: none; margin: 0; padding: 0; }
.site-nav a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--ink);
    text-decoration: none;
    font-weight: 500;
}
.site-nav a:hover { background: var(--neutral-soft); color: var(--ink); }
.site-nav a:active { background: var(--line); }
.site-nav a[aria-current="page"] {
    background: var(--brand-soft);
    color: var(--brand);
    font-weight: 700;
    box-shadow: inset 3px 0 0 var(--brand);
}

.content { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
    display: flex;
    align-items: center;
    gap: 0.5rem 0.75rem;
    padding: 0.5rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.menu-button {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-weight: 600;
    cursor: pointer;
}
.menu-button:hover { background: var(--neutral-soft); }
.menu-button:active { background: var(--line); }
.nav-toggle:focus-visible ~ .app .menu-button { outline: 3px solid var(--brand); outline-offset: 2px; box-shadow: 0 0 0 5px var(--brand-soft); }
.nav-toggle:checked ~ .app .menu-button { background: var(--brand-soft); border-color: var(--brand); }
.site-nav__who { padding: 0.5rem 0.75rem; font-size: 0.85rem; color: var(--ink-muted); overflow-wrap: anywhere; }

.org { flex: 1 1 0; min-width: 0; }
.org strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.25; }
.org span { display: none; color: var(--ink-muted); font-size: 0.85rem; }

.account { display: flex; align-items: center; gap: 0.25rem 0.75rem; flex: none; }
.account__who { display: none; font-size: 0.85rem; color: var(--ink-muted); overflow-wrap: anywhere; }
.account form { margin: 0; }

main {
    flex: 1;
    width: 100%;
    max-width: 72rem;
    padding: 1rem;
}
main:focus { outline: none; }

.site-footer { padding: 1rem; color: var(--ink-muted); font-size: 0.85rem; }

@media (min-width: 1024px) {
    .app { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
    .sidebar { border-bottom: 0; border-right: 1px solid var(--line); position: sticky; top: 0; align-self: start; height: 100vh; overflow-y: auto; }
    .site-nav { display: block; }
    .menu-button { display: none; }
    .nav-toggle { display: none; }
    .site-nav__who { display: none; }
    .org strong { white-space: normal; overflow-wrap: anywhere; }
    .org span { display: block; }
    .account__who { display: inline; }
    .brand { padding: 1rem; }
    .topbar { padding: 0.75rem 2rem; }
    .account { margin-left: auto; }
    main { padding: 1.5rem 2rem 2rem; }
    .site-footer { padding: 1rem 2rem; }
}

/* ---------- bare layout (sign in pages) ---------- */
.auth-page { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1rem; }
.auth-card {
    width: 100%;
    max-width: 26rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 1.5rem;
    flex: none;
    height: auto;
    min-height: 0;
}
.auth-brand { display: flex; align-items: center; gap: 0.75rem; padding-bottom: 1rem; margin-bottom: 1rem; border-bottom: 1px solid var(--line); font-weight: 700; line-height: 1.25; }
.auth-brand img { width: 48px; height: 48px; flex: none; }
.auth-card h1 { font-size: 1.5rem; }
.auth-footer { margin-top: 1rem; text-align: center; font-size: 0.85rem; color: var(--ink-muted); }

/* ---------- forms ---------- */
.field { margin-bottom: 1rem; }
.field label, label.field-label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
.hint { display: block; color: var(--ink-muted); font-size: 0.85rem; margin-top: 0.25rem; }

input[type="text"], input[type="email"], input[type="password"], input:not([type]), select, textarea {
    display: block;
    width: 100%;
    max-width: 36rem;
    min-height: 44px;
    padding: 0.5rem 0.75rem;
    font: inherit;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid #aab3c2;
    border-radius: var(--radius-sm);
}
textarea { min-height: 6rem; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: var(--ink-muted); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }

.btn, button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0.5rem 1.1rem;
    font: inherit;
    font-weight: 600;
    color: #fff;
    background: var(--brand);
    border: 1px solid var(--brand);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.12s ease, border-color 0.12s ease;
}
.btn:hover, button:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: #fff; }
.btn:active, button:active { background: var(--brand-pressed); border-color: var(--brand-pressed); }
.btn:disabled, button:disabled { opacity: 0.6; cursor: not-allowed; }
.btn--block { width: 100%; }

.btn--secondary, .account button, .site-table button {
    color: var(--brand);
    background: var(--surface);
    border-color: var(--brand);
}
.btn--secondary:hover, .account button:hover, .site-table button:hover { background: var(--brand-soft); color: var(--brand-hover); }
.btn--secondary:active, .account button:active, .site-table button:active { background: #d3e4fa; }

.inline-form { display: inline; margin: 0; }

/* ---------- banners and notices ---------- */
.banner {
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    border-left-width: 4px;
    background: var(--surface);
}
.banner--error { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.banner--error a { color: var(--danger); font-weight: 600; }
.banner--warn { background: var(--warn-soft); border-color: #d99a00; color: var(--warn); }
.banner--warn a { color: var(--warn); font-weight: 600; }
.banner--success { background: var(--success-soft); border-color: var(--success); color: var(--success); }
.banner--info { background: var(--info-soft); border-color: var(--brand); color: var(--info); }

.secret-box { border: 1px solid var(--success); background: var(--success-soft); border-radius: var(--radius-sm); padding: 0.75rem 1rem; margin-bottom: 1rem; }
.secret-box code { word-break: break-all; }

.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.page-head .actions { margin: 0; }

/* ---------- cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 0.75rem; font-size: 1rem; }
.card__row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; }
.meta { color: var(--ink-muted); font-size: 0.9rem; margin: 0.5rem 0 0; }
.flush { margin: 0; }
.nowrap { white-space: nowrap; }
.compact-list { margin-top: 0; }

.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
@media (min-width: 720px) { .cards { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.75rem 1rem; box-shadow: var(--shadow); }
.metric__label { display: block; font-size: 0.9rem; color: var(--ink-muted); }
.metric__value { display: block; margin: 0; font-size: 1.75rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.metric__value--failed { color: var(--danger); }
.metric__note { display: block; margin-top: 0.25rem; font-size: 0.8rem; color: var(--ink-muted); }

.attention { list-style: none; margin: 0; padding: 0; }
.attention li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.25rem 1rem; padding: 0.6rem 0; border-top: 1px solid var(--line); }
.attention li:first-child { border-top: 0; }

/* ---------- status pills (always carry the word) ---------- */
.pill {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.4;
    background: var(--neutral-soft);
    color: var(--ink);
    border: 1px solid transparent;
}
.pill--queued { background: var(--warn-soft); color: var(--warn); border-color: #e6c36b; }
.pill--sent { background: var(--neutral-soft); color: var(--ink); border-color: #c3cad6; }
.pill--delivered, .pill--success { background: var(--success-soft); color: var(--success); border-color: #9fd7b9; }
.pill--read { background: var(--info-soft); color: var(--info); border-color: #a9c8f2; }
.pill--failed, .pill--danger { background: var(--danger-soft); color: var(--danger); border-color: #f0b3ae; }
.pill--warn { background: var(--warn-soft); color: var(--warn); border-color: #e6c36b; }

/* ---------- tables: stacked rows on phones ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 1rem; }
.table-wrap > h2 { margin: 0; padding: 0.75rem 1rem; font-size: 1rem; border-bottom: 1px solid var(--line); }
.site-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.site-table caption { text-align: left; }
.site-table th { text-align: left; font-weight: 600; color: var(--ink-muted); }
.site-table th, .site-table td { padding: 0.6rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.site-table tbody tr:last-child td { border-bottom: 0; }

@media (max-width: 719px) {
    .site-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
    .site-table, .site-table tbody, .site-table tr, .site-table td { display: block; width: 100%; }
    .site-table tr { padding: 0.5rem 0; border-bottom: 1px solid var(--line); }
    .site-table tbody tr:last-child { border-bottom: 0; }
    .site-table td { border: 0; padding: 0.2rem 1rem; display: flex; gap: 0.75rem; }
    .site-table td::before { content: attr(data-label); flex: 0 0 6.5rem; font-weight: 600; color: var(--ink-muted); }
    .site-table td:empty { display: none; }
}

.empty { padding: 1rem; color: var(--ink-muted); margin: 0; }

/* ---------- small screens ---------- */
@media (max-width: 719px) {
    .page-head .actions .btn { flex: 1 1 auto; }
    .auth-card { padding: 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* Two-factor set-up QR code: white square with a quiet zone so phone cameras can read it. */
.qr-box { background: #fff; padding: 12px; border: 1px solid var(--border, #d0d5dd); border-radius: 8px; width: fit-content; max-width: 100%; margin: 0 auto 1rem; }
.qr-box .qr { display: block; width: 220px; max-width: 100%; height: auto; }
