/* Teal Health - light theme defaults */
:root {
    --primary: #0D9488;
    --primaryDark: #0F766E;
    --primaryLight: #5EEAD4;
    --primarySubtle: #0D94881A;
    --bg: #F0FDFA;
    --mainBg: whitesmoke;
    --mainBgAlt: #DADCE0;
    --secondaryBg: #FAFAFA;
    --surface: #FFFFFF;
    --surfaceAlt: #CCFBF1;
    --surfaceRaised: #F5FFFE;
    --textPrimary: #0F172A;
    --textSecondary: #334155;
    --textMuted: #94A3B8;
    --border: #99F6E4;
    --borderStrong: #2DD4BF;
    --success: #059669;
    --warning: #D97706;
    --danger: #DC2626;
    --info: #0891B2;
    --accentGlow: #5EEAD4;
    --alertRoseBg: #FFF1F2;
    --alertRoseBorder: #FECDD3;
    --alertRoseText: #BE123C;
    --alertAmberBg: #FFFBEB;
    --alertAmberBorder: #FDE68A;
    --alertAmberText: #92400E;
    --alertGreenBg: #F0FDF4;
    --alertGreenBorder: #BBF7D0;
    --alertGreenText: #166534;
    --chartBarHigh: #F43F5E;
    --chartBarLow: #F59E0B;
    --shadow: 0 2px 12px rgba(13, 148, 136, 0.08), 0 1px 3px rgba(13, 148, 136, 0.05);
    --shadowLg: 0 16px 40px rgba(13, 148, 136, 0.12);
    --radiusXl: 20px;
    --radiusLg: 16px;
    --radiusMd: 12px;
    --radiusSm: 8px;
}

html.theme-dark {
    --primary: #2DD4BF;
    --primaryDark: #0D9488;
    --primaryLight: #134E4A;
    --primarySubtle: rgba(45, 212, 191, 0.14);
    --bg: #021009;
    --mainBg: #021009;
    --mainBgAlt: #021009;
    --secondaryBg: #061614;
    --surface: #061614;
    --surfaceAlt: #0A2421;
    --surfaceRaised: #0D2D29;
    --textPrimary: #F0FDFA;
    --textSecondary: #94A3B8;
    --textMuted: #4B5563;
    --border: #134E4A;
    --borderStrong: #115E59;
    --success: #34D399;
    --warning: #FBBF24;
    --danger: #F87171;
    --info: #22D3EE;
    --accentGlow: #0F766E;
    --alertRoseBg: rgba(239, 68, 68, 0.12);
    --alertRoseBorder: rgba(239, 68, 68, 0.25);
    --alertRoseText: #FCA5A5;
    --alertAmberBg: rgba(251, 191, 36, 0.10);
    --alertAmberBorder: rgba(251, 191, 36, 0.25);
    --alertAmberText: #FCD34D;
    --alertGreenBg: rgba(52, 211, 153, 0.10);
    --alertGreenBorder: rgba(52, 211, 153, 0.25);
    --alertGreenText: #34D399;
    --chartBarHigh: #FB7185;
    --chartBarLow: #FBBF24;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.25), 0 1px 3px rgba(0, 0, 0, 0.15);
    --shadowLg: 0 16px 40px rgba(0, 0, 0, 0.45);
}

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

html, body {
    margin: 0;
    padding: 0;
    font-family: Roboto, Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--textPrimary);
    -webkit-font-smoothing: antialiased;
    background-color: var(--mainBgAlt);
}

h1:focus {
    outline: none;
}

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

.card h3,
.page-card h3 {
    margin: 0 0 4px;
    font-size: 16px;
    font-weight: 700;
    color: var(--textPrimary);
}
button, input, textarea, select { font: inherit; }

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/*Input component*/
.in-input{
    font-size: 0.8rem;
    font-weight: 300;
    color: var(--textPrimary);
    height: 100%;
    width: 100%;
    outline: none;
    border: none;

    background: transparent;
    border-radius: var(--in-radius);
    padding: 0 0 0 var(--in-pad-x);
}

