:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --text: #1f2933;
    --muted: #52606d;
    --border: #d9e2ec;
    --accent: #0f766e;
    --accent-hover: #115e59;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text);
    background: linear-gradient(180deg, #f8fafc 0%, #eef2f5 100%);
    min-height: 100vh;
}

.site-header {
    height: 64px;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background-color: var(--surface);
}

.site-header h1 {
    margin: 0;
    font-size: 1.1rem;
}

.icon-button {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    text-decoration: none;
    font-size: 1.2rem;
    border-radius: 8px;
    color: var(--text);
    background-color: #f1f5f9;
    border: 1px solid var(--border);
}

.icon-button:hover {
    background-color: #e2e8f0;
}

.app-shell {
    min-height: calc(100vh - 64px);
    display: grid;
    grid-template-columns: 240px 1fr;
}

.side-menu {
    border-right: 1px solid var(--border);
    background-color: #f8fafc;
    padding: 1rem 0.75rem;
}

.menu-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.4rem;
}

.menu-link {
    display: block;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    border: 1px solid transparent;
}

.menu-link:hover {
    background-color: #eaf2f2;
    border-color: #cbe7e4;
}

.menu-link.is-active {
    background-color: #d8f3ef;
    border-color: #80d5cb;
    font-weight: 600;
}

.main-content {
    padding: 1.5rem;
}

.content-panel {
    min-height: 220px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.content-panel.is-compact {
    min-height: 0;
}

.cwv-panel {
    padding: 1rem;
}

.cwv-panel h2 {
    margin: 0;
    font-size: 1.1rem;
}

.cwv-panel p {
    margin: 0.75rem 0 0;
    color: var(--muted);
}

.cwv-actions {
    margin-top: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.action-button {
    border: 0;
    border-radius: 8px;
    padding: 0.65rem 1rem;
    color: #fff;
    background-color: var(--accent);
    cursor: pointer;
    font: inherit;
}

.action-button:hover {
    background-color: var(--accent-hover);
}

.action-button:disabled {
    background-color: #97aaa7;
    cursor: not-allowed;
}

.status-message.is-error {
    color: #b42318;
}

.settings-form {
    display: grid;
    gap: 0.75rem;
    max-width: 760px;
    margin-top: 1.5rem;
}

.settings-form label {
    font-weight: 600;
    font-size: 0.95rem;
}

.settings-form input,
.settings-form textarea,
.settings-form button {
    font: inherit;
}

.settings-form input,
.settings-form textarea {
    width: 100%;
    border: 1px solid #bcccdc;
    border-radius: 8px;
    padding: 0.6rem 0.7rem;
    background-color: #fff;
}

.settings-form button {
    margin-top: 0.5rem;
    justify-self: start;
    border: 0;
    border-radius: 8px;
    padding: 0.65rem 1rem;
    color: #fff;
    background-color: var(--accent);
    cursor: pointer;
}

.settings-form button:hover {
    background-color: var(--accent-hover);
}

.settings-fieldset {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin: 0;
    display: grid;
    gap: 0.5rem;
}

.settings-fieldset legend {
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0 0.25rem;
}

.settings-fieldset-hint {
    margin: 0;
    font-size: 0.875rem;
    color: var(--muted);
}

.settings-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.settings-toggle-label {
    font-size: 0.95rem;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: var(--border);
    border-radius: 24px;
    transition: background-color 0.2s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background-color: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

.status-message {
    min-height: 1.2rem;
    margin: 0.25rem 0 0;
    color: var(--muted);
}

.chart-panel-section {
    margin-top: 1rem;
}

.chart-wrapper {
    position: relative;
    margin-top: 1rem;
    height: 500px;
    width: 100%;
}

.tab-nav {
    display: flex;
    gap: 0.25rem;
    margin-top: 1rem;
    border-bottom: 2px solid var(--border);
}

.tab-button {
    padding: 0.5rem 1rem;
    border: none;
    background: none;
    font: inherit;
    font-size: 0.95rem;
    color: var(--muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    border-radius: 4px 4px 0 0;
}

.tab-button:hover {
    color: var(--text);
    background-color: #f1f5f9;
}

.tab-button.is-active {
    color: var(--accent);
    font-weight: 600;
    border-bottom-color: var(--accent);
}

.tab-panel {
    padding-top: 1rem;
}

.tab-panel.is-hidden {
    display: none;
}

.websites-toolbar {
    margin-top: 1rem;
    display: flex;
    justify-content: flex-end;
}

.websites-table-wrapper {
    margin-top: 1rem;
    overflow-x: auto;
}

.websites-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.websites-table th,
.websites-table td {
    text-align: left;
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

.websites-table th {
    font-weight: 600;
    background-color: #f1f5f9;
    color: var(--text);
}

.websites-table tbody tr:hover {
    background-color: #f8fafc;
}

.websites-table .websites-index-col {
    width: 3rem;
    color: var(--muted);
    text-align: center;
}

.websites-table .websites-index {
    color: var(--muted);
    text-align: center;
}

.websites-table .websites-url a {
    color: var(--accent);
    text-decoration: none;
    word-break: break-all;
}

.websites-table .websites-url a:hover {
    text-decoration: underline;
}

.websites-empty {
    color: var(--muted);
    padding: 1rem 0.75rem;
}

.crux-panel {
    min-height: calc(100vh - 64px - 3rem);
    display: flex;
    flex-direction: column;
}

.crux-panel>.cwv-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.crux-header {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.crux-filename {
    font-size: 0.8rem;
    color: var(--muted);
}

.crux-empty {
    margin-top: 1rem;
    color: var(--muted);
    line-height: 1.6;
}

.crux-iframe-wrapper {
    flex: 1;
    margin-top: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    min-height: 80vh;
}

.crux-iframe {
    width: 100%;
    height: 100%;
    min-height: 80vh;
    border: none;
    display: block;
}

@media (max-width: 640px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .side-menu {
        border-right: 0;
        border-bottom: 1px solid var(--border);
        padding: 0.75rem;
    }

    .menu-list {
        grid-auto-flow: column;
        grid-auto-columns: minmax(180px, 1fr);
        overflow-x: auto;
    }

    .main-content {
        padding: 1rem;
    }
}