* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
}

:root {
    --bg: #26262a;
    --bg-panel: #2e2e33;
    --text: #ffffff;
    --border: #89cff0;
    --border-dim: rgba(137, 207, 240, 0.35);
    --dragonfruit: #FF4696;
    --warn: #f0c674;
    --fail: #f07178;
    --ok: #7ec699;
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

img, picture, video, canvas, svg {
    display: block;
    max-width: 100%;
}

a {
    color: inherit;
    text-decoration: none;
}

/* --- layout --- */

.layout {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--bg-panel);
    border-right: 2px solid var(--border);
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-title {
    font-weight: 600;
    letter-spacing: 0.08em;
    margin-bottom: 1.5rem;
    color: var(--border);
}

.nav-item {
    display: block;
    padding: 0.6rem 0.75rem;
    border-radius: 6px;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.nav-item.active {
    background: rgba(137, 207, 240, 0.12);
    border: 2px solid var(--border);
}

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.main-header {
    flex-shrink: 0;
    padding: 2rem 2rem 1.5rem;
}

.main-header h1 {
    margin: 0;
}

.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 2rem 2rem;
}

/* --- widgets / accordion --- */

.widgets {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 900px;
}

.widget {
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--bg-panel);
    overflow: hidden;
}

.widget-header {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: transparent;
    border: none;
    color: var(--text);
    font: inherit;
    cursor: pointer;
    text-align: left;
}

.widget-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--ok);
    flex-shrink: 0;
}
.widget-status.status-ok { background: var(--ok); }
.widget-status.status-fail { background: var(--fail); }
.widget-status.status-warn { background: var(--warn); }
.widget-status.status-no_data { background: #666; }

.widget-label {
    font-weight: 600;
}

.widget-meta {
    margin-left: auto;
    font-size: 0.85rem;
    opacity: 0.75;
    white-space: nowrap;
}

.widget-chevron {
    transition: transform 0.15s ease;
    flex-shrink: 0;
}

.widget.open .widget-chevron {
    transform: rotate(180deg);
}

.widget-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.2s ease;
}

.widget.open .widget-body {
    max-height: 420px;
    overflow-y: auto;
    border-top: 1px solid var(--border-dim);
}

.widget-section + .widget-section {
    border-top: 1px solid var(--border-dim);
}

.widget-section-title {
    padding: 0.6rem 1rem 0.3rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.6;
}

.issue-list {
    list-style: none;
}

.issue {
    display: flex;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border-dim);
    font-size: 0.85rem;
    font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
}

.issue:last-child {
    border-bottom: none;
}

.issue-status {
    font-weight: 700;
    width: 5.5rem;
    flex-shrink: 0;
}
.issue-fail .issue-status { color: var(--fail); }
.issue-warn .issue-status { color: var(--warn); }
.issue-success .issue-status { color: var(--ok); }

.issue-ts {
    opacity: 0.6;
    flex-shrink: 0;
    white-space: nowrap;
}

.no-issues {
    padding: 1rem;
    opacity: 0.7;
}

/* --- auth (login/register) --- */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-card {
    width: 100%;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    background: var(--bg-panel);
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 2rem;
}

.auth-title {
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--border);
    margin-bottom: 1rem;
    text-align: center;
}

.auth-label {
    font-size: 0.85rem;
    opacity: 0.75;
    margin-top: 0.75rem;
}

.auth-input {
    background: var(--bg);
    border: 1px solid var(--border-dim);
    border-radius: 6px;
    padding: 0.6rem 0.75rem;
    color: var(--text);
    font: inherit;
}

.auth-input:focus {
    outline: none;
    border-color: var(--border);
}

.auth-submit {
    margin-top: 1.5rem;
    padding: 0.7rem;
    border: 2px solid var(--border);
    border-radius: 6px;
    background: rgba(137, 207, 240, 0.12);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.auth-submit:hover {
    background: rgba(137, 207, 240, 0.2);
}

.auth-error {
    color: var(--fail);
    font-size: 0.85rem;
}

.auth-success {
    color: var(--ok);
    font-size: 0.9rem;
}

.auth-alt {
    margin-top: 1.25rem;
    text-align: center;
    font-size: 0.85rem;
}

.auth-alt a {
    color: var(--border);
}

/* --- sidebar logout / run-now --- */

.nav-item-logout {
    margin-top: auto;
    opacity: 0.7;
}

.widget-actions {
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.run-now-btn {
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: rgba(137, 207, 240, 0.12);
    color: var(--text);
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
}

.run-now-btn:hover {
    background: rgba(137, 207, 240, 0.2);
}

.run-now-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.run-now-status {
    font-size: 0.85rem;
    opacity: 0.8;
}

.run-now-status.run-now-ok { color: var(--ok); }
.run-now-status.run-now-fail { color: var(--fail); }

/* --- companies --- */

.company-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 900px;
}

.company-card {
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--bg-panel);
    padding: 1.25rem 1.5rem;
}

