:root {
    --color-primary: #0c6e6d;
    --color-primary-hover: #0a5c5b;
    --color-primary-light: #e6f5f5;
    --color-secondary: #ff9307;
    --color-secondary-hover: #e68406;
    --color-secondary-light: #fff4e6;
    --bg-page: #f5f8fa;
    --bg-surface: #ffffff;
    --bg-sidebar: #0b3f3e;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --danger: #b91c1c;
    --danger-bg: #fef2f2;
    --success-bg: #ecfdf5;
    --success-text: #065f46;
    --radius: 0.5rem;
    --radius-sm: 0.375rem;
    --sidebar-width: 15.5rem;
    --font: Inter, Manrope, system-ui, -apple-system, Segoe UI, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    height: 100%;
}

body {
    margin: 0;
    min-height: 100%;
    font-family: var(--font);
    font-size: 0.875rem;
    line-height: 1.45;
    color: var(--text);
    background: var(--bg-page);
}

body:has(.app-shell) {
    height: 100%;
    overflow: hidden;
}

a {
    color: var(--color-primary);
    text-decoration: none;
}

a:hover {
    color: var(--color-primary-hover);
    text-decoration: underline;
}

img {
    max-width: 100%;
    height: auto;
}

button,
[type="submit"],
[type="button"],
.btn {
    border-radius: var(--radius);
    font: inherit;
    cursor: pointer;
}

.btn,
button[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    border: 0;
    background: var(--color-primary);
    color: #fff;
    padding: 0.5rem 1rem;
    font-weight: 600;
}

.btn:hover,
button[type="submit"]:hover {
    background: var(--color-primary-hover);
    color: #fff;
    text-decoration: none;
}

.btn-ghost,
button.btn-ghost {
    background: transparent;
    color: var(--color-primary);
    border: 1px solid var(--border);
}

.btn-ghost:hover,
button.btn-ghost:hover {
    background: var(--color-primary-light);
    color: var(--color-primary-hover);
}

.btn-secondary,
button.btn-secondary {
    background: var(--color-secondary);
    color: #fff;
}

.btn-secondary:hover,
button.btn-secondary:hover {
    background: var(--color-secondary-hover);
    color: #fff;
}

.content h2 {
    margin: 1.25rem 0 0.5rem;
    font-size: 1rem;
    color: var(--text);
}

/* Stack caption above control so text never sits on the input border */
label {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
    margin-top: 0.9rem;
    max-width: 40rem;
    font-weight: 600;
    color: var(--text);
}

label:has(> input[type="checkbox"]),
label:has(> input[type="radio"]) {
    flex-direction: row;
    align-items: center;
    gap: 0.55rem;
    max-width: none;
    font-weight: 500;
}

input,
select,
textarea {
    display: block;
    box-sizing: border-box;
    width: 100%;
    max-width: 40rem;
    margin: 0;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text);
    font: inherit;
    line-height: 1.3;
}

label > input,
label > select,
label > textarea {
    width: 100%;
    max-width: none;
}

input[type="checkbox"],
input[type="radio"] {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    max-width: none;
    margin: 0;
    padding: 0;
    flex: 0 0 auto;
    accent-color: var(--color-primary);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(12, 110, 109, 0.15);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    gap: 0.75rem 1rem;
    max-width: 56rem;
}

