:root {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --panel-soft: #f7fafc;
    --text: #172033;
    --muted: #667085;
    --line: #d9e2ee;
    --primary: #0f766e;
    --primary-dark: #115e59;
    --accent: #99f6e4;
    --danger: #b42318;
    --warning: #b54708;
    --info: #2563eb;
    --shadow: 0 24px 60px rgba(17, 24, 39, 0.10);
    --radius-lg: 28px;
    --radius-md: 18px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at 14% 8%, rgba(153, 246, 228, 0.38), transparent 34rem),
        radial-gradient(circle at 92% 16%, rgba(59, 130, 246, 0.12), transparent 28rem),
        linear-gradient(135deg, #f7fafc 0%, #e9eef6 100%);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: inherit; }

.icon {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
}

.icon svg {
    display: block;
    width: 100%;
    height: 100%;
    fill: currentColor;
}

button,
input,
textarea { font: inherit; }

input,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px 14px;
    color: var(--text);
    background: #fff;
    outline: none;
    transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

textarea { resize: vertical; }

button[disabled] {
    cursor: wait;
    opacity: .72;
    transform: none !important;
}

input:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(12, 107, 90, .12);
}

input[type="checkbox"] {
    appearance: none;
    display: inline-grid;
    place-items: center;
    width: 42px;
    min-width: 42px;
    height: 24px;
    padding: 2px;
    border: 1px solid #c8d3df;
    border-radius: 999px;
    background: #e7edf4;
    cursor: pointer;
    transition: background .18s ease, border-color .18s ease;
}

input[type="checkbox"]::before {
    content: '';
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .18);
    transform: translateX(-9px);
    transition: transform .18s ease;
}

input[type="checkbox"]:checked {
    border-color: var(--primary);
    background: var(--primary);
}

input[type="checkbox"]:checked::before { transform: translateX(9px); }

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 650;
}