.in-input::placeholder{
    color: color-mix(in srgb, var(--in-muted) 75%, transparent);
}

.form-login_register {
    width: 100%;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.validation-message {
    color: #ef4444;
    font-size: 0.8rem;
    font-weight: 300;
}

.in-input-checkbox{
    width: 14px;
    height: 14px;
    padding: 0;
    accent-color: var(--primary);
    border-radius: 4px;
    justify-self: start;
    cursor: pointer;
}

/* Hover Elevation */
.in-input-checkbox:hover{
    border-color: var(--in-accent);
    box-shadow:
            0 0 0 3px color-mix(in srgb, var(--in-accent) 18%, transparent),
            var(--in-shadow-focus);
}

/* Focus Elevation */
.in-input-checkbox:focus-within{
    border-color: var(--in-accent);
    box-shadow:
            0 0 0 3px color-mix(in srgb, var(--in-accent) 18%, transparent),
            var(--in-shadow-focus);
}

/*sidebar link*/
.sb-link {
    display: flex;
    gap: 0.8rem;
    align-items: center;
    
    color: var(--textPrimary);
    padding: 0.85rem 1rem;
    font-size: 0.92rem;
    border-radius: 10px;
    transition: background 140ms ease, color 140ms ease;
}

.sb-link:hover {
    background: #f3f4f6;
    color: var(--sb-text);
}

.sb-link.active {
    background: var(--primary);
    color: white;
    font-weight: 500;
}

.sb-link.active .sb-link-icon {
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* Cards & surfaces */
.page-card,
.card,
.oauth-card,
.admin-tile,
.permission-group-card {
    background: var(--secondaryBg);
    /*border: 1px solid var(--border);*/
    border-radius: var(--radiusXl);
    box-shadow: var(--shadow);
    padding: 24px;
}

.page-card { display: grid; gap: 1rem; }

/* Grid layouts */
.dashboard-grid,
.two-col-grid,
.metric-grid,
.admin-home-grid,
.admin-action-grid,
.oauth-grid,
.permission-group-grid,
.form-grid {
    display: grid;
    gap: 20px;
}

.dashboard-grid,
.two-col-grid { grid-template-columns: 1.2fr .8fr; }
.metric-grid { grid-template-columns: repeat(4, 1fr); }
.metric-grid-two,
.oauth-grid,
.permission-group-grid,
.admin-home-grid,
.admin-action-grid { grid-template-columns: repeat(2, 1fr); }
.panel-wide { grid-column: 1 / -1; }
.field-span-2 { grid-column: span 2; }

/* Hero card */
.hero-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primaryDark) 100%);
    color: #FFFFFF;
    border-radius: var(--radiusXl);
    padding: 28px;
    box-shadow: var(--shadowLg);
}

.eyebrow {
    font-size: 12px;
    font-weight: 700;
    opacity: .85;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.hero-reading-row { display: flex; align-items: end; gap: 10px; margin-top: 12px; }
.hero-reading { font-size: 72px; font-weight: 800; line-height: 1; }
.hero-unit { margin-bottom: 10px; font-size: 20px; font-weight: 600; }

/* Badges & pills */
.status-pill,
.badge,
.summary-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    background: var(--surfaceAlt);
    border: 1px solid var(--border);
    color: var(--textPrimary);
    font-size: 13px;
    font-weight: 600;
}

.metric-label { color: var(--textSecondary); font-size: 13px; font-weight: 500; }
.metric-value { margin-top: 4px; font-size: 28px; font-weight: 800; }
.muted-text { color: var(--textMuted); font-size: 13px; }

