:root {
    --accent: #fcb425;
    --accent-dark: #d99700;
    --accent-soft: #fff4d6;
    --up: #22a06b;
    --up-soft: #e6f5ee;
    --down: #d64545;
    --down-soft: #fde8e8;
    --degraded: #fcb425;
    --degraded-soft: #fff4d6;
    --none: #d0d5dd;
    --none-soft: #f2f4f7;
    --card-border: #e5e7eb;
}

html, body {
    background-color: #fafafa;
    color: #1f2937;
}

/* --- Navbar --- */
.brand-nav {
    background: #ffffff;
    border-bottom: 3px solid var(--accent);
}

.brand-logo {
    height: 28px;
    width: 28px;
    display: block;
    object-fit: contain;
    flex-shrink: 0;
}

.brand-name {
    font-weight: 700;
    font-size: 1.05rem;
    color: #1f2937;
    letter-spacing: -0.01em;
    margin-left: 0.55rem;
    line-height: 1;
}

.brand-divider {
    width: 1px;
    height: 22px;
    background: #d1d5db;
    margin: 0 0.75rem;
    display: inline-block;
}

.brand-subtitle {
    font-weight: 500;
    font-size: 0.95rem;
    color: #4b5563;
    letter-spacing: 0.01em;
}

/* --- Overall banner --- */
.overall-banner {
    background: #ffffff;
    border: 1px solid var(--card-border);
    border-left: 6px solid var(--accent);
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 4px 14px rgba(17, 24, 39, 0.05),
                0 1px 3px  rgba(17, 24, 39, 0.04);
}

