/* =========================================================================
   Pogotowie Kulinarne Sync — dashboard + logowanie
   Design tokeny i responsywność wg specifications/16-dashboard-ui-design.md
   Mobile-first: reguły bazowe dla wąskiego ekranu, min-width w górę.
   ========================================================================= */

:root {
    color-scheme: light;

    --bg: #EDEAE1;
    --surface: #FFFFFF;
    --surface-alt: #FBFAF6;
    --ink: #16202B;
    --ink-2: #42505C;
    --muted: #6B7480;
    --muted-2: #9AA1A9;
    --border: #E4DFD2;
    --border-soft: #F4F1E8;
    --accent: #F4B31E;
    --link: #16A0A6;
    --link-hover: #0E7C81;

    --ok-bg: #E1F3E8;      --ok-fg: #1E7D4B;      --dot-ok: #3FCE85;
    --degraded-bg: #FBEFC9; --degraded-fg: #916100; --dot-degraded: #F4B31E;
    --down-bg: #FBE3E1;    --down-fg: #C22F2A;    --dot-down: #E23D3D;
    --skipped-bg: #ECE8DD; --skipped-fg: #6B7480; --dot-skipped: #B8BFC7;

    --radius: 16px;
    --radius-sm: 12px;
    --radius-xs: 9px;
    --shadow-bar: 0 2px 12px rgba(22, 32, 43, .18);

    --font-head: 'Bricolage Grotesque', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-body: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html, body { overflow-x: hidden; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--font-head); margin: 0; line-height: 1.15; }

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

code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; }

:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; border-radius: 4px; }

@keyframes pulseDot { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ---------------------------------------------------- top bar ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px 20px;
    padding: 12px 16px;
    background: var(--ink);
    color: #fff;
    box-shadow: var(--shadow-bar);
}