.company-card-header {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    margin-bottom: 0.35rem;
}

.company-name {
    font-weight: 600;
    font-size: 1.1rem;
}

.company-industry {
    opacity: 0.7;
    font-size: 0.85rem;
}

.company-description {
    opacity: 0.85;
    margin-bottom: 0.75rem;
}

.company-modules {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.company-tag {
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    border: 1px solid var(--border-dim);
    background: rgba(137, 207, 240, 0.08);
    font-size: 0.8rem;
}

.company-tag-link {
    cursor: pointer;
}

.company-tag-link:hover {
    border-color: var(--border);
    background: rgba(137, 207, 240, 0.18);
}

.no-companies {
    opacity: 0.7;
}

/* --- booking insights --- */

.insight-panel {
    max-width: 700px;
}

.insight-panel-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    opacity: 0.9;
}

.state-bars {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.state-bar-row {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 5px 0.5rem;
    border-radius: 4px;
}

.state-bar-row:hover {
    background: rgba(137, 207, 240, 0.08);
}

.state-bar-label {
    width: 160px;
    flex-shrink: 0;
    font-size: 1.05rem;
    opacity: 0.8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.state-bar-track {
    flex: 1;
    height: 20px;
    background: var(--bg);
    border-radius: 3px;
    overflow: hidden;
    display: flex;
}

.state-bar-fill {
    display: block;
    height: 100%;
    background: var(--border);
    border-radius: 0 4px 4px 0;
}

.state-bar-value {
    width: 54px;
    flex-shrink: 0;
    text-align: right;
    font-size: 1.05rem;
    font-variant-numeric: tabular-nums;
    opacity: 0.95;
}

/* Stacked segments (e.g. Florida split) — square joins with a 2px surface gap
   between them, only the last segment carries the rounded data-end. */
.state-bar-segment {
    border-radius: 0;
    margin-right: 2px;
}

.state-bar-segment:last-child {
    margin-right: 0;
    border-radius: 0 4px 4px 0;
}

.state-bar-fill-border      { background: var(--border); }
.state-bar-fill-dragonfruit { background: var(--dragonfruit); }

.state-bar-legend {
    display: flex;
    gap: 1.25rem;
    padding: 0 0 10px calc(160px + 0.9rem);
}

.state-bar-legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    opacity: 0.75;
}

.state-bar-legend-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

/* --- campaigns --- */

.campaign-form {
    max-width: 900px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--bg-panel);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.campaign-form-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-grid-metrics {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-bottom: 1rem;
}

.form-grid .form-field {
    margin-bottom: 0;
}

.form-field-checkbox {
    justify-content: flex-end;
}

.form-label {
    font-size: 0.8rem;
    opacity: 0.75;
}

.form-input {
    background: var(--bg);
    border: 1px solid var(--border-dim);
    border-radius: 6px;
    padding: 0.55rem 0.7rem;
    color: var(--text);
    font: inherit;
    width: 100%;
}

.form-input:focus {
    outline: none;
    border-color: var(--border);
}

.form-textarea {
    resize: vertical;
    min-height: 120px;
    font-family: inherit;
}

.form-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    opacity: 0.9;
    padding-bottom: 0.55rem;
}

.form-section-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 1.25rem 0 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-dim);
}

.form-section-hint {
    font-weight: 400;
    font-size: 0.8rem;
    opacity: 0.6;
}

.campaign-image-preview {
    margin-top: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.campaign-image-preview img {
    max-width: 140px;
    max-height: 140px;
    border-radius: 6px;
    border: 1px solid var(--border-dim);
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
}

.btn-primary {
    padding: 0.6rem 1.2rem;
    border: 2px solid var(--border);
    border-radius: 6px;
    background: rgba(137, 207, 240, 0.12);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.btn-primary:hover {
    background: rgba(137, 207, 240, 0.2);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: default;
}

.btn-secondary {
    padding: 0.6rem 1.2rem;
    border: 1px solid var(--border-dim);
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    font: inherit;
    cursor: pointer;
}

.btn-secondary:hover {
    border-color: var(--border);
}

.btn-link {
    background: none;
    border: none;
    color: var(--border);
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0;
}

.btn-link:hover {
    text-decoration: underline;
}

.btn-danger {
    color: var(--fail);
}

.form-status {
    font-size: 0.85rem;
    opacity: 0.9;
}

.campaign-list-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.campaign-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 900px;
}

.campaign-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--bg-panel);
    padding: 0.9rem 1.25rem;
}

.campaign-row-main {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    flex: 1;
}

.campaign-row-name {
    font-weight: 600;
    margin-right: 0.25rem;
}

.campaign-row-date {
    font-size: 0.8rem;
    opacity: 0.65;
}

.campaign-row-metrics {
    display: flex;
    gap: 0.9rem;
    font-size: 0.85rem;
    opacity: 0.8;
}

.campaign-row-actions {
    display: flex;
    gap: 1rem;
    margin-left: auto;
}
