/* BrownstoneBot - reimagined */

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

:root {
    /* Primitive Tokens - Grays */
    --snow: #ffffff;
    --ivory: #f9f7f4;
    --linen: #f4efe6;
    --parchment: #efe6d7;
    --oat: #e5ddd0;
    --sand: #d1c7b8;
    --fossil: #a89f94;
    --slate: #7a7168;
    --driftwood: #5f564f;
    --walnut: #4a433d;
    --charcoal: #352f2a;
    --soot: #221b16;
    --obsidian: #0f0c0a;

    /* Primitive Tokens - Browns */
    --safari: #f5e6d9;
    --almond: #e5c4a8;
    --terracotta: #c2724a;
    --rust: #a85b36;
    --sienna: #8b4a24;
    --umber: #6a3a1f;
    --mahogany: #4b2a1a;

    /* Primitive Tokens - Reds */
    --blush: rgba(176, 58, 46, 0.08);
    --rose: rgba(176, 58, 46, 0.2);
    --coral: rgba(176, 58, 46, 0.4);
    --brick: #b03a2e;
    --crimson: #922f25;
    --maroon: #7a231c;

    /* Primitive Tokens - Oranges */
    --apricot: rgba(194, 124, 44, 0.08);
    --peach: rgba(194, 124, 44, 0.2);
    --tangerine: rgba(194, 124, 44, 0.4);
    --amber: #d9822b;
    --honey: #f0b35a;
    --molasses: #7a4a0a;

    /* Primitive Tokens - Greens */
    --sage: rgba(47, 107, 79, 0.12);
    --fern: rgba(46, 125, 80, 0.18);
    --forest: #2f6b4f;
    --pine: #2f6b3f;
    --clover: rgba(46, 214, 72, 0.55);
    --shamrock: #2ed648;

    /* Primitive Tokens - Blues */
    --mist: rgba(43, 111, 145, 0.12);
    --teal: #2b6f91;

    /* Primitive Tokens - Purples */
    --lavender: rgba(116, 88, 164, 0.2);
    --plum: #5a3a8e;

    /* Semantic Tokens - Backgrounds */
    --bg-page: var(--linen);
    --bg-page-strong: var(--parchment);
    --bg-card: var(--snow);
    --bg-card-translucent: rgba(255, 255, 255, 0.85);
    --bg-card-translucent-strong: rgba(255, 255, 255, 0.9);
    --bg-card-gradient: linear-gradient(160deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.88));
    --bg-card-gradient-light: linear-gradient(160deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.8));
    --bg-subtle: rgba(34, 27, 22, 0.04);
    --bg-subtle-strong: rgba(34, 27, 22, 0.05);
    --bg-subtle-weak: rgba(34, 27, 22, 0.02);
    --bg-hover: rgba(194, 114, 74, 0.08);
    --bg-hover-strong: rgba(194, 114, 74, 0.18);

    /* Semantic Tokens - Text */
    --text-primary: var(--soot);
    --text-secondary: var(--driftwood);
    --text-tertiary: rgba(34, 27, 22, 0.45);
    --text-inverse: var(--snow);
    --text-link: var(--rust);
    --text-link-hover: var(--terracotta);

    /* Semantic Tokens - Brand */
    --brand-dark: var(--mahogany);
    --brand-mid: var(--umber);
    --brand-light: var(--sienna);

    /* Semantic Tokens - Interactive */
    --accent: var(--terracotta);
    --accent-hover: var(--rust);
    --accent-focus-ring: rgba(194, 114, 74, 0.2);

    --destructive: var(--brick);
    --destructive-hover: var(--crimson);

    /* Semantic Tokens - Status */
    --status-error-bg: var(--blush);
    --status-error-border: var(--coral);
    --status-error-text: var(--maroon);

    --status-warning-bg: var(--peach);
    --status-warning-border: var(--tangerine);
    --status-warning-text: var(--molasses);

    --status-success-bg: var(--fern);
    --status-success-border: rgba(194, 114, 74, 0.4);
    --status-success-text: var(--pine);

    --status-info-bg: rgba(99, 102, 110, 0.08);
    --status-info-border: rgba(99, 102, 110, 0.4);
    --status-info-text: var(--text-secondary);

    --status-insight-bg: var(--lavender);
    --status-insight-text: var(--plum);

    /* Semantic Tokens - Borders & Shadows */
    --border-default: rgba(34, 27, 22, 0.12);
    --border-subtle: rgba(34, 27, 22, 0.08);
    --border-input: rgba(34, 27, 22, 0.2);
    --border-accent: rgba(194, 114, 74, 0.2);

    --shadow-soft: 0 10px 30px rgba(34, 27, 22, 0.08);
    --shadow-tight: 0 2px 6px rgba(34, 27, 22, 0.12);
    --shadow-hover: 0 12px 24px rgba(34, 27, 22, 0.12);

    /* Semantic Tokens - Sanitation Schedule */
    --schedule-trash: #2f2f2f;
    --schedule-large: #3b3b3b;
    --schedule-recycling: var(--teal);
    --schedule-recycling-bg: var(--mist);
    --schedule-compost: var(--forest);
    --schedule-compost-bg: var(--sage);

    /* Semantic Tokens - Temperature */
    --temp-gradient-start: var(--honey);
    --temp-gradient-end: var(--amber);

    /* Semantic Tokens - Energy Chart */
    --energy-bar: var(--clover);
    --energy-border: var(--shamrock);

    /* Semantic Tokens - Page Decorations */
    --bg-glow-warm: rgba(139, 74, 36, 0.15);
    --bg-glow-accent: rgba(194, 114, 74, 0.18);

    /* Layout Tokens */
    --radius-s: 10px;
    --radius-m: 16px;
    --radius-l: 22px;
    --radius-pill: 999px;

    --space-1: 6px;
    --space-2: 12px;
    --space-3: 18px;
    --space-4: 24px;
    --space-5: 32px;
    --space-6: 48px;
}

