:root {
  --ocean-deep: #06233f;
  --ocean: #0a3a63;
  --sky: #bfe3f5;
  --glass: rgba(14, 30, 52, 0.55);
  --glass-hi: rgba(22, 44, 74, 0.62);
  --border: rgba(126, 176, 224, 0.22);
  --border-hi: rgba(126, 200, 240, 0.5);
  --text: #eaf3fb;
  --muted: #a7bcd6;
  --accent: #5eb0ef;
  --accent-2: #7ee0c3;
  --warn: #f6c177;
  --danger: #f2857f;
  --radius: 16px;
  --sidebar-w: 216px;
  --shadow: 0 8px 30px rgba(0, 12, 28, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { min-height: 100%; }

body {
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  background: linear-gradient(180deg, #1a4e77 0%, #0d3a5f 42%, #06233f 100%);
  overflow-x: hidden;
}

/* ---------- Water & air background ---------- */
.bg { position: fixed; inset: 0; z-index: -2; overflow: hidden; }
.bg .sky {
  position: absolute; inset: 0;
  background:
    radial-gradient(1100px 520px at 78% -12%, rgba(190, 227, 245, 0.30) 0%, transparent 60%),
    radial-gradient(900px 480px at 12% -6%, rgba(126, 224, 195, 0.12) 0%, transparent 55%);
}
.bg .waves { position: absolute; left: 0; right: 0; bottom: 0; height: 60vh; min-height: 340px; }
.bg .waves svg { width: 220%; height: 100%; display: block; }
.wave-band { animation: drift linear infinite; transform-origin: center; }
.wave-1 { animation-duration: 34s; opacity: 0.5; }
.wave-2 { animation-duration: 48s; opacity: 0.38; animation-direction: reverse; }
.wave-3 { animation-duration: 66s; opacity: 0.26; }
@keyframes drift { from { transform: translateX(0); } to { transform: translateX(-45%); } }

.bubbles { position: absolute; inset: 0; }
.bubble {
  position: absolute; bottom: -40px; border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, rgba(255,255,255,0.55), rgba(160,220,250,0.06) 60%, transparent 70%);
  animation: rise linear infinite;
}
@keyframes rise {
  0% { transform: translateY(0) translateX(0); opacity: 0; }
  10% { opacity: 0.7; }
  90% { opacity: 0.5; }
  100% { transform: translateY(-102vh) translateX(30px); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .wave-band, .bubble { animation: none; }
}

/* ---------- App frame ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

/* Sidebar */
.side {
  position: sticky; top: 0; align-self: start; height: 100vh;
  display: flex; flex-direction: column; gap: 0.4rem;
  padding: 1.1rem 0.8rem; background: var(--glass);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 0.55rem; padding: 0.4rem 0.6rem 1rem; }
.brand .mark { font-size: 1.5rem; }
.brand .name { font-weight: 700; letter-spacing: -0.01em; font-size: 1.05rem; }
.nav-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); padding: 0.6rem 0.7rem 0.25rem; }
.nav-item {
  display: flex; align-items: center; gap: 0.7rem; padding: 0.55rem 0.7rem;
  border-radius: 10px; color: var(--text); text-decoration: none; font-size: 0.92rem;
  border: 1px solid transparent; transition: background 0.14s, border-color 0.14s;
}
.nav-item:hover { background: var(--glass-hi); border-color: var(--border); }
.nav-item.active { background: rgba(94, 176, 239, 0.16); border-color: var(--border-hi); }
.nav-item .ico { width: 1.3rem; text-align: center; font-size: 1.05rem; }
.nav-item.ext .name::after { content: "↗"; color: var(--muted); font-size: 0.75rem; margin-left: 0.3rem; }
.side .spacer { flex: 1; }

/* Header */
.main { display: flex; flex-direction: column; min-width: 0; }
.head {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.9rem 1.6rem; background: var(--glass);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.head .page-title { font-size: 1.15rem; font-weight: 600; }
.head .page-title small { display: block; color: var(--muted); font-size: 0.8rem; font-weight: 400; }
.head-right { display: flex; align-items: center; gap: 1.2rem; }
.status-row { display: flex; gap: 0.85rem; }
.dot-item { color: var(--muted); font-size: 0.8rem; text-decoration: none; display: inline-flex; align-items: center; gap: 0.35rem; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: #556; }
.dot.up { background: var(--accent-2); box-shadow: 0 0 7px var(--accent-2); }
.dot.down { background: var(--danger); box-shadow: 0 0 7px var(--danger); }

.content { padding: 1.6rem; }

/* ---------- Widget grid ---------- */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.1rem; }
.wfull { grid-column: 1 / -1; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }

.widget {
  background: var(--glass); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  display: flex; flex-direction: column; overflow: hidden;
}
.widget-head { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; padding: 0.9rem 1.1rem 0.6rem; }
.widget-head h2 { font-size: 0.95rem; font-weight: 600; display: flex; align-items: center; gap: 0.5rem; }
.widget-head .wico { font-size: 1.05rem; }
.widget-head .meta { color: var(--muted); font-size: 0.75rem; }
.widget-head a.more { color: var(--accent); font-size: 0.78rem; text-decoration: none; }
.widget-head a.more:hover { text-decoration: underline; }
.widget-body { padding: 0.3rem 1.1rem 1rem; overflow: auto; }

/* rows */
.row { display: flex; align-items: baseline; gap: 0.7rem; padding: 0.5rem 0.1rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.row:last-child { border-bottom: none; }
.row .time, .row .date { color: var(--accent); font-variant-numeric: tabular-nums; white-space: nowrap; }
.row .date { min-width: 6.8em; }
.row.overdue .date { color: var(--danger); font-weight: 600; }
.row .title { flex: 1; min-width: 0; }
.row .title a { color: var(--text); text-decoration: none; }
.row .title a:hover { text-decoration: underline; }
.dl-check {
  appearance: none; -webkit-appearance: none;
  width: 17px; height: 17px; flex: none; margin: 0 0.15rem 0 0;
  border: 1.5px solid var(--muted); border-radius: 5px;
  background: rgba(6, 20, 36, 0.5); cursor: pointer;
  transition: border-color 0.14s, background 0.14s;
  position: relative; top: 3px;
}
.dl-check:hover { border-color: var(--accent-2); }
.dl-check:checked { background: var(--accent-2); border-color: var(--accent-2); }
.dl-check:checked::after {
  content: "✓"; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #05233f; font-size: 12px; font-weight: 700;
}
.dl-check:disabled { cursor: default; opacity: 0.7; }
/* .todo rows are centre-aligned, so drop the baseline nudge there */
.todo .dl-check { top: 0; }

.pill { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 0.05rem 0.55rem; white-space: nowrap; }
.pill.p-high, .pill.p-urgent { color: var(--danger); border-color: rgba(242,133,127,0.5); }
.pill.p-normal { color: var(--accent); border-color: rgba(94,176,239,0.4); }
.chip { font-size: 0.7rem; border-radius: 999px; padding: 0.08rem 0.6rem; white-space: nowrap; }
.chip.active { background: rgba(126,224,195,0.16); color: var(--accent-2); }
.chip.waiting { background: rgba(246,193,119,0.16); color: var(--warn); }
.chip.done { background: rgba(167,188,214,0.16); color: var(--muted); }
.empty { color: var(--muted); font-size: 0.86rem; padding: 0.8rem 0.1rem; }

/* todo checkbox */
.todo { display: flex; align-items: center; gap: 0.6rem; padding: 0.45rem 0.1rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.todo:last-child { border-bottom: none; }
.todo .box { width: 16px; height: 16px; border-radius: 5px; border: 1.5px solid var(--muted); flex: none; }
.todo .t { flex: 1; }
.todo .t a { color: var(--text); text-decoration: none; }
.todo .src { font-size: 0.68rem; color: var(--muted); }

/* n8n workflow health rows */
.wf { display: flex; align-items: center; gap: 0.65rem; padding: 0.5rem 0.1rem; border-bottom: 1px solid var(--border); }
.wf:last-child { border-bottom: none; }
.wf .dot { flex: none; }
.wf-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.wf-name { color: var(--text); text-decoration: none; font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wf-name:hover { color: var(--accent); }
.wf-sub { color: var(--muted); font-size: 0.73rem; }
.wf-stat { color: var(--muted); font-size: 0.75rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
#n8n-body { max-height: 320px; }

/* status tiles (n8n / rss) */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 0.6rem; }
.tile { background: var(--glass-hi); border: 1px solid var(--border); border-radius: 12px; padding: 0.7rem 0.85rem; }
.tile .k { color: var(--muted); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; }
.tile .v { font-size: 1.25rem; font-weight: 700; margin-top: 0.15rem; }
.tile .v.ok { color: var(--accent-2); }
.tile .v.bad { color: var(--danger); }
.tile .s { color: var(--muted); font-size: 0.76rem; }

/* capture box */
.capture { display: flex; gap: 0.5rem; }
.capture input { flex: 1; background: rgba(6,20,36,0.6); border: 1px solid var(--border); border-radius: 10px; padding: 0.55rem 0.8rem; color: var(--text); font-size: 0.9rem; }
.capture input:focus { outline: none; border-color: var(--accent); }

/* week strip */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.5rem; }
.day { background: var(--glass-hi); border: 1px solid var(--border); border-radius: 12px; padding: 0.6rem 0.5rem; min-height: 92px; }
.day.today { border-color: var(--border-hi); box-shadow: inset 0 0 0 1px rgba(94,176,239,0.3); }
.day .dname { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; }
.day .dnum { font-size: 1.05rem; font-weight: 700; }
.day .ev { font-size: 0.68rem; color: var(--accent); margin-top: 0.25rem; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day .ev.dl { color: var(--warn); }

/* buttons / forms */
button { background: var(--accent); color: #05233f; border: none; border-radius: 9px; padding: 0.5rem 1rem; font-size: 0.9rem; font-weight: 600; cursor: pointer; }
button:hover { filter: brightness(1.08); }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); font-weight: 500; }
button.ghost:hover { color: var(--text); border-color: var(--muted); filter: none; }
button.sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }

/* projects full page table */
.ptable { width: 100%; border-collapse: collapse; }
.ptable th { text-align: left; color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); }
.ptable td { padding: 0.6rem 0.6rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; vertical-align: middle; }
.ptable tr:hover td { background: rgba(22,44,74,0.35); }
.ptable input, .ptable select { background: rgba(6,20,36,0.6); border: 1px solid var(--border); border-radius: 8px; padding: 0.4rem 0.55rem; color: var(--text); font-size: 0.88rem; width: 100%; }
.ptable input:focus, .ptable select:focus { outline: none; border-color: var(--accent); }
.linkbtn { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 0.85rem; padding: 0.2rem; }

/* login (kept) */
.login-box { max-width: 340px; margin: 20vh auto 0; background: var(--glass); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; text-align: center; backdrop-filter: blur(14px); box-shadow: var(--shadow); }
.login-box h1 { font-size: 1.5rem; }
.login-box .sub { color: var(--muted); margin-bottom: 1.4rem; }
.login-box form { display: flex; flex-direction: column; gap: 0.8rem; }
.login-box input { background: rgba(6,20,36,0.6); border: 1px solid var(--border); border-radius: 8px; padding: 0.6rem 0.9rem; color: var(--text); font-size: 1rem; }
.login-box input:focus { outline: none; border-color: var(--accent); }
.error { color: var(--danger); font-size: 0.9rem; margin-top: 0.9rem; min-height: 1.2em; }

/* responsive: collapse sidebar to icons */
@media (max-width: 720px) {
  :root { --sidebar-w: 60px; }
  .brand .name, .nav-item .name, .nav-label { display: none; }
  .nav-item { justify-content: center; }
  .content { padding: 1rem; }
  .head { padding: 0.8rem 1rem; }
  .status-row .dot-item span:not(.dot) { display: none; }
}