.required,
.optional {
    display: inline-flex;
    width: fit-content;
    margin-left: 4px;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.required {
    color: #7f1d1d;
    background: #fee2e2;
}

.optional {
    color: var(--muted);
    background: #edf2f8;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

th,
td {
    padding: 13px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 12px;
    letter-spacing: .04em;
    text-transform: uppercase;
}

pre {
    overflow: auto;
    max-height: 240px;
    margin: 12px 0 0;
    padding: 12px;
    border-radius: 14px;
    color: #d8fff2;
    background: #0b1e1a;
}

.auth-page {
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-shell { width: min(100%, 440px); }

.install-shell { width: min(100%, 780px); }

.auth-card {
    padding: 34px;
    border: 1px solid rgba(255, 255, 255, .72);
    border-radius: 30px;
    background: rgba(255, 255, 255, .82);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.auth-card.wide { padding: 36px; }

.brand-mark {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 16px;
    color: #062c28;
    background: linear-gradient(135deg, var(--accent), #f5d37e);
    font-weight: 900;
    letter-spacing: -.04em;
}

.auth-card h1,
.topbar h1,
.card h2 { margin: 12px 0 8px; letter-spacing: -.04em; }

.muted { color: var(--muted); }

.alert {
    margin: 18px 0;
    padding: 13px 15px;
    border-radius: 14px;
    font-weight: 700;
}

.alert.error {
    color: #7f1d1d;
    background: #fee2e2;
}

.stack-form { display: grid; gap: 18px; margin-top: 24px; }

.stack-form h2 { margin: 4px 0 0; font-size: 17px; }

.form-grid {
    display: grid;
    gap: 16px;
}

.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.span-two { grid-column: 1 / -1; }

.primary-btn,
.ghost-btn,
.danger-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    border: 0;
    border-radius: 14px;
    padding: 12px 16px;
    cursor: pointer;
    font-weight: 800;
    transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}

.primary-btn {
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    box-shadow: 0 12px 24px rgba(12, 107, 90, .22);
}

.primary-btn .icon,
.ghost-btn .icon,
.danger-btn .icon { width: 18px; height: 18px; }

.button-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 999px;
    animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.primary-btn:hover,
.ghost-btn:hover,
.danger-btn:hover { transform: translateY(-1px); }

.ai-save-btn {
    justify-self: stretch;
    width: 100%;
}

.ghost-btn {
    color: var(--primary-dark);
    background: #e7f7f4;
}

.danger-btn {
    color: #fff;
    background: var(--danger);
}

.compact { padding: 10px 13px; }

.app-shell {
    display: grid;
    grid-template-columns: 292px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 24px;
    height: 100vh;
    padding: 24px;
    color: #f4fff9;
    background:
        radial-gradient(circle at 20% 0%, rgba(153, 246, 228, .18), transparent 18rem),
        linear-gradient(180deg, #0b1f1d 0%, #123b37 100%);
    box-shadow: 18px 0 50px rgba(15, 23, 42, .14);
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-bottom: 18px;
    border-bottom: 1px solid rgba(255,255,255,.10);
}

.brand span { display: block; color: rgba(255,255,255,.62); font-size: 13px; }

.nav-list {
    display: grid;
    gap: 9px;
}

.nav-list a,
.logout-form button {
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 16px;
    padding: 13px 14px;
    color: rgba(255,255,255,.82);
    background: rgba(255,255,255,.06);
    text-decoration: none;
    transition: background .16s ease, color .16s ease, transform .16s ease, border-color .16s ease;
}

.nav-list a:hover,
.logout-form button:hover {
    color: #fff;
    border-color: rgba(153,246,228,.22);
    background: rgba(255,255,255,.12);
    transform: translateX(2px);
}

.nav-list .icon,
.logout-form .icon {
    width: 20px;
    height: 20px;
    color: var(--accent);
}

.logout-form { margin-top: auto; }
.logout-form button { width: 100%; cursor: pointer; }

.main-panel {
    display: grid;
    gap: 24px;
    padding: 32px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 30px;
    border-radius: 32px;
    color: #fff;
    background:
        linear-gradient(135deg, rgba(9, 37, 31, .94), rgba(12, 107, 90, .9)),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140' viewBox='0 0 140 140'%3E%3Cpath d='M0 70h140M70 0v140' stroke='%23ffffff' stroke-opacity='.06'/%3E%3C/svg%3E");
    box-shadow: var(--shadow);
}

.topbar h1,
.card h2,
.activity-panel h2,
.tool-box h3 {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar h1 .icon,
.card h2 .icon,
.activity-panel h2 .icon,
.tool-box h3 .icon {
    width: 24px;
    height: 24px;
    color: var(--primary);
}

.topbar h1 .icon { color: var(--accent); }

.eyebrow {
    margin: 0;
    color: #7bcbb6;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.status-card {
    display: grid;
    gap: 4px;
    min-width: 230px;
    padding: 16px;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 22px;
    background: rgba(255,255,255,.1);
}

.status-card small { color: rgba(255,255,255,.72); }

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 99px;
    background: #facc15;
}

.status-card strong {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-card.open .status-dot { background: #34d399; }
.status-card.closed .status-dot { background: #fb7185; }

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 20px;
}

.activity-panel {
    display: grid;
    grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
    padding: 22px;
    border: 1px solid rgba(255,255,255,.7);
    border-radius: var(--radius-lg);
    background: rgba(255,255,255,.86);
    box-shadow: 0 16px 34px rgba(23, 32, 51, .08);
}

.activity-panel h2 {
    margin: 4px 0 0;
    letter-spacing: -.04em;
}

#activity-list {
    display: grid;
    gap: 8px;
    max-height: 180px;
    overflow: auto;
    margin: 0;
    padding: 0;
    list-style: none;
}

.activity-item {
    position: relative;
    padding: 11px 12px 11px 34px;
    border: 1px solid var(--line);
    border-radius: 14px;
    color: var(--text);
    background: var(--panel-soft);
    font-size: 13px;
}

.activity-item::before {
    content: '';
    position: absolute;
    left: 13px;
    top: 15px;
    width: 8px;
    height: 8px;
    border-radius: 99px;
    background: var(--info);
}

.activity-item.success::before { background: #10b981; }
.activity-item.error::before { background: var(--danger); }
.activity-item.pending::before { background: #f59e0b; }
.activity-item.warning::before { background: var(--warning); }

.metric-card,
.card {
    border: 1px solid rgba(255,255,255,.7);
    border-radius: var(--radius-lg);
    background: rgba(255,255,255,.90);
    box-shadow: 0 16px 34px rgba(23, 32, 51, .08);
    backdrop-filter: blur(14px);
}

.metric-card {
    position: relative;
    overflow: hidden;
    padding: 20px;
}

.metric-card > .icon {
    width: 34px;
    height: 34px;
    margin-bottom: 16px;
    padding: 8px;
    border-radius: 13px;
    color: var(--primary-dark);
    background: #e7f7f4;
}

.metric-card span { display: block; color: var(--muted); font-size: 13px; }
.metric-card strong { display: block; margin-top: 8px; font-size: 22px; letter-spacing: -.03em; }

.card { padding: 26px; scroll-margin-top: 18px; }

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.section-heading h2 { margin: 4px 0 0; }

.switch-row {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    min-height: 50px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--panel-soft);
}

.switch-row input { width: auto; }

.copy-row,
.button-row {
    display: flex;
    gap: 10px;
}

.copy-row input { flex: 1; }

.channel-output {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.channel-pill {
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel-soft);
}

.channel-pill code {
    word-break: break-all;
    color: var(--primary-dark);
    font-weight: 800;
}

.warning-pill {
    border-color: #fed7aa;
    color: #7c2d12;
    background: #fff7ed;
}

.mini-actions {
    margin-top: 10px;
}

.hours-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.day-card {
    display: grid;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--panel-soft);
}

.day-card h3 { margin: 0; }

.slot-row {
    display: grid;
    grid-template-columns: minmax(98px, auto) 1fr 1fr auto;
    gap: 10px;
    align-items: center;
}

.slot-row input[type="checkbox"] { width: 42px; }

.slot-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-weight: 800;
}

.slot-row input[type="time"] {
    min-width: 0;
}

.inline-form {
    display: grid;
    grid-template-columns: 1fr 1fr 1.4fr auto;
    gap: 14px;
    align-items: end;
    margin-bottom: 16px;
}

.inline-form.subtle {
    grid-template-columns: 1fr 1fr 130px auto;
}

.table-wrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 18px;
}

.logs-table-wrap { max-height: 520px; }

.tool-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.tool-box {
    display: grid;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--panel-soft);
}

.tool-box h3 { margin: 0; }

.tool-box h3 .icon { color: var(--primary-dark); }

.field-help {
    display: block;
    margin-top: 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.45;
}

.ai-test-box {
    margin-top: 18px;
}

.ai-test-grid {
    display: grid;
    grid-template-columns: minmax(260px, .9fr) minmax(300px, 1.1fr);
    gap: 16px;
    align-items: start;
}

.ai-test-input,
.ai-test-result {
    display: grid;
    gap: 12px;
    grid-template-rows: auto minmax(150px, auto) auto;
}

.ai-test-input { align-content: stretch; }

.ai-test-input .ghost-btn {
    justify-self: stretch;
    width: 100%;
}

.ai-test-input textarea,
.ai-test-result pre {
    min-height: 150px;
}

.ai-result-title {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
    line-height: 1.35;
}

.ai-test-result pre {
    height: 100%;
    margin: 0;
    grid-row: 2 / 4;
}

.toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 60;
    max-width: 360px;
    padding: 14px 16px;
    border-radius: 16px;
    color: #fff;
    background: #10231f;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: opacity .18s ease, transform .18s ease;
}

.toast.success { background: #0c6b5a; }
.toast.error { background: #9f1d1d; }
.toast.pending { background: #8a5300; }
.toast.info { background: #1e3a8a; }

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.tag {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    color: var(--primary-dark);
    background: #dff6ee;
    font-size: 12px;
    font-weight: 800;
}

.tag.warn { color: #7c3c00; background: #fff4d5; }
.tag.error { color: #7f1d1d; background: #fee2e2; }

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 22px;
    background: rgba(15, 23, 42, .46);
    opacity: 0;
    pointer-events: none;
    backdrop-filter: blur(7px);
    transition: opacity .18s ease;
}

.modal-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    width: min(100%, 440px);
    padding: 26px;
    border: 1px solid rgba(255,255,255,.76);
    border-radius: 28px;
    background: rgba(255,255,255,.96);
    box-shadow: var(--shadow);
    transform: translateY(10px) scale(.98);
    transition: transform .18s ease;
}

.modal-backdrop.show .modal-card { transform: translateY(0) scale(1); }

.modal-icon {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border-radius: 18px;
    color: var(--danger);
    background: #fee2e2;
}

.modal-icon .icon { width: 26px; height: 26px; }

.modal-card h2 {
    margin: 18px 0 8px;
    letter-spacing: -.04em;
}

.modal-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
}

@media (max-width: 1060px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: static;
        height: auto;
        border-radius: 0 0 26px 26px;
        padding: 18px;
    }
    .brand { padding-bottom: 14px; }
    .nav-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .logout-form { margin-top: 0; }
    .metric-grid,
    .activity-panel,
    .tool-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    .main-panel { gap: 18px; padding: 16px; }
    .topbar,
    .section-heading,
    .copy-row,
    .button-row,
    .modal-actions { flex-direction: column; align-items: stretch; }
    .form-grid.two,
    .hours-grid,
    .ai-test-grid,
    .inline-form,
    .inline-form.subtle { grid-template-columns: 1fr; }
    .span-two { grid-column: auto; }
    .slot-row { grid-template-columns: 1fr 1fr; }
    .slot-toggle { grid-column: 1 / -1; }
    .slot-row .danger-btn { grid-column: 1 / -1; }
    .nav-list { grid-template-columns: 1fr 1fr; }
    .auth-card { padding: 24px; }
    .topbar,
    .card,
    .activity-panel { border-radius: 22px; padding: 20px; }
    table { min-width: 640px; }
}

@media (max-width: 480px) {
    .nav-list { grid-template-columns: 1fr; }
    .metric-card strong { font-size: 19px; }
    .toast { right: 14px; bottom: 14px; left: 14px; max-width: none; }
}