html {
    font-size: 16px;
}

body {
    margin: 0;
    color: var(--text-primary);
    font-family: "Avenir Next", "Avenir", "Gill Sans", "Trebuchet MS", sans-serif;
    background-color: var(--bg-page);
    background-image:
        radial-gradient(1200px 600px at 10% -10%, var(--bg-glow-warm), transparent 60%),
        radial-gradient(900px 700px at 90% 10%, var(--bg-glow-accent), transparent 65%),
        linear-gradient(180deg, var(--bg-page), var(--bg-page-strong));
    min-height: 100vh;
}

main {
    display: block;
}

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

a:hover {
    color: var(--text-link-hover);
}

p {
    line-height: 1.6;
    color: var(--text-secondary);
}

h1, h2, h3, h4, h5, h6 {
    font-family: "Iowan Old Style", "Palatino", "Georgia", serif;
    font-weight: 700;
    margin: 0 0 var(--space-3) 0;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

h1 {
    font-size: clamp(2.5rem, 5vw, 5rem);
    line-height: 1.05;
}

h2 {
    font-size: clamp(1.8rem, 3.5vw, 2.8rem);
}

h3 {
    font-size: clamp(1.4rem, 2.5vw, 2rem);
}

h4 {
    font-size: 1.2rem;
}

h5 {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    color: var(--text-secondary);
}

.site-header {
    padding: clamp(18px, 3vw, 36px) clamp(16px, 6vw, 60px);
    background: linear-gradient(135deg, var(--brand-dark), var(--brand-mid) 60%, var(--brand-light));
    color: var(--text-inverse);
    box-shadow: var(--shadow-soft);
}

.site-header h1 {
    color: var(--text-inverse);
    margin: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.site-main {
    padding: clamp(18px, 4vw, 48px) clamp(16px, 5vw, 64px) clamp(40px, 6vw, 72px);
}

.app-shell {
    display: grid;
    grid-template-columns: minmax(200px, 260px) minmax(0, 1fr);
    gap: clamp(16px, 3vw, 36px);
    align-items: start;
}

.app-nav {
    position: sticky;
    top: 20px;
}

.nav {
    background: var(--bg-card-translucent);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-l);
    padding: var(--space-4);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(8px);
}

.nav-list {
    list-style: none;
    margin: 0 0 var(--space-4) 0;
    padding: 0;
    display: grid;
    gap: var(--space-2);
}

.nav-list a {
    display: block;
    padding: 10px 14px;
    border-radius: var(--radius-pill);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-subtle-strong);
    transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.nav-list a:hover {
    background: var(--bg-hover-strong);
    color: var(--accent-hover);
    transform: translateX(4px);
}

.nav-actions {
    margin-top: var(--space-3);
}

.nav-actions input[type="submit"] {
    width: 100%;
    border-radius: var(--radius-pill);
}

.app-content {
    background: var(--bg-card-translucent);
    border-radius: var(--radius-l);
    padding: clamp(18px, 3vw, 36px);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-soft);
    min-height: 60vh;
}

.app-content > *:first-child {
    margin-top: 0;
}

.button,
button,
input[type="submit"],
input[type="button"] {
    appearance: none;
    border: none;
    border-radius: var(--radius-pill);
    background: var(--accent);
    color: var(--text-inverse);
    font-weight: 700;
    padding: 10px 18px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.button:hover,
button:hover,
input[type="submit"]:hover,
input[type="button"]:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-tight);
}

.button + .button {
    margin-left: 8px;
}

.app-content .button {
    margin-bottom: 8px;
}