.overall-banner.status-up { border-left-color: var(--up); }
.overall-banner.status-degraded { border-left-color: var(--degraded); }
.overall-banner.status-down { border-left-color: var(--down); }
.overall-banner.status-maintenance { border-left-color: #7c3aed; }

.overall-icon {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 1.4rem;
    background: var(--none-soft);
    color: #6b7280;
    flex-shrink: 0;
}

.overall-banner.status-up .overall-icon {
    background: var(--up-soft);
    color: var(--up);
}
.overall-banner.status-degraded .overall-icon {
    background: var(--degraded-soft);
    color: var(--accent-dark);
}
.overall-banner.status-down .overall-icon {
    background: var(--down-soft);
    color: var(--down);
}
.overall-banner.status-maintenance .overall-icon {
    background: #ede9fe;
    color: #5b21b6;
}

/* --- Service rows --- */
.service-row {
    background: #ffffff;
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 0.9rem 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.9rem;
    box-shadow: 0 1px 3px rgba(17, 24, 39, 0.04),
                0 1px 2px rgba(17, 24, 39, 0.03);
}

.service-status-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.service-status-icon.status-up {
    background: var(--up-soft);
    color: var(--up);
}
.service-status-icon.status-down {
    background: var(--down-soft);
    color: var(--down);
}
.service-status-icon.status-maintenance {
    background: #ede9fe;
    color: #5b21b6;
}

.service-name {
    font-weight: 600;
}

.service-meta {
    color: #6b7280;
    font-size: 0.8rem;
}

.service-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.service-badge.status-up {
    background: var(--up-soft);
    color: var(--up);
}
.service-badge.status-down {
    background: var(--down-soft);
    color: var(--down);
}
.service-badge.status-maintenance {
    background: #ede9fe;
    color: #5b21b6;
}

/* --- History (per-day list) --- */
.history-list {
    background: #ffffff;
    border: 1px solid var(--card-border);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(17, 24, 39, 0.04),
                0 1px 2px rgba(17, 24, 39, 0.03);
}

.history-day {
    padding: 0.85rem 1.1rem;
    border-bottom: 1px solid var(--card-border);
}

.history-day:last-child {
    border-bottom: 0;
}

.history-day-header {
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.25rem;
}

.history-empty {
    color: #6b7280;
    font-size: 0.85rem;
}

.incident-line {
    padding: 0.5rem 0;
    border-top: 1px dashed var(--card-border);
    margin-top: 0.5rem;
}

.incident-line:first-child {
    border-top: 0;
    margin-top: 0;
    padding-top: 0.35rem;
}

.incident-headline {
    font-weight: 500;
    color: #1f2937;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.incident-meta {
    color: #6b7280;
    font-size: 0.78rem;
    margin-top: 0.15rem;
}

.incident-notes {
    color: #374151;
    font-size: 0.85rem;
    margin-top: 0.25rem;
    white-space: pre-wrap;
}

/* Rich-text notes/details rendered from sanitised HTML. Overrides the
   pre-wrap above so paragraphs and lists format naturally. */
.rich-notes {
    white-space: normal;
}
.rich-notes p        { margin: 0 0 0.4rem 0; }
.rich-notes p:last-child { margin-bottom: 0; }
.rich-notes p:empty      { display: none; }
.rich-notes ul,
.rich-notes ol       { margin: 0 0 0.4rem 1.25rem; padding: 0; }
.rich-notes li       { margin-bottom: 0.15rem; }
.rich-notes h3,
.rich-notes h4       { font-size: 0.95rem; margin: 0.4rem 0 0.2rem; }
.rich-notes blockquote {
    margin: 0.3rem 0;
    padding: 0.2rem 0.75rem;
    border-left: 3px solid var(--card-border);
    color: #4b5563;
}
.rich-notes code {
    background: var(--none-soft);
    padding: 0.05rem 0.3rem;
    border-radius: 4px;
    font-size: 0.8rem;
}
.rich-notes pre {
    background: var(--none-soft);
    padding: 0.5rem 0.7rem;
    border-radius: 6px;
    font-size: 0.8rem;
    overflow-x: auto;
    margin: 0.3rem 0;
}
.rich-notes a { color: var(--accent-dark); }

.pill {
    display: inline-block;
    font-size: 0.72rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    background: var(--none-soft);
    color: #374151;
}

.pill.sev-outage      { background: var(--down-soft);     color: var(--down); }
.pill.sev-performance { background: var(--degraded-soft); color: var(--accent-dark); }
.pill.state-investigating { background: var(--degraded-soft); color: var(--accent-dark); }
.pill.state-monitoring    { background: #e0f2fe; color: #075985; }
.pill.state-resolved      { background: var(--up-soft); color: var(--up); }
.pill.type-maintenance    { background: #ede9fe; color: #5b21b6; }
.pill.service             { background: var(--none-soft); color: #374151; text-transform: none; }

.pill.timing-ongoing  { background: var(--down-soft);     color: var(--down); }
.pill.timing-today    { background: var(--accent-soft);   color: var(--accent-dark); }
.pill.timing-week     { background: var(--degraded-soft); color: var(--accent-dark); }
.pill.timing-upcoming { background: #ede9fe;              color: #5b21b6; }
.pill.timing-later    { background: var(--none-soft);     color: #4b5563; }

/* --- Maintenance cards --- */
.maint-card {
    background: #ffffff;
    border: 1px solid var(--card-border);
    border-left: 5px solid var(--none);
    border-radius: 10px;
    padding: 0.85rem 1.1rem 0.95rem;
    display: flex;
    align-items: flex-start;
    gap: 0.9rem;
    box-shadow: 0 1px 3px rgba(17, 24, 39, 0.04),
                0 1px 2px rgba(17, 24, 39, 0.03);
}
.maint-card + .maint-card { margin-top: 0.6rem; }

.maint-card.timing-ongoing  { border-left-color: var(--down);     background: #fff7f7; }
.maint-card.timing-today    { border-left-color: var(--accent);   background: #fffbf0; }
.maint-card.timing-week     { border-left-color: var(--degraded); }
.maint-card.timing-upcoming { border-left-color: #7c3aed; }
.maint-card.timing-later    { border-left-color: var(--none); }

.maint-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    background: var(--none-soft);
    color: #6b7280;
    flex-shrink: 0;
    margin-top: 0.1rem;
}
.maint-card.timing-ongoing  .maint-icon { background: var(--down-soft);     color: var(--down); }
.maint-card.timing-today    .maint-icon { background: var(--accent-soft);   color: var(--accent-dark); }
.maint-card.timing-week     .maint-icon { background: var(--degraded-soft); color: var(--accent-dark); }
.maint-card.timing-upcoming .maint-icon { background: #ede9fe;              color: #5b21b6; }

.maint-body { flex: 1 1 auto; min-width: 0; }

.maint-header {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
    margin-bottom: 0.15rem;
}

.maint-title  { font-weight: 600; color: #1f2937; }
.maint-window { color: #4b5563; font-size: 0.82rem; }
.maint-details {
    color: #374151;
    font-size: 0.85rem;
    margin-top: 0.35rem;
    white-space: pre-wrap;
}

@media (max-width: 576px) {
    .service-row { flex-wrap: wrap; }
    .service-meta { width: 100%; }
}

/* --- Motion (subtle; disabled by prefers-reduced-motion) --- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInLeft {
    from { opacity: 0; transform: translateX(-12px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes softPulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.15); }
}
@keyframes breathe {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.05); }
}
@keyframes checkPop {
    0%   { transform: scale(0.4); opacity: 0; }
    55%  { transform: scale(1.18); opacity: 1; }
    75%  { transform: scale(0.95); }
    100% { transform: scale(1); opacity: 1; }
}
@keyframes ringPulseUp {
    0%   { box-shadow: 0 0 0 0    rgba(34, 160, 107, 0.45); }
    70%  { box-shadow: 0 0 0 14px rgba(34, 160, 107, 0); }
    100% { box-shadow: 0 0 0 0    rgba(34, 160, 107, 0); }
}
@keyframes ringPulseDown {
    0%   { box-shadow: 0 0 0 0    rgba(214, 69, 69, 0.55); }
    70%  { box-shadow: 0 0 0 18px rgba(214, 69, 69, 0); }
    100% { box-shadow: 0 0 0 0    rgba(214, 69, 69, 0); }
}
@keyframes ringPulseAccent {
    0%   { box-shadow: 0 0 0 0    rgba(252, 180, 37, 0.6); }
    70%  { box-shadow: 0 0 0 18px rgba(252, 180, 37, 0); }
    100% { box-shadow: 0 0 0 0    rgba(252, 180, 37, 0); }
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
@keyframes bannerSweep {
    from { background-position: -200% 0; }
    to   { background-position:  200% 0; }
}

@media (prefers-reduced-motion: no-preference) {
    /* Fade sections in on first render and on every data refresh */
    .overall-banner   { animation: fadeInUp   0.55s cubic-bezier(.2,.7,.2,1) both; }
    .service-row      { animation: fadeInLeft 0.45s cubic-bezier(.2,.7,.2,1) both; }
    .maint-card       { animation: fadeInUp   0.50s cubic-bezier(.2,.7,.2,1) both; }
    .history-day      { animation: fadeInUp   0.40s ease-out both; }
    .incident-line    { animation: fadeIn     0.35s ease-out both; }

    /* Stagger the service rows and maintenance cards so they cascade */
    .service-row:nth-child(1)  { animation-delay: 0.00s; }
    .service-row:nth-child(2)  { animation-delay: 0.10s; }
    .service-row:nth-child(3)  { animation-delay: 0.20s; }
    .service-row:nth-child(4)  { animation-delay: 0.30s; }
    .service-row:nth-child(n+5){ animation-delay: 0.40s; }

    .maint-card:nth-child(1)   { animation-delay: 0.00s; }
    .maint-card:nth-child(2)   { animation-delay: 0.12s; }
    .maint-card:nth-child(3)   { animation-delay: 0.24s; }
    .maint-card:nth-child(n+4) { animation-delay: 0.36s; }

    /* Hover lift for interactive-feeling cards */
    .service-row,
    .maint-card {
        transition: transform 0.2s cubic-bezier(.2,.7,.2,1),
                    box-shadow 0.2s ease,
                    border-color 0.2s ease;
    }
    .service-row:hover,
    .maint-card:hover {
        transform: translateY(-3px);
        box-shadow: 0 8px 22px rgba(0, 0, 0, 0.09);
    }

    /* Attention pulse on non-healthy overall banner icon */
    .overall-banner.status-down .overall-icon {
        animation: softPulse 1.6s ease-in-out infinite,
                   ringPulseDown 1.6s ease-in-out infinite;
    }
    .overall-banner.status-degraded .overall-icon {
        animation: softPulse 1.8s ease-in-out infinite,
                   ringPulseAccent 1.8s ease-in-out infinite;
    }
    /* Healthy state: one-shot pop, then a soft breathe + green halo. */
    .overall-banner.status-up .overall-icon {
        animation: checkPop 0.6s cubic-bezier(.34,1.56,.64,1) both,
                   breathe 3.4s ease-in-out 0.6s infinite,
                   ringPulseUp 3.4s ease-in-out 0.6s infinite;
    }
    .service-status-icon.status-up {
        animation: checkPop 0.55s cubic-bezier(.34,1.56,.64,1) both;
    }

    /* Ongoing maintenance draws a soft accent ring */
    .maint-card.timing-ongoing .maint-icon {
        animation: softPulse 1.4s ease-in-out infinite,
                   ringPulseDown 1.4s ease-in-out infinite;
    }
    .maint-card.timing-today .maint-icon {
        animation: softPulse 1.8s ease-in-out infinite,
                   ringPulseAccent 1.8s ease-in-out infinite;
    }

    /* Rotating spinner while the initial "Loading..." indicator shows */
    #last-updated .bi-arrow-repeat {
        display: inline-block;
        animation: spin 1s linear infinite;
    }

    /* Colour transitions on service badges/icons when status flips */
    .service-status-icon,
    .service-badge,
    .pill { transition: background-color 0.25s ease, color 0.25s ease; }
}
