:root {
  color-scheme: light dark;
  --bg: #f3f4f7;
  --surface: #ffffff;
  --surface-2: #f6f7fa;
  --fg: #151922;
  --muted: #697386;
  --border: #e3e6ec;
  --accent: #4f5bd5;
  --accent-soft: rgb(79 91 213 / .1);
  --good: #18865a;
  --bad: #cf3a3a;
  --warn: #b7791f;
  --shadow: 0 1px 2px rgb(16 24 40 / .04), 0 1px 3px rgb(16 24 40 / .06);
  --radius: 14px;
  font: 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01";
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0f14;
    --surface: #141920;
    --surface-2: #1a2029;
    --fg: #e7eaf0;
    --muted: #8a94a6;
    --border: #232a35;
    --accent: #8b97ff;
    --accent-soft: rgb(139 151 255 / .12);
    --good: #3ccf8e;
    --bad: #f07272;
    --warn: #e9b04a;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); min-height: 100vh; }
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; font-weight: 650; letter-spacing: -.01em; margin: 0; }
h2 { font-size: 15px; margin: 0; }
h3 { font-size: 14px; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--bad); margin: 0; }

button { font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--fg); padding: 6px 12px; }
button:hover { border-color: var(--muted); }
button:disabled { opacity: .6; cursor: progress; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; padding: 8px 16px; font-weight: 550; }
button.danger { color: var(--bad); }
button.link { border: none; background: none; color: var(--accent); padding: 0; }
.icon-button { padding: 0 9px; height: 26px; line-height: 1; font-size: 16px; }
input, select, textarea { font: inherit; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--fg); min-width: 0; }
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type=color] { padding: 2px; height: 34px; width: 60px; }
label { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 13px; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--fg); }

/* Top bar --------------------------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 28px; padding: 10px 28px;
  background: color-mix(in srgb, var(--surface) 85%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 15px; }
.logo { width: 24px; height: 24px; display: inline-block; background: url(/static/favicon.svg) center / contain no-repeat; }
.logo.big { width: 44px; height: 44px; }
nav { display: flex; gap: 2px; flex: 1; }
.tab { border: none; background: none; color: var(--muted); padding: 6px 12px; }
.tab.active { color: var(--fg); background: var(--surface-2); }
#account { margin-left: auto; display: flex; gap: 14px; align-items: center; color: var(--muted); }

main { padding: 28px; max-width: 1560px; margin: 0 auto; }
#message { padding: 10px 14px; border-radius: 10px; border: 1px solid var(--bad); color: var(--bad); background: var(--surface); margin: 0 0 18px; }
#message.ok { border-color: var(--good); color: var(--good); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.narrow { max-width: 420px; margin: 9vh auto; display: flex; flex-direction: column; gap: 14px; padding: 32px; }
.narrow h2 { font-size: 20px; }
.narrow p { margin: 0; }

/* Home ------------------------------------------------------------------------ */

