/* #133: the Grid view's look (dashboards-src/grid-outages.yaml): HA default theme colours for light
   and dark, 24px cards, pill chips, 18px tiles. Type colours: short amber, medium orange, long red,
   partial purple, online green; the partial-outage hero is amber. */
:root {
  --bg: #fafafa;
  --card: #ffffff;
  --text: #212121;
  --text2: #727272;
  --text3: #9e9e9e;
  --soft: #eeeeee;
  --divider: rgba(0, 0, 0, 0.12);
  --shadow: rgba(0, 0, 0, 0.18);
  --short: rgb(242, 169, 0);
  --medium: rgb(239, 108, 0);
  --long: rgb(219, 68, 55);
  --partial: rgb(156, 39, 176);
  --ok: rgb(67, 160, 71);
  --blue: rgb(74, 120, 208);
  --amber: rgb(242, 169, 0);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111111; --card: #1c1c1c; --text: #e1e1e1; --text2: #9b9b9b; --text3: #6f6f6f;
    --soft: #282828; --divider: rgba(225, 225, 225, 0.12); --shadow: rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111111; --card: #1c1c1c; --text: #e1e1e1; --text2: #9b9b9b; --text3: #6f6f6f;
  --soft: #282828; --divider: rgba(225, 225, 225, 0.12); --shadow: rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.4 Roboto, system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
button, input, select { font: inherit; color: inherit; }
.i { display: inline-block; flex: none; vertical-align: middle; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 12px 16px 32px; }
header.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0 12px; }
header.top h1 { margin: 0; font-size: 20px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.flags { display: flex; gap: 6px; }
.flag {
  border: 0; background: var(--card); border-radius: 999px; padding: 4px 10px; font-size: 20px; line-height: 1.2;
  cursor: pointer; opacity: 0.55; box-shadow: 0 0 0 1px var(--divider);
}
.flag[aria-pressed="true"] { opacity: 1; box-shadow: 0 0 0 2px var(--blue); }

/* Two columns from tablet width: hero + notify + numbers left, the rest right. */
.cols { display: grid; gap: 12px; grid-template-columns: 1fr; }
.col { display: grid; gap: 12px; align-content: start; min-width: 0; }
@media (min-width: 900px) { .cols { grid-template-columns: 1fr 1fr; } }

.card { background: var(--card); border-radius: 24px; padding: 20px; min-width: 0; border: 1px solid transparent; }
.title { font-size: 19px; font-weight: 600; }
.sub { font-size: 14px; color: var(--text2); margin-top: 2px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  background: var(--soft); font-size: 14px; white-space: nowrap;
}
.type {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap;
  color: var(--c); background: color-mix(in srgb, var(--c) 16%, transparent);
}

/* Hero */
.hero { --c: var(--ok); }
.hero.bad { background: color-mix(in srgb, var(--c) 10%, var(--card)); border-color: color-mix(in srgb, var(--c) 45%, transparent); }
.hero .row { display: grid; grid-template-columns: auto 1fr; column-gap: 16px; align-items: center; }
.hero .dot {
  width: 64px; height: 64px; border-radius: 50%; background: var(--c); display: flex; align-items: center; justify-content: center;
}
.hero.idle .dot { background: var(--soft); }
.hero.bad .dot { animation: pulse 1.8s ease-out infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--c) 55%, transparent); }
  70% { box-shadow: 0 0 0 16px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@media (prefers-reduced-motion: reduce) { .hero.bad .dot { animation: none; } }
.hero .head { font-size: 26px; font-weight: 700; line-height: 1.2; color: var(--c); font-variant-numeric: tabular-nums; }
.hero.idle .head { color: var(--text); }
.hero .note { font-size: 15px; margin-top: 4px; color: var(--text2); }
.hero .erm { margin-top: 14px; padding: 12px 14px; border-radius: 18px; background: var(--soft); }
.hero .erm .big { font-size: 22px; font-weight: 700; line-height: 1.25; font-variant-numeric: tabular-nums; }
.hero .erm .small { font-size: 14px; color: var(--text2); margin-top: 3px; }
.hero .chips { margin-top: 16px; }
.line { display: flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 600; margin-top: 8px; }
.stale { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 14px; color: var(--medium); font-weight: 600; }
.banner {
  display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-radius: 18px; font-weight: 600;
  color: var(--blue); background: color-mix(in srgb, var(--blue) 12%, var(--card));
  border: 1px solid color-mix(in srgb, var(--blue) 40%, transparent);
}
.banner .sub { font-weight: 400; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 999px;
  padding: 10px 18px; font-weight: 600; cursor: pointer; background: var(--blue); color: #fff; min-height: 44px;
}
.btn.ghost { background: var(--soft); color: var(--text); }
.btn.out { background: var(--long); }
.btn.backbtn { background: var(--ok); }
.btn.sel { box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 60%, transparent); }
.btn[disabled] { opacity: 0.5; cursor: default; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; align-items: center; }
.hint { font-size: 14px; color: var(--text2); margin-top: 10px; }
.hint.warn { color: var(--medium); }
select, input[type="text"], input[type="password"] {
  background: var(--soft); border: 1px solid var(--divider); border-radius: 12px; padding: 10px 12px; min-height: 44px; max-width: 100%;
}

/* Tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.tile { padding: 14px 16px; border-radius: 18px; background: var(--soft); min-width: 0; }
.tile .lbl { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text2); }
.tile .val { font-size: 24px; font-weight: 700; margin-top: 6px; line-height: 1.15; overflow-wrap: anywhere; }
.tile .nt { font-size: 12px; color: var(--text2); margin-top: 2px; }

/* Table */
table.stats { width: 100%; border-collapse: collapse; margin-top: 8px; }
table.stats th { text-align: right; font-weight: 500; font-size: 13px; color: var(--text2); padding: 0 0 8px 8px; }
table.stats td { text-align: right; padding: 10px 0 10px 8px; font-size: 17px; font-weight: 500; border-top: 1px solid var(--divider); }
table.stats td:first-child { text-align: left; padding-left: 0; white-space: nowrap; font-size: 16px; }
table.stats td.zero { color: var(--text3); }
table.stats .rng { font-size: 13px; color: var(--text2); margin-left: 6px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; background: var(--c); }
@media (max-width: 380px) { table.stats .rng { display: none; } }

/* Lists */
.list { margin: 10px 0 -10px; }
.item { display: grid; grid-template-columns: 1fr auto auto; align-items: center; column-gap: 12px; padding: 10px 0; border-top: 1px solid var(--divider); }
.item .when { font-size: 16px; font-weight: 500; }
.item .meta { font-size: 13px; color: var(--text2); margin-top: 2px; }
.item .dur { font-size: 16px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Calendar */
.week, .cells { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; justify-items: center; }
.week { margin-top: 14px; font-size: 12px; color: var(--text2); }
.cells { margin-top: 4px; }
.cell {
  width: 36px; height: 36px; border-radius: 10px; border: 0; padding: 0; position: relative; display: flex; align-items: center;
  justify-content: center; font-size: 13px; background: color-mix(in srgb, var(--ok) 35%, transparent); color: var(--text); cursor: pointer;
}
.cell.hit { color: #fff; font-weight: 700; }
.cell.today { box-shadow: 0 0 0 1px var(--text2); }
.cell.sel { box-shadow: 0 0 0 2px var(--text); }
.cell.blank { background: none; cursor: default; }
.cell .pdot { position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; border-radius: 50%; background: var(--partial); box-shadow: 0 0 0 1.5px #fff; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--text2); margin-top: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; background: var(--c); display: inline-block; }
.detail { margin-top: 14px; padding: 14px 16px; border-radius: 18px; background: var(--soft); }
.detail .item { grid-template-columns: 1fr auto auto; padding: 8px 0; }

/* Timeline */
.tl-row { display: grid; grid-template-columns: 58px 1fr; align-items: center; column-gap: 10px; margin-top: 8px; }
.tl-lbl { font-size: 13px; color: var(--text2); }
.tl-bar { position: relative; height: 18px; border-radius: 5px; background: color-mix(in srgb, var(--ok) 55%, transparent); }
.tl-future { position: absolute; top: 0; bottom: 0; right: 0; background: var(--soft); border-radius: 0 5px 5px 0; }
.mark { position: absolute; top: 0; bottom: 0; border-radius: 2px; outline: none; cursor: pointer; min-width: 2px; background: var(--c); }
.mark::before { content: ''; position: absolute; top: -6px; bottom: -6px; left: 50%; width: max(100%, 22px); transform: translateX(-50%); }
.tip {
  display: none; position: absolute; z-index: 5; white-space: nowrap; padding: 6px 10px; border-radius: 10px; font-size: 13px; font-weight: 500;
  color: var(--text); background: var(--card); border: 1px solid var(--divider); box-shadow: 0 2px 8px var(--shadow); pointer-events: none;
}
.mark .tip { bottom: calc(100% + 8px); }
.mark:hover, .mark:focus { z-index: 6; box-shadow: 0 0 0 2px var(--text); }
.mark:hover .tip, .mark:focus .tip { display: block; }
.axis { display: grid; grid-template-columns: 58px 1fr; column-gap: 10px; margin-top: 4px; }
.axis div:last-child { display: flex; justify-content: space-between; font-size: 11px; color: var(--text2); }

/* Hour chart */
.hours-head { display: grid; grid-template-columns: 1fr auto; column-gap: 10px; align-items: start; }
.toggle { display: inline-flex; background: var(--soft); border-radius: 999px; padding: 3px; }
.toggle button { border: 0; background: none; border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 600; color: var(--text2); cursor: pointer; }
.toggle button[aria-pressed="true"] { background: var(--blue); color: #fff; }
.bars { position: relative; display: grid; grid-template-columns: repeat(24, 1fr); gap: 3px; height: 130px; margin-top: 14px; }
.bar { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; outline: none; cursor: pointer; }
.bar .n { font-size: 10px; text-align: center; color: var(--text2); }
.stack { display: flex; flex-direction: column-reverse; border-radius: 3px 3px 0 0; overflow: hidden; }
.stack div { min-height: 2px; background: var(--c); }
.bar .empty { height: 2px; background: var(--divider); }
.bar .tip { top: 0; min-width: 200px; max-width: 75%; white-space: nowrap; font-size: 12px; line-height: 1.5; font-weight: 400; }
.bar:hover .tip, .bar:focus .tip { display: block; }
.bar:hover .stack, .bar:focus .stack { box-shadow: 0 0 0 2px var(--text); }
.haxis { display: grid; grid-template-columns: repeat(24, 1fr); gap: 3px; margin-top: 4px; font-size: 11px; color: var(--text2); text-align: center; }

/* Votes */
.votes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.votes .btn { width: 100%; white-space: normal; text-align: center; line-height: 1.2; }
.street-list { margin-top: 10px; }
.street-list .item { grid-template-columns: 1fr auto auto; padding: 6px 0; font-size: 14px; }

/* Recently here */
.here { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.nick-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.nick-form label { width: 100%; font-size: 13px; color: var(--text2); }
.nick-form input { flex: 1 1 160px; }

/* Login */
.login { max-width: 380px; margin: 8vh auto 0; }
.login form { display: grid; gap: 12px; margin-top: 16px; }
.login label { display: grid; gap: 4px; font-size: 13px; color: var(--text2); }
.err { color: var(--long); font-size: 14px; min-height: 1.2em; }

footer { margin-top: 18px; font-size: 13px; color: var(--text2); display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; }
footer button { border: 0; background: none; color: var(--blue); cursor: pointer; padding: 6px 0; display: inline-flex; gap: 6px; align-items: center; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