.topbar__brand { display: flex; align-items: center; gap: 10px; }
.topbar__logo {
    width: 38px; height: 38px; border-radius: 10px; background: #fff;
    display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.topbar__name { font-family: var(--font-head); font-weight: 800; font-size: 16px; }
.topbar__name span { color: var(--accent); }

.tabs {
    order: 3;
    width: 100%;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
    scroll-snap-align: start;
    padding: 9px 15px;
    min-height: 40px;
    border-radius: var(--radius-xs);
    font-size: 14px;
    font-weight: 500;
    color: #C3CAD2;
    background: transparent;
}
.tab:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.tab.is-active { background: var(--accent); color: var(--ink); font-weight: 700; }
.tab.is-active:hover { color: var(--ink); }
.tab__badge {
    background: var(--dot-down); color: #fff; font-size: 11px; font-weight: 700;
    padding: 1px 7px; border-radius: 999px;
}
.tab.is-active .tab__badge { background: var(--ink); color: #fff; }

.topbar__meta { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 13px; color: #A9B2BC; }
.topbar__status { display: flex; align-items: center; gap: 7px; }
.topbar__logout { color: #A9B2BC; }
.topbar__logout:hover { color: #fff; }

/* ---------------------------------------------------- layout ----------- */
.wrap { max-width: 1320px; margin: 0 auto; padding: 20px 16px 64px; }

.view { display: none; }
.view.is-active { display: block; }

.page-head {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 18px;
}
.page-head h1 { font-size: 22px; font-weight: 800; }
.lead { margin: 5px 0 0; color: var(--muted); font-size: 14px; }

/* ---------------------------------------------------- grids ------------ */
.grid { display: grid; gap: 14px; margin-bottom: 16px; }
.grid--overview { grid-template-columns: 1fr; }
.grid--kpi { grid-template-columns: 1fr; }
.grid--monitors { grid-template-columns: 1fr; }
.grid--two { grid-template-columns: 1fr; }

/* ---------------------------------------------------- cards ------------ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
}
.card__head {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    margin: -16px -18px 14px; padding: 15px 18px; border-bottom: 1px solid var(--border-soft);
}
.card__head h3 { font-size: 15px; font-weight: 700; }
.card__body { margin-top: 2px; }
.link { font-size: 12.5px; font-weight: 600; }

.stack { display: flex; flex-direction: column; gap: 10px; }
.stat-row { display: flex; align-items: center; justify-content: space-between; font-size: 13.5px; color: var(--ink-2); }
.stat-row b { font-family: var(--font-head); font-size: 18px; }

/* ring / stan ogólny */
.ring-card { display: flex; align-items: center; gap: 18px; }
.ring { width: 96px; height: 96px; flex: 0 0 auto; }
.ring__pct { font-family: var(--font-head); font-weight: 800; font-size: 24px; fill: var(--ink); }
.ring__cap { font-family: var(--font-body); font-size: 10px; fill: var(--muted); }
.ring-card__title { font-family: var(--font-head); font-weight: 700; font-size: 16px; }
.ring-card__sub { font-size: 13px; color: var(--muted); margin-top: 3px; }
.ring-card__meta { font-size: 12.5px; color: var(--degraded-fg); margin-top: 6px; }

/* KPI */
.kpi__label { font-size: 12.5px; color: var(--muted); }
.kpi__value { font-family: var(--font-head); font-weight: 800; font-size: 28px; margin-top: 4px; }
.kpi__value.is-warn { color: var(--degraded-fg); }
.kpi__value.is-error { color: var(--down-fg); }
.kpi__trend { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* monitory — mini kafle na przeglądzie */
.monitor-mini { border-left: 4px solid var(--dot-skipped); }
.monitor-mini--ok { border-left-color: var(--dot-ok); }
.monitor-mini--degraded { border-left-color: var(--dot-degraded); }
.monitor-mini--down { border-left-color: var(--dot-down); }
.monitor-mini__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.monitor-mini__name { font-weight: 600; font-size: 13.5px; }
.monitor-mini__row { font-size: 12px; color: var(--muted); margin-top: 8px; }
.monitor-mini__row b { color: var(--ink-2); }

/* monitory — pełne karty */
.monitor__head { display: flex; align-items: center; gap: 10px; }
.monitor__name { font-family: var(--font-head); font-weight: 700; font-size: 16px; }
.monitor__head .status { margin-left: auto; }
.monitor__grid { display: flex; flex-wrap: wrap; gap: 18px 26px; margin-top: 14px; }
.monitor__k { font-size: 12px; color: var(--muted); }
.monitor__v { font-family: var(--font-head); font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; }
.monitor__detail { font-size: 12.5px; color: var(--muted); margin-top: 12px; border-top: 1px solid var(--border-soft); padding-top: 10px; }

/* feed / aktywność */
.feed { list-style: none; margin: 0; padding: 0; }
.feed__item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
.feed__item:last-child { border-bottom: 0; }
.feed__time { color: var(--muted-2); font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.feed__op { font-weight: 600; }
.feed__text { color: var(--ink-2); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed__item .status { margin-left: auto; }

/* ---------------------------------------------------- status pills ----- */
.status {
    display: inline-block; border-radius: 999px; font-size: 11.5px; font-weight: 700;
    padding: 3px 9px; white-space: nowrap;
}
.status--ok { background: var(--ok-bg); color: var(--ok-fg); }
.status--degraded { background: var(--degraded-bg); color: var(--degraded-fg); }
.status--down { background: var(--down-bg); color: var(--down-fg); }
.status--skipped { background: var(--skipped-bg); color: var(--skipped-fg); }

.dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; display: inline-block; background: var(--dot-skipped); }
.dot--ok { background: var(--dot-ok); }
.dot--down { background: var(--dot-down); }
.dot--degraded { background: var(--dot-degraded); }
.dot--live { background: var(--dot-ok); animation: pulseDot 1.8s infinite; }
.dot--glow.dot--ok { box-shadow: 0 0 0 5px rgba(63, 206, 133, .18); }
.dot--glow.dot--degraded { box-shadow: 0 0 0 5px rgba(244, 179, 30, .18); }
.dot--glow.dot--down { box-shadow: 0 0 0 5px rgba(226, 61, 61, .18); }
.dot--glow { width: 12px; height: 12px; }

/* ---------------------------------------------------- toolbar / chips -- */
.toolbar { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.search {
    display: flex; align-items: center; gap: 8px; background: var(--surface);
    border: 1px solid var(--border); border-radius: 10px; padding: 9px 14px;
}
.search__icon { color: var(--muted-2); }
.search__input { border: 0; background: transparent; font: inherit; width: 100%; color: var(--ink); }
.search__input:focus { outline: none; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
    border: 1px solid var(--border); cursor: pointer; font-family: var(--font-body);
    font-size: 13px; font-weight: 600; padding: 8px 14px; min-height: 40px;
    border-radius: 999px; background: var(--surface); color: var(--muted);
}
.chip.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------------------------------------------------- buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    border: 0; cursor: pointer; font-family: var(--font-body); font-weight: 600;
    font-size: 13.5px; padding: 11px 16px; min-height: 44px; border-radius: var(--radius-xs);
}
.btn--primary { background: var(--accent); color: var(--ink); font-weight: 700; }
.btn--dark { background: var(--ink); color: #fff; }
.btn--dark:hover { color: #fff; opacity: .92; }
.btn--block { width: 100%; }

.note { font-size: 13px; color: var(--muted); margin: 0 0 10px; }
.note--warn { color: var(--ink-2); background: var(--degraded-bg); border-radius: var(--radius-sm); padding: 12px 14px; }
.note b { color: var(--ink); }

/* ---------------------------------------------------- tables ----------- */
.table-card { padding: 0; overflow: hidden; }
.table-card .card__head { margin: 0; }
.table-wrap { width: 100%; overflow-x: auto; }
.table { border-collapse: collapse; width: 100%; font-size: 13px; }
.table thead tr { background: var(--surface-alt); color: var(--muted); text-align: left; }
.table th { padding: 10px 14px; font-weight: 600; font-size: 12px; white-space: nowrap; }
.table td { padding: 11px 14px; border-top: 1px solid var(--border-soft); vertical-align: top; }
.table .strong { font-weight: 600; }
.table .muted { color: var(--muted); }
.table .num { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.table .nowrap { white-space: nowrap; }
.table .detail { color: var(--ink-2); max-width: 360px; overflow-wrap: anywhere; }
.table-foot { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; border-top: 1px solid var(--border-soft); font-size: 12.5px; color: var(--muted); }

/* empty states */
.empty { color: var(--muted); font-size: 13px; padding: 14px 0; }
.empty--big { display: flex; align-items: center; gap: 12px; padding: 8px 0; color: var(--ink-2); font-size: 14px; }
.empty__icon {
    width: 34px; height: 34px; border-radius: 50%; background: var(--ok-bg); color: var(--ok-fg);
    display: flex; align-items: center; justify-content: center; font-weight: 800; flex: 0 0 auto;
}

/* =========================================================================
   LOGOWANIE
   ========================================================================= */
.login-page { display: flex; min-height: 100vh; }
.login { display: flex; align-items: center; justify-content: center; width: 100%; padding: 24px 16px; }
.login__card {
    width: 100%; max-width: 380px; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius); padding: 28px 24px;
}
.login__brand { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.login__logo {
    width: 44px; height: 44px; border-radius: 12px; background: var(--ink);
    display: flex; align-items: center; justify-content: center; font-size: 24px;
}
.login__title { font-family: var(--font-head); font-weight: 800; font-size: 18px; }
.login__title span { color: var(--accent); }
.login__lead { color: var(--muted); font-size: 13.5px; margin: 0 0 18px; }
.login__error {
    background: var(--down-bg); color: var(--down-fg); font-size: 13px; font-weight: 600;
    border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 14px;
}
.login__form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field__input {
    font: inherit; padding: 11px 13px; min-height: 44px; border: 1px solid var(--border);
    border-radius: var(--radius-xs); background: var(--surface-alt); color: var(--ink);
}
.field__input:focus { outline: none; border-color: var(--link); background: #fff; }
.login__form .btn { margin-top: 4px; }
.login__hint { font-size: 12px; color: var(--muted-2); margin: 16px 0 0; text-align: center; }

/* =========================================================================
   BREAKPOINTY (min-width, mobile-first)
   ========================================================================= */

/* sm ≥ 640px — KPI 2 kolumny, pasek zakładek w linii */
@media (min-width: 640px) {
    .topbar { padding: 14px 24px; gap: 14px 22px; }
    .tabs { order: 0; width: auto; }
    .grid--kpi { grid-template-columns: 1fr 1fr; }
    .page-head { flex-direction: row; align-items: flex-end; justify-content: space-between; }
    .page-head h1 { font-size: 24px; }
    .toolbar { flex-direction: row; align-items: center; }
    .search { flex: 1; max-width: 420px; }
    .chips { margin-left: auto; }
}

/* md ≥ 900px — monitoring i sekcje przeglądu obok siebie */
@media (min-width: 900px) {
    .wrap { padding: 24px 24px 72px; }
    .grid--kpi { grid-template-columns: repeat(3, 1fr); }
    .grid--two { grid-template-columns: 1fr 1fr; }
    .grid--monitors { grid-template-columns: repeat(2, 1fr); }
}

/* lg ≥ 1200px — pełny układ desktop */
@media (min-width: 1200px) {
    .wrap { padding: 28px 32px 80px; }
    .page-head h1 { font-size: 26px; }
    .grid--overview { grid-template-columns: 320px 1fr; align-items: stretch; }
    .grid--overview .grid--kpi { grid-template-columns: repeat(3, 1fr); margin-bottom: 0; }
    .grid--monitors { grid-template-columns: repeat(4, 1fr); }
    .grid--kpi-3 { grid-template-columns: repeat(3, 1fr); }
    .kpi__value { font-size: 30px; }
}

/* =========================================================================
   TABELE → KARTY na wąskim ekranie (< 720px)
   ========================================================================= */
@media (max-width: 719px) {
    .table--cards, .table--cards thead, .table--cards tbody,
    .table--cards th, .table--cards td, .table--cards tr { display: block; }
    .table--cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .table--cards tr { border: 1px solid var(--border); border-radius: var(--radius-sm); margin: 12px; padding: 6px 4px; }
    .table--cards td { border: 0; display: flex; gap: 12px; padding: 7px 12px; align-items: baseline; }
    .table--cards td::before {
        content: attr(data-label); flex: 0 0 42%; color: var(--muted);
        font-size: 12px; font-weight: 600;
    }
    .table--cards td.detail { flex-direction: column; gap: 3px; }
    .table--cards td.detail::before { flex-basis: auto; }
    .table-wrap { overflow-x: visible; }
}

/* =========================================================================
   DOSTĘPNOŚĆ — reduced motion
   ========================================================================= */
@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}
