:root {
    --bg: #f4f7f8;
    --panel: #ffffff;
    --ink: #182230;
    --muted: #667085;
    --line: #d7dee8;
    --line-soft: #edf1f5;
    --accent: #236d64;
    --accent-dark: #19574f;
    --accent-soft: #e6f2ef;
    --sidebar: #17332e;
    --sidebar-muted: #cfe0dc;
    --warn: #b54708;
    --radius: 8px;
    --shadow: 0 12px 30px rgba(24, 34, 48, .07);
    color-scheme: light;
}

:root.wa-dark {
    --bg: #101416;
    --panel: #171d20;
    --ink: #edf2f4;
    --muted: #aab6bd;
    --line: #303a40;
    --line-soft: #242c31;
    --accent: #5fc0b3;
    --accent-dark: #8fd3c8;
    --accent-soft: #193834;
    --sidebar: #0d211e;
    --sidebar-muted: #b7cbc6;
    --warn: #f79009;
    --shadow: 0 16px 38px rgba(0, 0, 0, .34);
    color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(180deg, #fbfcfd 0, var(--bg) 270px),
        var(--bg);
    color: var(--ink);
    font: 15px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
:root.wa-dark body {
    background:
        linear-gradient(180deg, #151b1e 0, var(--bg) 270px),
        var(--bg);
}
a { color: inherit; }
wa-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25em;
    min-width: 1.25em;
    line-height: 1;
    color: currentColor;
}
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 248px;
    background: var(--sidebar);
    color: #fff;
    padding: 18px 16px;
    border-right: 1px solid rgba(255,255,255,.08);
}
.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 48px;
    padding: 0 8px 16px;
    border-bottom: 1px solid rgba(255,255,255,.1);
    font-size: 16px;
    font-weight: 760;
    margin-bottom: 16px;
}
nav { display: grid; gap: 4px; }
nav a {
    display: flex;
    gap: 11px;
    align-items: center;
    min-height: 42px;
    padding: 9px 11px;
    border-radius: 8px;
    color: var(--sidebar-muted);
    text-decoration: none;
    font-weight: 650;
}
nav a:hover {
    background: rgba(255,255,255,.1);
    color: #fff;
}
nav a.active {
    background: rgba(255,255,255,.14);
    color: #fff;
}
nav a.active wa-icon {
    color: #8fd3c8;
}
.theme-control {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 11px;
    margin-top: 18px;
    padding: 14px 10px 0;
    border-top: 1px solid rgba(255,255,255,.1);
    color: var(--sidebar-muted);
    font-size: 13px;
    font-weight: 650;
}
.shell {
    width: min(1280px, calc(100% - 248px));
    margin-left: 248px;
    padding: 30px;
}
.public-shell {
    width: min(980px, 100%);
    margin: 0 auto;
    padding: 30px;
}
.auth-shell { display: grid; min-height: 100vh; place-items: center; padding: 24px; }
wa-card.login-panel,
wa-card.panel {
    --spacing: 22px;
    display: block;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
wa-card.panel::part(body) {
    overflow-x: auto;
}
.login-panel {
    width: min(410px, 100%);
    --spacing: 28px;
}
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 22px;
}
h1, h2 { margin: 0 0 8px; line-height: 1.2; }
h1 {
    font-size: 29px;
    font-weight: 780;
}
h2 {
    font-size: 18px;
    font-weight: 760;
}
p { color: var(--muted); margin: 0; }
.panel-title {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}
.panel-title.slim {
    margin-bottom: 0;
}
.grid { display: grid; gap: 18px; margin-bottom: 18px; }
.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}
.metrics div {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: 0 8px 20px rgba(24, 34, 48, .045);
}
.metrics strong {
    display: block;
    font-size: 32px;
    line-height: 1.1;
}
.metrics span { color: var(--muted); }
.stack { display: grid; gap: 14px; }
.inline-form, .actions {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 10px;
}
.add-meeting-form {
    margin-top: 14px;
}
.add-meeting-form[hidden] {
    display: none;
}
.pattern-form {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 12px;
    align-items: end;
}
.pattern-form label:first-of-type {
    grid-column: span 2;
}
.compact-form {
    border-bottom: 1px solid var(--line-soft);
    padding-bottom: 16px;
    margin-bottom: 16px;
}
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.form-grid label:last-child {
    grid-column: 1 / -1;
}
label,
wa-input,
wa-select,
wa-textarea {
    display: grid;
    gap: 6px;
    color: var(--ink);
    font-size: 13px;
    font-weight: 700;
}
wa-input,
wa-select,
wa-textarea {
    width: 100%;
}
wa-checkbox {
    color: var(--ink);
    font-size: 13px;
    font-weight: 700;
}
input[type="hidden"] {
    display: none;
}
input:not([type="hidden"]), select, textarea {
    width: 100%;
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 8px 11px;
    font: inherit;
    background: var(--panel);
    color: var(--ink);
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(35, 109, 100, .13);
}
textarea { min-height: 88px; resize: vertical; }
button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 8px 13px;
    background: var(--panel);
    color: var(--ink);
    text-decoration: none;
    cursor: pointer;
    font: inherit;
    font-weight: 720;
    line-height: 1.2;
    transition: background .15s ease, border-color .15s ease, color .15s ease, transform .08s ease;
}
button:hover, .button:hover {
    border-color: #b8c4d2;
    background: color-mix(in srgb, var(--panel) 74%, var(--bg));
}
button:active, .button:active {
    transform: translateY(1px);
}
.primary {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}
.primary:hover { background: var(--accent-dark); }
.danger {
    border-color: light-dark(#fecdca, #912018);
    color: light-dark(#b42318, #fecdc7);
    background: var(--panel);
}
.danger:hover {
    border-color: light-dark(#fda29b, #f97066);
    background: light-dark(#fff5f4, #55160c);
}
.table-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    white-space: nowrap;
}
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}
.meeting-table {
    min-width: 1080px;
}
.meeting-table th,
.meeting-table td {
    padding-left: 8px;
    padding-right: 8px;
}
.meeting-table th.icon-col,
.meeting-table td.icon-col {
    position: sticky;
    right: 0;
    z-index: 2;
    background: var(--panel);
}
.meeting-table th.icon-col:nth-last-child(2),
.meeting-table td.icon-col:nth-last-child(2) {
    right: 46px;
}
.meeting-table th.icon-col:nth-last-child(3),
.meeting-table td.icon-col:nth-last-child(3) {
    right: 92px;
}
.meeting-table thead th.icon-col {
    background: color-mix(in srgb, var(--panel) 86%, var(--bg));
}
thead th {
    background: color-mix(in srgb, var(--panel) 86%, var(--bg));
    border-bottom: 1px solid var(--line);
}
th, td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--line-soft);
    text-align: left;
    vertical-align: middle;
}
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--panel) 74%, var(--bg)); }
.pattern-edit-row td {
    background: color-mix(in srgb, var(--panel) 74%, var(--bg));
    padding: 14px 12px 16px;
}
.pattern-edit-form {
    padding: 0;
}
th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 780;
    letter-spacing: 0;
    text-transform: uppercase;
}
.icon-col {
    width: 46px;
    min-width: 46px;
    text-align: center;
}
.icon-col wa-button {
    width: 40px;
}
.list { display: grid; gap: 6px; }
.list a {
    padding: 10px 11px;
    border: 1px solid var(--line);
    border-radius: 7px;
    text-decoration: none;
    font-weight: 650;
}
.list a span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
}
.list a:hover { background: color-mix(in srgb, var(--panel) 74%, var(--bg)); }
.list a.active {
    border-color: #91c6bd;
    background: var(--accent-soft);
    color: var(--accent-dark);
}
.list a.active span {
    color: var(--accent-dark);
}
.editable-list {
    display: grid;
    gap: 12px;
}
.editable-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    align-items: end;
    padding: 12px;
    border: 1px solid var(--line-soft);
    border-radius: 7px;
    background: color-mix(in srgb, var(--panel) 74%, var(--bg));
}
.editable-row .row-actions {
    grid-column: 1 / -1;
}
.delete-form {
    display: none;
}
.empty {
    padding: 2px 0 4px;
    color: var(--muted);
}
.alert {
    color: light-dark(#7a271a, #fecdc7);
    background: light-dark(#ffede8, #55160c);
    border: 1px solid light-dark(#fecdca, #912018);
    border-radius: 7px;
    padding: 10px;
    margin-bottom: 14px;
}
.notice {
    color: light-dark(#064e3b, #a7f3d0);
    background: light-dark(#ecfdf3, #063f31);
    border: 1px solid light-dark(#abefc6, #067647);
    border-radius: 7px;
    padding: 10px;
    margin-bottom: 14px;
}
.row-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.row-actions form { margin: 0; }
.row-actions .lock,
.row-actions button,
.row-actions wa-button {
    flex: 0 0 auto;
}
.row-actions button,
.row-actions wa-button[aria-label] {
    width: 40px;
}
.print-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.print-sheet { background: var(--panel); padding: 28px; border: 1px solid var(--line); }

@media (max-width: 900px) {
    .sidebar { position: static; width: auto; }
    .shell { width: auto; margin-left: 0; padding: 18px; }
    .public-shell { padding: 18px; }
    .two, .metrics, .form-grid, .pattern-form, .editable-row { grid-template-columns: 1fr; }
    .pattern-form label:first-of-type { grid-column: auto; }
    .page-head { display: grid; }
}

@media print {
    :root,
    :root.wa-dark {
        --bg: #ffffff;
        --panel: #ffffff;
        --ink: #182230;
        --muted: #667085;
        --line: #d7dee8;
        --line-soft: #edf1f5;
        color-scheme: light;
    }
    .sidebar, .print-head wa-button { display: none; }
    .shell,
    .public-shell { margin: 0; padding: 0; width: auto; }
    body { background: #fff; color: var(--ink); }
    .print-sheet { border: 0; padding: 0; }
    thead th,
    th,
    td {
        background: #fff;
        color: var(--ink);
    }
}