.site-main > form.large-form,
.site-main > .error {
    margin-left: auto;
    margin-right: auto;
}

.app-content td form {
    display: inline-block;
    margin: 0;
}

.destructive[type="submit"],
.destructive[type="button"] {
    background: var(--destructive);
}

.destructive[type="submit"]:hover,
.destructive[type="button"]:hover {
    background: var(--destructive-hover);
}

form {
    margin: var(--space-3) 0;
}

form.large-form {
    background: var(--bg-card-translucent-strong);
    border-radius: var(--radius-m);
    padding: clamp(16px, 3vw, 28px);
    border: 1px solid var(--border-default);
    box-shadow: var(--shadow-tight);
    max-width: 720px;
}

form.large-form label {
    display: block;
    margin-top: var(--space-3);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
}

form.large-form p {
    margin: 6px 0 0 0;
    font-size: 0.9rem;
}

input,
select,
textarea {
    width: 100%;
    margin-top: var(--space-2);
    padding: 10px 12px;
    border-radius: var(--radius-s);
    border: 1px solid var(--border-input);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 1rem;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-focus-ring);
}

form.large-form input[type="submit"] {
    width: auto;
    margin-top: var(--space-4);
}

form.centered-form {
    text-align: center;
}

form.inline {
    display: inline-flex;
    gap: var(--space-2);
    align-items: center;
}

.error,
.alert,
.notice,
.success,
.info {
    padding: var(--space-3);
    margin-bottom: var(--space-3);
    border-radius: var(--radius-s);
    border: 1px solid var(--border-default);
    background: var(--bg-card);
    box-shadow: var(--shadow-tight);
}

.error,
.alert {
    border-color: var(--status-error-border);
    background: var(--status-error-bg);
}

.notice {
    border-color: var(--status-warning-border);
    background: var(--orange-100);
}

.success {
    border-color: var(--status-success-border);
    background: var(--bg-hover);
}

.info {
    border-color: var(--status-info-border);
    background: var(--status-info-bg);
}

.content table,
.app-content table,
table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--space-4) 0;
    background: var(--bg-card);
    border-radius: var(--radius-m);
    overflow: hidden;
    border: 1px solid var(--border-default);
    box-shadow: var(--shadow-tight);
}

th,
td {
    text-align: left;
    padding: 12px 14px;
    font-size: 0.95rem;
}

thead th {
    background: var(--brand-dark);
    color: var(--text-inverse);
    font-weight: 700;
}

tbody tr:nth-child(even) {
    background: var(--bg-subtle);
}

tbody tr:hover {
    background: var(--bg-hover);
}

tfoot td {
    font-weight: 700;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-3);
    margin: var(--space-3) 0 var(--space-4);
    align-items: stretch;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius-m);
    padding: var(--space-3);
    border: 1px solid var(--border-default);
    box-shadow: var(--shadow-tight);
}

.card-grid .card {
    height: 100%;
}

.card + .card {
    margin-top: var(--space-3);
}

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

.service-provider-card {
    position: relative;
    overflow: hidden;
    padding: var(--space-4);
    background: var(--bg-card-gradient);
}

.service-provider-bg-icon {
    position: absolute;
    right: -10px;
    bottom: -14px;
    font-size: clamp(6.5rem, 14vw, 12rem);
    color: var(--border-subtle);
    transform: rotate(-6deg);
    pointer-events: none;
}

.service-provider-content {
    position: relative;
    z-index: 1;
    display: grid;
    gap: var(--space-2);
}

.service-provider-name {
    margin: 0;
    font-size: clamp(1.4rem, 2.5vw, 1.8rem);
}

.service-provider-role {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--text-tertiary);
    font-weight: 600;
}

.service-provider-line {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    color: var(--text-secondary);
}

.service-provider-line i {
    color: var(--text-tertiary);
    width: 18px;
    text-align: center;
}

.service-provider-line a {
    font-weight: 600;
}

.section-title {
    margin-top: var(--space-5);
}

.card-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-secondary);
    margin-bottom: var(--space-1);
}

.card-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.weather {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--space-3);
    margin: var(--space-3) 0 var(--space-5);
}