.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 22px; flex-wrap: wrap; }
.hero p { margin: 4px 0 0; }
.hero-right { display: flex; align-items: center; gap: 18px; }
#search { width: min(340px, 60vw); padding: 9px 14px; border-radius: 10px; background: var(--surface); }
.clock { font-size: 30px; font-weight: 300; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

.columns { display: grid; gap: 18px; grid-template-columns: minmax(270px, 330px) minmax(0, 1fr) minmax(270px, 330px); grid-template-areas: "left main right"; align-items: start; }
.col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.col-left { grid-area: left; }
.col-main { grid-area: main; }
.col-right { grid-area: right; }
@media (max-width: 1200px) {
  .columns { grid-template-columns: 1fr 1fr; grid-template-areas: "main main" "left right"; }
}
@media (max-width: 760px) {
  main { padding: 16px; }
  .topbar { padding: 10px 16px; gap: 12px; }
  .columns { grid-template-columns: 1fr; grid-template-areas: "main" "left" "right"; }
  .clock { display: none; }
  #user, .brand #site-title { display: none; }
  .tab { padding: 6px 8px; }
  .hero h1 { font-size: 22px; }
  #search { width: 100%; }
  .hero-right { width: 100%; }
}

.widget { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.widget > h2, .widget-head h2 { font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.widget > h2 { margin-bottom: 14px; }
.widget-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.empty { color: var(--muted); font-size: 13px; margin: 0; }
.note { color: var(--muted); font-size: 12px; margin: 10px 0 0; }
.note.bad { color: var(--bad); }

/* Services */
.group + .group { margin-top: 18px; }
.group h3 { font-size: 13px; font-weight: 600; margin: 0 0 10px; color: var(--fg); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.tile {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid transparent; color: var(--fg); transition: border-color .12s, transform .12s;
}
.tile:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); }
.tile:focus-visible { outline: 2px solid var(--accent); }
.tile-text { display: flex; flex-direction: column; min-width: 0; }
.tile-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-desc { color: var(--muted); font-size: 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile-icon {
  flex: none; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; overflow: hidden;
  background: hsl(var(--hue, 230) 70% 55% / .16); color: hsl(var(--hue, 230) 65% 50%); font-weight: 700; font-size: 17px;
}
/* Site icons are drawn for light backgrounds (GitHub's is black): keep them on white in both themes. */
.tile-icon.image { background: #fff; border: 1px solid var(--border); }
.tile-icon img { width: 26px; height: 26px; object-fit: contain; }
.tile-icon.small { width: 26px; height: 26px; border-radius: 7px; font-size: 12px; }
.tile-icon.small img { width: 18px; height: 18px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.up { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 20%, transparent); }
.dot.down { background: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 20%, transparent); }
.tile .dot { position: absolute; top: 10px; right: 10px; }
.tag { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border: 1px solid var(--border); border-radius: 5px; padding: 0 5px; margin-left: 6px; font-weight: 600; vertical-align: 1px; }

/* Pills */
.pills { display: flex; gap: 4px; flex-wrap: wrap; }
.pill { border: 1px solid transparent; background: none; color: var(--muted); padding: 3px 10px; border-radius: 999px; font-size: 12px; }
.pill:hover { color: var(--fg); border-color: transparent; }
.pill.active { background: var(--accent-soft); color: var(--accent); }

/* News */
.news-list { list-style: none; margin: 0; padding: 0; }
.news-list li { padding: 11px 0; border-top: 1px solid var(--border); }
.news-list li:first-child { border-top: none; padding-top: 0; }
.news-list a { color: var(--fg); font-weight: 550; }
.news-list a:hover { color: var(--accent); text-decoration: none; }
.news-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.news-meta .source { color: var(--accent); font-weight: 550; }
.news-summary { color: var(--muted); font-size: 13px; margin: 3px 0 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.more { margin-top: 12px; }

/* Weather */
.wx-now { display: flex; align-items: center; gap: 14px; }
.wx-icon { font-size: 44px; line-height: 1; }
.wx-temp { font-size: 40px; font-weight: 300; letter-spacing: -.03em; line-height: 1; }
.wx-desc { font-weight: 600; }
.wx-place { color: var(--muted); font-size: 12px; }
.wx-facts { display: flex; gap: 14px; color: var(--muted); font-size: 12px; margin: 12px 0 4px; flex-wrap: wrap; }
.wx-hours { width: 100%; height: auto; display: block; margin: 8px 0 4px; overflow: visible; }
.wx-hours .area { fill: var(--accent-soft); }
.wx-hours .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.wx-hours text { fill: var(--muted); font-size: 10px; }
.wx-hours .t { fill: var(--fg); font-size: 10px; font-weight: 600; }
.wx-days { display: grid; grid-template-columns: 34px 22px 32px 1fr 32px; gap: 6px 8px; align-items: center; font-size: 13px; margin-top: 10px; }
.wx-days .lo { color: var(--muted); text-align: right; }
.range { position: relative; height: 5px; border-radius: 3px; background: var(--surface-2); }
.range span { position: absolute; top: 0; bottom: 0; border-radius: 3px; background: linear-gradient(90deg, #4dabf7, #ffa94d); }

/* Calendar */
.month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; font-size: 12px; }
.month .wd { color: var(--muted); font-size: 11px; padding-bottom: 4px; }
.day { border: none; background: none; padding: 5px 0 7px; border-radius: 8px; position: relative; font-variant-numeric: tabular-nums; color: var(--fg); }
.day:hover { background: var(--surface-2); border-color: transparent; }
.day.other { color: var(--muted); opacity: .5; }
.day.today { background: var(--accent); color: #fff; font-weight: 650; }
.day.selected:not(.today) { outline: 1px solid var(--accent); }
.day .marks { position: absolute; left: 0; right: 0; bottom: 2px; display: flex; justify-content: center; gap: 2px; }
.day .marks i { width: 4px; height: 4px; border-radius: 50%; background: var(--c, var(--accent)); }
.day.today .marks i { background: #fff; }
#day-events { margin-top: 12px; }

/* Agenda */
.agenda-day + .agenda-day { margin-top: 14px; }
.agenda-day h4 { margin: 0 0 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
.event { display: grid; grid-template-columns: 4px 1fr; gap: 10px; padding: 4px 0; }
.event .bar { border-radius: 2px; background: var(--c, var(--accent)); }
.event-title { font-weight: 550; }
.event-meta { color: var(--muted); font-size: 12px; }

/* Markets */
.fx { display: grid; grid-template-columns: auto 1fr auto auto; gap: 10px 12px; align-items: center; font-variant-numeric: tabular-nums; }
.fx .pair { font-weight: 600; }
.fx .pair span { color: var(--muted); font-weight: 400; }
.fx .rate { text-align: right; }
.fx .chg { font-size: 12px; text-align: right; min-width: 52px; }
.fx .chg.up { color: var(--good); }
.fx .chg.down { color: var(--bad); }
.spark { width: 100%; max-width: 110px; height: 24px; }
.spark path { fill: none; stroke: var(--muted); stroke-width: 1.5; }
.spark.up path { stroke: var(--good); }
.spark.down path { stroke: var(--bad); }

/* Status */
.status-summary { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.status-summary strong { font-size: 24px; font-weight: 600; }
.status-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.status-list li { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.status-list .ms { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

/* Manage ------------------------------------------------------------------------ */

.manage-head { display: flex; align-items: center; gap: 24px; margin-bottom: 20px; flex-wrap: wrap; }
.panel { display: flex; flex-direction: column; gap: 18px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.panel-head p { margin: 0; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
tbody tr:last-child td { border-bottom: none; }
td.wrap { white-space: normal; overflow-wrap: anywhere; max-width: 420px; }
.actions { display: flex; gap: 6px; justify-content: flex-end; }
.actions button { padding: 3px 9px; font-size: 12px; }
.group-card { padding: 0; overflow: hidden; }
.group-card .panel-head { padding: 12px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.group-card .table-wrap { border: none; border-radius: 0; }
.group-card .empty { padding: 14px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; border: 1px solid currentColor; }
.badge.good { color: var(--good); }
.badge.bad { color: var(--bad); }
.badge.warn { color: var(--warn); }
.badge.muted { color: var(--muted); }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 4px; background: var(--c); vertical-align: -1px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row > label { flex: 1; min-width: 160px; }
.help { color: var(--muted); font-size: 12px; margin: 0; }
.invite-link { display: flex; gap: 8px; align-items: center; }
.invite-link input { flex: 1; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; }
.suggestions button { font-size: 12px; border-radius: 999px; }
.results { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.results li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 12px; background: var(--surface-2); border-radius: 8px; }

dialog { width: min(520px, 94vw); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--fg); padding: 22px; }
dialog::backdrop { background: rgb(0 0 0 / .5); }
dialog h2 { font-size: 17px; margin-bottom: 16px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
#dialog-error { margin-top: 12px; }