.form-grid > label {
    margin-top: 0;
    max-width: none;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

th,
td {
    border-bottom: 1px solid var(--border);
    text-align: left;
    padding: 0.65rem 0.75rem;
    vertical-align: top;
}

th {
    background: #f8fafc;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

tr:last-child td {
    border-bottom: 0;
}

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    margin: 0.75rem 0;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.card h2 {
    margin: 0 0 0.4rem;
    font-size: 0.95rem;
    color: var(--color-primary);
}

.card p,
.card ul {
    margin: 0.35rem 0;
    color: var(--text-muted);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
    gap: 0.85rem;
}

.card-grid .card {
    margin: 0;
}

.warn {
    color: #9a3412;
    background: var(--color-secondary-light);
    border: 1px solid #fdba74;
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.85rem;
}

.flash {
    margin: 0 0 1rem;
    padding: 0.65rem 0.85rem;
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid #a7f3d0;
    border-radius: var(--radius-sm);
}

.banner,
.info-strip {
    margin: 0;
    padding: 0.65rem 1.25rem;
    background: var(--color-primary-light);
    color: var(--color-primary-hover);
    border-bottom: 1px solid rgba(12, 110, 109, 0.15);
    font-size: 0.8125rem;
    flex: 0 0 auto;
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin: 0 0 1rem;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: 0 0 1rem;
    padding: 0.3rem;
    background: #eef5f5;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.tabs .tab {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 0.9rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 600;
    text-decoration: none;
}

.tabs .tab:hover {
    color: var(--color-primary);
    background: rgba(255, 255, 255, 0.7);
    text-decoration: none;
}

.tabs .tab.is-active {
    background: var(--bg-surface);
    color: var(--color-primary);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.tab-panel > h2:first-child {
    margin-top: 0;
}

.tab-panel .lede {
    margin: 0 0 1rem;
    color: var(--text-muted);
}

.tab-panel label {
    max-width: 40rem;
}

.auth-card label {
    max-width: none;
}

.badge {
    display: inline-block;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.badge-warn {
    background: var(--color-secondary-light);
    color: #9a3412;
}

.badge-muted {
    background: #f1f5f9;
    color: var(--text-muted);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.traffic-hit {
    margin-top: 1rem;
}

.traffic-hit__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.85rem;
    align-items: center;
    margin-bottom: 0.75rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.traffic-pre {
    margin: 0.35rem 0 0.85rem;
    padding: 0.65rem 0.75rem;
    max-height: 14rem;
    overflow: auto;
    background: #0f172a;
    color: #e2e8f0;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    white-space: pre-wrap;
    word-break: break-word;
}

form.inline {
    display: inline;
}

/* Authenticated shell */
.app-shell {
    height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    overflow: hidden;
}

.sidebar {
    background: linear-gradient(180deg, var(--bg-sidebar) 0%, #072928 100%);
    color: #e2e8f0;
    padding: 1rem 0.85rem 1.5rem;
    height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.25);
    border-radius: 999px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    margin: 0 0 0.85rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    text-decoration: none;
    color: #fff;
}

.sidebar-brand:hover {
    color: #fff;
    text-decoration: none;
}

.sidebar-brand .brand-mark {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-radius: 0.5rem;
    padding: 0.35rem 0.45rem;
    height: 2.5rem;
}

.sidebar-brand img {
    height: 1.6rem;
    width: auto;
    max-width: 7.5rem;
    display: block;
    object-fit: contain;
}

.sidebar-brand strong {
    display: none;
}

.sidebar-brand span {
    display: block;
    font-size: 0.75rem;
    color: #99f6e4;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.nav-group {
    margin: 0.85rem 0 0.35rem;
}

.nav-group-label {
    padding: 0.35rem 0.65rem;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #94a3b8;
}

.sidebar nav a {
    display: block;
    color: #cbd5e1;
    padding: 0.45rem 0.65rem;
    border-radius: var(--radius-sm);
    margin: 0.1rem 0;
    text-decoration: none;
    font-weight: 500;
}

.sidebar nav a:hover,
.sidebar nav a.is-active {
    background: rgba(12, 110, 109, 0.55);
    color: #fff;
    text-decoration: none;
}

.app-main {
    min-width: 0;
    min-height: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1.25rem;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    flex: 0 0 auto;
    z-index: 10;
}

.topbar h1 {
    margin: 0;
    font-size: 1.15rem;
    color: var(--text);
}

.topbar-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.topbar-meta button {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--color-primary);
    padding: 0.35rem 0.75rem;
    font-weight: 600;
}

.topbar-meta button:hover {
    background: var(--color-primary-light);
}

.content {
    padding: 1.15rem 1.25rem 2rem;
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
}

.content > h1:first-child {
    display: none;
}

/* Auth pages — light panels like KiyoHR login (logo is dark wordmark) */
.auth-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    background: #f8fbfb;
}

.auth-hero {
    background:
        radial-gradient(circle at top left, rgba(12, 110, 109, 0.08), transparent 36%),
        radial-gradient(circle at bottom right, rgba(15, 23, 42, 0.04), transparent 32%),
        linear-gradient(180deg, #ffffff 0%, #f5fbf9 100%);
    color: var(--text);
    padding: clamp(1.5rem, 4vw, 3rem);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.auth-hero img.logo {
    height: 2.5rem;
    width: auto;
    max-width: 11rem;
    object-fit: contain;
    display: block;
    margin-bottom: 1.5rem;
}

.auth-hero h1 {
    margin: 0 0 0.75rem;
    font-size: clamp(1.6rem, 2.5vw, 2rem);
    line-height: 1.2;
    color: var(--text);
}

.auth-hero > p {
    margin: 0;
    max-width: 28rem;
    color: var(--text-muted);
    font-size: 1rem;
}

.auth-hero .chips {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    margin-top: 2rem;
}

.auth-hero .chip {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 0.75rem;
    padding: 0.85rem 1rem;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.04);
}

.auth-hero .chip strong {
    display: block;
    font-size: 0.85rem;
    color: var(--color-primary);
}

.auth-hero .chip span {
    display: block;
    margin-top: 0.2rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.auth-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(1.25rem, 3vw, 2.5rem);
    background:
        radial-gradient(circle at top right, rgba(12, 110, 109, 0.06), transparent 30%),
        linear-gradient(180deg, #f8fbfb 0%, #eef7f6 100%);
}

.auth-card {
    width: min(26rem, 100%);
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.85);
    border-radius: 1.25rem;
    padding: clamp(1.25rem, 3vw, 2rem);
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

.auth-card .eyebrow {
    margin: 0 0 0.35rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.auth-card h2 {
    margin: 0 0 0.35rem;
    font-size: 1.35rem;
    color: var(--text);
}

.auth-card .lede {
    margin: 0 0 1.25rem;
    color: var(--text-muted);
}

.auth-card .mobile-logo {
    display: none;
    height: 2rem;
    width: auto;
    max-width: 9rem;
    object-fit: contain;
    margin-bottom: 1rem;
}

.auth-card form p {
    margin-top: 1.25rem;
}

.auth-card input {
    width: 100%;
}

@media (max-width: 960px) {
    body:has(.app-shell) {
        height: auto;
        overflow: auto;
    }

    .app-shell {
        grid-template-columns: 1fr;
        height: auto;
        overflow: visible;
    }

    .sidebar {
        position: relative;
        height: auto;
        max-height: none;
    }

    .app-main {
        height: auto;
        overflow: visible;
    }

    .content {
        overflow: visible;
    }

    .auth-page {
        grid-template-columns: 1fr;
    }

    .auth-hero {
        padding: 1.5rem;
        border-bottom: 1px solid var(--border);
    }

    .auth-hero .chips {
        grid-template-columns: 1fr;
    }

    .auth-card .mobile-logo {
        display: block;
    }
}