.card-title-row { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.card-title-row h1,
.card-title-row h3,
.page-card h1 { margin: 0 0 4px; }
.page-card p { margin: 0; color: var(--textSecondary); font-size: 14px; }

/* Bar chart */
.bar-chart {
    height: 240px;
    padding: 16px;
    border-radius: var(--radiusLg);
    background: linear-gradient(180deg, var(--surfaceAlt) 0%, var(--surfaceRaised) 100%);
    display: flex;
    align-items: end;
    gap: 8px;
}

.bar {
    flex: 1;
    border-radius: 6px 6px 0 0;
    background: linear-gradient(180deg, var(--primary) 0%, var(--primaryDark) 100%);
    opacity: .8;
    transition: opacity 150ms ease;
}

.bar:hover { opacity: 1; }

/* Form elements */
.app-input {
    width: 100%;
    min-height: 44px;
    padding: 0 14px;
    border-radius: var(--radiusSm);
    border: 1px solid var(--border);
    background: var(--primarySubtle);
    color: var(--textPrimary);
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.app-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primarySubtle);
}

.app-textarea {
    min-height: 120px;
    padding-top: 12px;
    padding-bottom: 12px;
    resize: vertical;
}

label {
    display: block;
    margin-bottom: 6px;
    color: var(--textSecondary);
    font-size: 13px;
    font-weight: 600;
}

/* Buttons */
.app-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 18px;
    border-radius: var(--radiusMd);
    border: 1px solid transparent;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: background 150ms ease, box-shadow 150ms ease, transform 100ms ease;
}

.app-btn:active { transform: scale(.98); }

.app-btn-primary {
    background: var(--primary);
    color: #FFFFFF;
    box-shadow: 0 2px 8px rgba(13, 148, 136, 0.25);
}

.app-btn-primary:hover {
    background: var(--primaryDark);
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.35);
}

.app-btn-outline {
    background: var(--surface);
    color: var(--textPrimary);
    border-color: var(--border);
}

.app-btn-outline:hover {
    border-color: var(--borderStrong);
    background: var(--surfaceAlt);
}

.app-btn-danger {
    background: var(--danger);
    color: white;
}

.app-btn-danger:hover { opacity: .88; }

.btn-sm {
    min-height: 36px;
    padding: 0 12px;
    border-radius: var(--radiusSm);
    font-size: 13px;
}

/* Scroll lock — applied by dialog-lock.js when any modal is open */
body.dialog-open { overflow: hidden; }

/* Tables */
.table-wrap { overflow-x: auto; border-radius: var(--radiusMd); }
.app-table { width: 100%; border-collapse: collapse; }

.app-table th,
.app-table td {
    text-align: left;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.app-table th {
    color: var(--textMuted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    background: var(--surfaceAlt);
    /* Sticky header inside scrollable table-wrap containers */
    position: sticky;
    top: 0;
    z-index: 1;
}

.app-table tr:last-child td { border-bottom: none; }
.app-table tbody tr:hover { background: var(--surfaceRaised); }

/* Settings rows */
.settings-list,
.stack-list { display: grid; gap: 10px; }

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    border-radius: var(--radiusMd);
    background: var(--mainBg);
}

.row-actions,
.toolbar-actions,
.switch-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-inline { width: 260px; }

.admin-tile-title,
.permission-group-title,
.row-title { font-weight: 700; font-size: 15px; }

.admin-tile-text { color: var(--textSecondary); margin-top: 6px; font-size: 14px; }

.permission-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.permission-item:last-child { border-bottom: none; }

/* Responsive */
@media (max-width: 960px) {
    .dashboard-grid,
    .two-col-grid,
    .metric-grid-two,
    .oauth-grid,
    .permission-group-grid,
    .admin-home-grid,
    .admin-action-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .metric-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .field-span-2 { grid-column: span 1; }
    .input-inline { width: 100%; }
}

@media (max-width: 600px) {
    .metric-grid {
        grid-template-columns: 1fr;
    }

    .card, .page-card, .oauth-card, .admin-tile, .permission-group-card {
        padding: 16px;
    }

    .hero-reading { font-size: 48px; }
    .hero-unit { font-size: 16px; }
    .metric-value { font-size: 22px; }

    .app-table th,
    .app-table td {
        padding: 10px 12px;
        font-size: 13px;
    }

    .settings-row {
        flex-wrap: wrap;
    }

    .bar-chart {
        height: 180px;
        padding: 12px;
    }

    .card-title-row {
        flex-wrap: wrap;
    }
}
