/* Same shape as the myda panel: a dark emerald frame with a fixed sidebar, the
   content as a light rounded panel, white cards, compact buttons and badges. */
:root {
    --primary-50: #ecfdf5;
    --primary-100: #d1fae5;
    --primary-200: #a7f3d0;
    --primary-300: #6ee7b7;
    --primary-400: #34d399;
    --primary-600: #059669;
    --primary-700: #047857;
    --primary-800: #065f46;
    --primary-900: #064e3b;
    --primary-950: #022c22;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-900: #111827;
    --navbar: 4rem;
    --sidebar: 16rem;
    --footer: 3.75rem;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

* { box-sizing: border-box; }
html { color-scheme: light; scroll-behavior: smooth; scroll-padding-top: calc(var(--navbar) + 1rem); }

body {
    margin: 0;
    background: var(--gray-50);
    color: var(--gray-900);
    font: 16px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

h1, h2, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
a { color: var(--primary-700); font-weight: 500; text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.icon { width: 1rem; height: 1rem; flex-shrink: 0; }

/* ---- Shell ---------------------------------------------------------- */

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--gray-900);
}
.brand:hover { text-decoration: none; }
.brand .icon {
    width: 2rem;
    height: 2rem;
    padding: 0.45rem;
    border-radius: 0.6rem;
    background: var(--primary-600);
    color: #fff;
}
.brand-light { color: #fff; }
.brand-light .icon { background: rgb(255 255 255 / 0.15); }

.sidebar {
    position: fixed;
    top: var(--navbar);
    bottom: 0;
    left: 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    width: var(--sidebar);
    background: var(--primary-950);
    transform: translateX(-100%);
    transition: transform 0.2s ease-out;
}
.shell.sidebar-open .sidebar { transform: translateX(0); }

.sidebar-head { display: flex; align-items: center; height: var(--navbar); padding: 0 1.25rem; flex-shrink: 0; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 0.5rem 0.75rem 1rem; }
.sidebar-label {
    padding: 0 0.75rem 0.4rem;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--primary-200);
}
.sidebar-nav li + li { margin-top: 0.125rem; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 0;
    border-radius: 0.5rem;
    background: transparent;
    color: var(--primary-100);
    font: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}
.sidebar-link .icon { color: var(--primary-200); }
.sidebar-link:hover { background: rgb(255 255 255 / 0.1); color: #fff; text-decoration: none; }
.sidebar-link.is-active { background: rgb(255 255 255 / 0.15); color: #fff; }
.sidebar-link.is-active .icon { color: #fff; }
.sidebar-link:focus-visible { outline: 2px solid var(--primary-400); outline-offset: 0; }

.sidebar-foot { flex-shrink: 0; padding: 0.75rem; border-top: 1px solid rgb(255 255 255 / 0.1); }
.user-menu { position: relative; }
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: 0.5rem;
    color: #fff;
    cursor: pointer;
    list-style: none;
    user-select: none;
    transition: background-color 0.2s ease-out;
}
.sidebar-user::-webkit-details-marker { display: none; }
.sidebar-user:hover, .user-menu[open] .sidebar-user { background: rgb(255 255 255 / 0.1); }
.sidebar-user:focus-visible { outline: 2px solid var(--primary-400); }
.avatar {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    flex-shrink: 0;
    border-radius: 999px;
    background: rgb(255 255 255 / 0.15);
    font-size: 0.875rem;
    font-weight: 600;
}
.sidebar-user-text { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.sidebar-user-text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-text span:first-child { font-size: 0.875rem; font-weight: 500; }
.sidebar-user-text span:last-child { font-size: 0.75rem; color: var(--primary-100); }
.user-menu-list {
    position: absolute;
    right: 0;
    bottom: calc(100% + 0.5rem);
    left: 0;
    padding: 0.25rem;
    border: 1px solid var(--gray-200);
    border-radius: 0.5rem;
    background: #fff;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.2);
}
.user-menu-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 0;
    border-radius: 0.375rem;
    background: transparent;
    color: var(--gray-700);
    font: inherit;
    font-size: 0.875rem;
    text-align: left;
    cursor: pointer;
}
.user-menu-item:hover { background: var(--gray-100); color: var(--gray-900); }

.scrim { position: fixed; inset: var(--navbar) 0 0 0; z-index: 30; background: rgb(17 24 39 / 0.4); }

.frame { display: flex; flex-direction: column; min-height: 100dvh; background: var(--gray-50); transition: margin 0.2s ease-out; }

.navbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    height: var(--navbar);
    flex-shrink: 0;
    padding: 0 0.75rem;
    border-bottom: 1px solid var(--gray-200);
    background: #fff;
}
.navbar-toggle {
    display: inline-flex;
    padding: 0.5rem;
    border: 0;
    border-radius: 0.5rem;
    background: transparent;
    color: var(--gray-600);
    cursor: pointer;
}
.navbar-toggle .icon { width: 1.25rem; height: 1.25rem; }
.navbar-toggle:hover { background: var(--gray-100); color: var(--gray-900); }
.navbar-divider { width: 1px; height: 1.25rem; background: var(--gray-200); }
.navbar-title { padding: 0 0.5rem; font-size: 0.875rem; font-weight: 500; }

.footer {
    display: flex;
    align-items: center;
    justify-content: center;
    height: var(--footer);
    padding: 0 1rem;
    border-top: 1px solid var(--gray-200);
    font-size: 0.875rem;
    color: var(--gray-500);
}

@media (min-width: 64rem) {
    body.shell { background: var(--primary-950); padding: 0.5rem 0; }
    .sidebar { top: 0; transform: translateX(0); }
    .shell.sidebar-collapsed .sidebar { transform: translateX(-100%); }
    .scrim { display: none !important; }
    .frame {
        min-height: calc(100dvh - 1rem);
        margin: 0 0.5rem 0 var(--sidebar);
        border-radius: 0.75rem;
        box-shadow: var(--shadow-sm);
    }
    .shell.sidebar-collapsed .frame { margin-left: 0.5rem; }
    .navbar { z-index: 20; padding: 0 1rem; border-radius: 0.75rem 0.75rem 0 0; }
}

/* ---- Page ----------------------------------------------------------- */

.page { flex: 1; padding: 1rem; }
.page-head { margin-bottom: 1.5rem; }
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.0125em; line-height: 2rem; }
h2 { font-size: 1rem; font-weight: 600; }
.page-description { margin-top: 0.25rem; font-size: 0.875rem; color: var(--gray-500); }
.hint { margin-top: 0.25rem; font-size: 0.75rem; color: var(--gray-500); }
.muted, .empty { color: var(--gray-500); }
.empty { font-size: 0.875rem; }

.card { border: 1px solid var(--gray-200); border-radius: 0.75rem; background: #fff; box-shadow: var(--shadow-sm); }

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat { padding: 1rem; }
.stat-label { font-size: 0.875rem; color: var(--gray-500); }
.stat-value { margin: 0.5rem 0; }
.stat-number { margin-top: 0.25rem; font-size: 1.5rem; font-weight: 600; line-height: 2rem; font-variant-numeric: tabular-nums; }
.stat form { margin-top: 0.75rem; }

.columns { display: grid; gap: 1.5rem; margin-bottom: 1.5rem; }
.column { display: grid; gap: 1.5rem; align-content: start; min-width: 0; }
.panel { padding: 1rem; min-width: 0; }
.panel > p { font-size: 0.875rem; color: var(--gray-700); }
.panel > .hint { margin-top: 0.75rem; font-size: 0.75rem; color: var(--gray-500); }
.panel-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

@media (min-width: 64rem) {
    .page { padding: 1.5rem; }
    .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---- Pieces --------------------------------------------------------- */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.25rem;
}
.badge-ok { background: #dcfce7; color: #166534; }
.badge-bad { background: #fee2e2; color: #991b1b; }
.badge-wait { background: #fef9c3; color: #854d0e; }
.badge-muted { background: var(--gray-100); color: var(--gray-700); }

.alert { margin-bottom: 1rem; padding: 0.75rem 1rem; border-radius: 0.5rem; font-size: 0.875rem; }
.alert-ok { background: var(--primary-50); color: var(--primary-800); }
.alert-bad { background: #fef2f2; color: #991b1b; }

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border: 1px solid transparent;
    border-radius: 0.5rem;
    font: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25rem;
    cursor: pointer;
    transition: background-color 0.15s;
}
.button-sm { padding: 0.375rem 0.75rem; }
.button-block { width: 100%; }
.button:disabled { opacity: 0.6; cursor: progress; }
.button-primary { background: var(--primary-600); color: #fff; }
.button-primary:hover { background: var(--primary-700); }
.button-secondary { border-color: var(--gray-300); background: #fff; color: var(--gray-900); }
.button-secondary:hover { background: var(--gray-100); }
.button:focus-visible, .navbar-toggle:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--primary-300); }

.stack { display: grid; gap: 1rem; }
.field { display: grid; gap: 0.5rem; }
.field > span { font-size: 0.875rem; font-weight: 500; }
.field-error { font-size: 0.875rem; color: #b91c1c; }

input, select, textarea {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: 0.5rem;
    background: var(--gray-50);
    color: var(--gray-900);
    font: inherit;
    font-size: 0.875rem;
}
textarea { resize: vertical; min-height: 12rem; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary-600); box-shadow: 0 0 0 1px var(--primary-600); }
summary:focus-visible { outline: 2px solid var(--primary-400); outline-offset: 2px; }

.day-filter { display: flex; gap: 0.5rem; align-items: center; }
.day-filter input { width: auto; padding: 0.375rem 0.75rem; }

.qr { margin-top: 0.75rem; }
.qr figure { margin: 1rem 0 0; }
.qr img { display: block; padding: 0.5rem; border: 1px solid var(--gray-200); border-radius: 0.75rem; background: #fff; }
.qr figcaption { max-width: 22rem; margin-top: 0.5rem; font-size: 0.75rem; color: var(--gray-500); }
.qr .alert { margin: 0.75rem 0 0; }

/* The line under the tabs is an inset shadow, so the selected tab's border sits
   on it without overflowing the strip (an overflow would add a scrollbar). */
.tabs { display: flex; gap: 0.25rem; margin: 0 -1rem; padding: 0 1rem; box-shadow: inset 0 -1px 0 var(--gray-200); overflow-x: auto; overflow-y: hidden; }
.tab {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--gray-500);
    font: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
}
.tab:hover { color: var(--gray-900); border-bottom-color: var(--gray-300); }
.tab[aria-selected="true"] { color: var(--primary-700); border-bottom-color: var(--primary-600); }
.tab:focus-visible { outline: 2px solid var(--primary-400); outline-offset: -2px; }
.tab-panel + .tab-panel { margin-top: 1.5rem; }
.tab-panel[hidden] + .tab-panel, .tabs + .tab-panel { margin-top: 0; }

.table-wrap { margin: 0 -1rem -1rem; overflow-x: auto; }
.history { width: 100%; border-collapse: collapse; font-size: 0.875rem; line-height: 1.5rem; }
.history th, .history td { padding: 0.75rem 1rem; text-align: left; vertical-align: top; border-top: 1px solid var(--gray-100); }
.history thead th {
    border-top: 0;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--gray-500);
}
.history tbody tr:first-child th, .history tbody tr:first-child td { border-top: 0; }
.history tbody tr:hover { background: var(--gray-50); }
.history tbody th { width: 6rem; white-space: nowrap; }
.history td:nth-child(2) { width: 13rem; white-space: nowrap; }
.history time { font-size: 0.9375rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.history-detail { color: var(--gray-700); }
.history-text { width: 34%; }
.history summary { cursor: pointer; color: var(--gray-600); overflow-wrap: anywhere; }
.history details[open] summary { color: var(--gray-500); font-size: 0.75rem; }
.message { white-space: pre-wrap; margin-top: 0.5rem; padding: 0.75rem; border-radius: 0.5rem; background: var(--gray-50); color: var(--gray-900); overflow-wrap: anywhere; }
.history tbody tr:hover .message { background: #fff; }

@media (max-width: 48rem) {
    .history thead { display: none; }
    .history tr { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 0.75rem; padding: 0.75rem 1rem; border-top: 1px solid var(--gray-100); }
    .history tbody tr:first-child { border-top: 0; }
    .history th, .history td { display: block; width: auto !important; padding: 0; border: 0; white-space: normal; }
    .history-detail, .history-text { grid-column: 1 / -1; }
}

/* ---- Login ---------------------------------------------------------- */

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 2rem 1rem;
    background: rgb(236 253 245 / 0.7);
}
.auth-card {
    display: grid;
    width: 100%;
    max-width: 60rem;
    padding: 0.75rem;
    border-radius: 2rem;
    background: #fff;
    box-shadow: 0 25px 50px -12px rgb(6 78 59 / 0.1);
    overflow: hidden;
}
.auth-panel {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    min-height: 34rem;
    padding: 2.5rem;
    border-radius: 1.5rem;
    background:
        radial-gradient(60rem 30rem at 110% -10%, rgb(52 211 153 / 0.35), transparent 60%),
        linear-gradient(to bottom, var(--primary-800), var(--primary-950));
}
.auth-eyebrow { font-size: 0.875rem; font-weight: 500; color: rgb(255 255 255 / 0.8); }
.auth-pitch { max-width: 24rem; margin-top: 0.5rem; font-size: 1.875rem; font-weight: 700; line-height: 1.2; letter-spacing: -0.0175em; color: #fff; }
.auth-form { align-self: center; width: 100%; max-width: 24rem; margin: 0 auto; padding: 2.5rem 1.25rem; }
.auth-mark { width: 1.75rem; height: 1.75rem; margin-bottom: 1rem; color: var(--primary-600); }
.auth-form .stack { margin-top: 1.5rem; }

@media (min-width: 48rem) {
    .auth-card { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .auth-panel { display: flex; }
}