.weather-card {
    background: var(--bg-card-gradient-light);
    border-radius: var(--radius-l);
    border: 1px solid var(--border-subtle);
    padding: var(--space-3);
    text-align: center;
    box-shadow: var(--shadow-tight);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.weather-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

.weather-day {
    margin: 0 0 var(--space-1) 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.weather-icon-top {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: var(--space-2) 0 var(--space-1);
}

.weather-icon-top .wi {
    font-size: 3rem;
    color: var(--accent);
}

.weather-summary {
    margin: 0 0 var(--space-2) 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.weather-temps {
    font-size: 1.2rem;
    font-weight: 700;
    margin: var(--space-1) 0;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.temp-bar {
    position: relative;
    width: 8px;
    height: 64px;
    margin: var(--space-2) auto;
}

.temp-track {
    position: absolute;
    inset: 0;
    border-radius: var(--radius-pill);
    border: thin solid var(--border-accent);
}

.temp-segment {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 10px;
    height: 0;
    bottom: 0;
    border-radius: var(--radius-pill);
    background: linear-gradient(180deg, var(--temp-gradient-start), var(--temp-gradient-end));
}

.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-size: 0.85rem;
    font-weight: 600;
    max-width: fit-content;
    white-space: nowrap;
    flex-wrap: nowrap;
}

.status-pill-info {
    background: var(--border-subtle);
    color: var(--text-secondary);
}

.status-pill-success {
    background: var(--status-success-bg);
    color: var(--status-success-text);
}

.status-pill-warning {
    background: var(--status-warning-bg);
    color: var(--status-warning-text);
}

.status-pill-critical {
    background: var(--red-200);
    color: var(--status-error-text);
}

.status-pill-insight {
    background: var(--status-insight-bg);
    color: var(--status-insight-text);
}

.big-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .app-nav {
        position: static;
    }

    .nav {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: var(--space-2);
    }

    .nav-list {
        display: flex;
        flex-wrap: wrap;
        gap: var(--space-2);
        margin: 0;
    }

    .nav-actions {
        margin-left: auto;
    }

    .nav-actions input[type="submit"] {
        width: auto;
    }

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

}

@media (max-width: 720px) {
    .site-header {
        text-align: center;
    }

    .nav {
        flex-direction: column;
        align-items: stretch;
    }

    .nav-actions {
        width: 100%;
    }

    .app-content {
        padding: var(--space-3);
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    table {
        display: block;
        overflow-x: auto;
    }
}

.data-table {
    table-layout: auto;
}

.data-table th,
.data-table td {
    word-break: break-word;
}

.rule-cell div {
    margin-bottom: 6px;
}

.actions-cell {
    white-space: nowrap;
}

.actions-cell .button {
    margin-right: 6px;
    margin-bottom: 6px;
}

.actions-cell .button,
.actions-cell button,
.actions-cell form {
    justify-self: start;
    width: max-content;
}

.sanitation-schedule {
    width: 100%;
    border-collapse: separate;
    border-spacing: 10px;
    margin: 0 auto var(--space-4);
    max-width: 920px;
    min-width: 640px;
}

.sanitation-schedule th {
    text-align: center;
    padding: 10px 12px;
    background: transparent;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-primary);
}

.sanitation-schedule thead tr {
    background: var(--bg-subtle);
}

.sanitation-schedule th.is-highlight {
    background: var(--green-500);
    color: var(--text-inverse);
}

.sanitation-schedule td {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    padding: var(--space-2);
    vertical-align: top;
    box-shadow: var(--shadow-tight);
}

.schedule-items {
    display: grid;
    gap: 10px;
}

.schedule-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 12px;
    background: var(--bg-subtle);
    font-weight: 600;
    color: var(--text-primary);
}

.schedule-item i {
    width: 20px;
    text-align: center;
    font-size: 1.05rem;
}

.schedule-item.large {
    color: var(--schedule-large);
}

.schedule-item.trash {
    color: var(--schedule-trash);
}

.schedule-item.recycling {
    color: var(--schedule-recycling);
    background: var(--schedule-recycling-bg);
}

.schedule-item.compost {
    color: var(--schedule-compost);
    background: var(--schedule-compost-bg);
}

.schedule-item.none {
    color: var(--text-secondary);
    background: var(--bg-subtle-weak);
    font-weight: 500;
}

@media (max-width: 880px) {
    .data-table thead {
        display: none;
    }

    .data-table,
    .data-table tbody,
    .data-table tr,
    .data-table td {
        display: block;
        width: 100%;
    }

    .data-table tr {
        background: var(--bg-card);
        border-radius: var(--radius-m);
        border: 1px solid var(--border-default);
        margin-bottom: var(--space-3);
        padding: var(--space-2);
        box-shadow: var(--shadow-tight);
    }

    .data-table td {
        display: grid;
        grid-template-columns: minmax(120px, 35%) minmax(0, 1fr);
        gap: var(--space-2);
        padding: 8px 10px;
        align-items: center;
    }

    .data-table td::before {
        content: attr(data-label);
        font-size: 0.75rem;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        color: var(--text-secondary);
    }

    .data-table td.actions-cell {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        align-items: center;
    }

    .data-table td.actions-cell::before {
        width: auto;
        margin-right: 8px;
    }

    .data-table td:last-child {
        padding-bottom: 12px;
    }

    .actions-cell {
        white-space: normal;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition: none !important;
    }
}
