/* solXpect web – looks like the solXpect app (colors from its res/values and res/values-night) */
:root {
  --primary: #024265;        /* toolbar, tabs */
  --on-primary: #ffffff;
  --accent: #0274b2;
  --card: #6fb1e2;           /* backgroundBlue */
  --card-text: #024265;      /* colorPrimaryDark */
  --card-line: #fafafa;      /* white */
  --highlight: #5fa1d2;      /* backgroundHighlight */
  --page: #fafafa;
  --text: #1d2730;
  --muted: #5b6b78;
  --surface: #ffffff;
  --field: #f1f4f7;
  --border: #c9d3dc;
  --danger: #d01530;
  --bar: #f8f49f;            /* yellow, chart bars */
  --credit: #fafafa;
  --scrim: rgba(0, 0, 0, .45);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #181818; --on-primary: #e6e6e6; --accent: #a0a0a0;
    --card: #080808; --card-text: #9a9a9a; --card-line: #303030; --highlight: #2a2a2a;
    --page: #000000; --text: #d6d6d6; --muted: #8a8a8a; --surface: #1c1c1c; --field: #262626;
    --border: #3a3a3a; --danger: #fa7972; --bar: #c9c58a; --credit: #8a8a8a; --scrim: rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --primary: #181818; --on-primary: #e6e6e6; --accent: #a0a0a0;
  --card: #080808; --card-text: #9a9a9a; --card-line: #303030; --highlight: #2a2a2a;
  --page: #000000; --text: #d6d6d6; --muted: #8a8a8a; --surface: #1c1c1c; --field: #262626;
  --border: #3a3a3a; --danger: #fa7972; --bar: #c9c58a; --credit: #8a8a8a; --scrim: rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 16px/1.4 Roboto, "Segoe UI", system-ui, -apple-system, "Noto Sans", sans-serif;
  background: var(--page); color: var(--text);
  min-height: 100vh; -webkit-tap-highlight-color: transparent;
}
svg { width: 24px; height: 24px; fill: currentColor; flex: none; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
h2 { font-size: 1rem; }
.small { font-size: .85rem; color: var(--muted); }
.error { color: var(--danger); font-size: .9rem; }

/* toolbar */
.toolbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 4px;
  min-height: 56px; padding: env(safe-area-inset-top) 4px 0; background: var(--primary); color: var(--on-primary);
}
.toolbar h1 { flex: 1; margin: 0 8px; font-size: 1.25rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.actions { display: flex; }
.icon-btn { display: grid; place-items: center; width: 48px; height: 48px; border: 0; border-radius: 50%; background: none; cursor: pointer; }
.icon-btn:active { background: rgba(255, 255, 255, .15); }
#sumBtn[aria-pressed="false"] svg { opacity: .3; }
#refreshBtn.spin svg { animation: spin .5s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.update-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 16px; background: var(--accent); color: #fff; }
.update-bar button { border: 1px solid #fff; border-radius: 4px; background: none; padding: 4px 12px; cursor: pointer; }

/* drawer */
.drawer {
  position: fixed; inset: 0 auto 0 0; z-index: 40; width: min(300px, 82vw); overflow-y: auto;
  background: var(--surface); transform: translateX(-105%); transition: transform .2s ease;
  padding-bottom: env(safe-area-inset-bottom); box-shadow: 2px 0 12px rgba(0, 0, 0, .25);
}
.drawer.open { transform: none; }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: calc(16px + env(safe-area-inset-top)) 16px 16px; background: var(--primary); color: var(--on-primary); }
.drawer-head img { border-radius: 12px; }
.drawer-head div { display: flex; flex-direction: column; }
.drawer-head span { font-size: .8rem; opacity: .8; }
.drawer a { display: flex; align-items: center; gap: 24px; padding: 12px 16px; color: var(--text); text-decoration: none; }
.drawer a.active { background: var(--field); color: var(--accent); font-weight: 500; }
.drawer a svg { color: var(--muted); }
.drawer a.active svg { color: var(--accent); }
.drawer hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); margin-left: auto; }
.scrim { position: fixed; inset: 0; z-index: 30; background: var(--scrim); }

main { max-width: 760px; margin: 0 auto; padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.page { padding: 0 8px; }

/* tabs */
.tabs {
  position: sticky; top: 56px; z-index: 10; display: flex; overflow-x: auto; scrollbar-width: none;
  margin: 0 -8px 8px; background: var(--primary); color: var(--on-primary);
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: 0 0 auto; min-width: 90px; max-width: 260px; padding: 12px 16px; border: 0; border-bottom: 2px solid transparent;
  background: none; color: inherit; opacity: .7; text-transform: uppercase; font-size: .875rem; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.tabs button[aria-selected="true"] { opacity: 1; border-bottom-color: currentColor; }
.empty { padding: 24px 16px; text-align: center; color: var(--muted); }

/* cards */
.card { margin: 8px 0; border-radius: 6px; background: var(--card); color: var(--card-text); overflow: hidden; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 8px 12px 6px; border-bottom: 1px solid var(--card-line); font-weight: 700; text-transform: uppercase; }
.card-head .unit { text-transform: none; border: 1px solid var(--card-line); border-radius: 6px; padding: 0 6px; }
.overview { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; padding: 10px 12px 12px; font-size: 1.1rem; }
.overview .val { text-align: right; font-weight: 500; }
.overview .meta { grid-column: 1 / -1; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; font-size: .85rem; }
.overview .credit { color: var(--credit); }
.stale { color: var(--danger); font-weight: 500; }
.hscroll { display: flex; overflow-x: auto; padding: 6px 4px 10px; scroll-snap-type: x proximity; overscroll-behavior-x: contain; }
.hour, .day { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; padding: 4px 8px; border-radius: 8px; scroll-snap-align: start; }
.hour { min-width: 78px; }
.hour .t, .day .d { font-size: 1.05rem; }
.hour img, .day img { width: 48px; height: 48px; margin: 2px 0 8px; }
.hour .p, .hour .c, .day .e { font-size: 1.05rem; white-space: nowrap; }
.hour .dbg { font-size: .8rem; white-space: nowrap; }
.day { min-width: 74px; cursor: pointer; border: 0; background: none; color: inherit; font: inherit; }
.day.current { background: var(--highlight); }
.chart { padding: 6px 8px 8px; }
.chart svg { width: 100%; height: 220px; display: block; }
.chart text { fill: currentColor; font-size: 13px; }
.chart .grid { stroke: var(--card-line); stroke-width: 1; opacity: .6; }
.chart .bar { fill: var(--bar); fill-opacity: .85; }
.chart .bar:hover, .chart .bar.sel { fill-opacity: 1; }
.chart-tip { min-height: 1.4em; padding: 0 4px; font-size: .9rem; text-align: center; }

/* manage locations */
.hint { margin: 12px 8px; color: var(--muted); font-size: .9rem; }
.plant-list { list-style: none; margin: 0; padding: 0; }
.plant-item { position: relative; margin: 8px 0; border-radius: 6px; background: var(--danger); overflow: hidden; touch-action: pan-y; user-select: none; }
.plant-item .swipe-label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; color: #fff; font-weight: 500; }
.plant-card { position: relative; padding: 10px 12px; background: var(--card); color: var(--card-text); cursor: pointer; transition: transform .15s ease; }
.plant-item.dragging { z-index: 5; box-shadow: 0 6px 18px rgba(0, 0, 0, .35); }
.plant-item.dragging .plant-card { background: var(--highlight); }
.plant-card .name { font-weight: 700; font-size: 1.05rem; }
.plant-card dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0 12px; margin: 4px 0 0; font-size: .85rem; }
.plant-card dt { display: inline; }
.plant-card dd { display: inline; margin: 0 0 0 4px; font-weight: 500; }
.plant-card .inv { margin-top: 4px; font-size: .85rem; }
.fab {
  position: fixed; right: calc(16px + env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 15;
  display: grid; place-items: center; width: 56px; height: 56px; border: 0; border-radius: 16px;
  background: var(--accent); color: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, .35); cursor: pointer;
}

/* settings, backup, help, about */
.settings h2, .backup h2 { margin: 24px 8px 4px; color: var(--accent); font-size: .9rem; font-weight: 600; }
.pref { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 8px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.pref > span { display: flex; flex-direction: column; flex: 1 1 200px; }
.pref small { color: var(--muted); }
.pref input[type="range"] { flex: 1 1 100%; accent-color: var(--accent); }
.pref input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent); }
.pref select, .pref.url input { padding: 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--field); color: var(--text); font: inherit; max-width: 100%; }
.pref.url input { flex: 1 1 100%; }
.btn { display: block; width: 100%; margin: 12px 0; padding: 12px; border: 0; border-radius: 6px; background: var(--accent); color: #fff; font-weight: 500; cursor: pointer; }
.text-btn { padding: 8px 12px; border: 0; border-radius: 6px; background: none; color: var(--accent); font-weight: 500; text-transform: uppercase; cursor: pointer; }
.text-btn.strong { font-weight: 700; }
.text-btn.danger { color: var(--danger); }
.text-btn:disabled { opacity: .4; cursor: default; }
.settings .text-btn { margin: 4px 0; }
.note { display: flex; gap: 12px; align-items: flex-start; margin: 16px 0 8px; padding: 12px; border-radius: 6px; background: var(--field); }
.note svg { color: var(--danger); margin-top: 2px; }
.note p { margin: 0; }
.help, .about { padding: 0 16px; }
.help h2, .about h2 { margin: 20px 0 4px; color: var(--accent); }
.help h3 { margin: 14px 0 2px; font-size: 1rem; }
.help p, .about p { margin: 4px 0; }
.about a, .help a { color: var(--accent); }
.about .logo { display: block; margin: 20px auto 8px; border-radius: 16px; }
.about .center { text-align: center; }

/* dialogs */
dialog { border: 0; border-radius: 10px; padding: 0; background: var(--surface); color: var(--text); max-width: min(560px, calc(100vw - 32px)); box-shadow: 0 8px 30px rgba(0, 0, 0, .4); }
dialog::backdrop { background: var(--scrim); }
dialog > form { display: flex; flex-direction: column; max-height: calc(100dvh - 32px); }
#msgDialog form { padding: 16px 16px 8px; }
#msgDialog h2 { margin: 0 0 8px; font-size: 1.15rem; }
.msg-text p { margin: 6px 0; }
.msg-text ul { margin: 6px 0; padding-left: 20px; }
dialog.full { width: min(560px, calc(100vw - 16px)); }
.dialog-head { padding: 14px 16px 8px; border-bottom: 1px solid var(--border); }
.dialog-head h2 { margin: 0; font-size: 1.15rem; }
.dialog-body { overflow-y: auto; padding: 8px 16px 16px; }
.dialog-foot { display: flex; align-items: center; gap: 4px; padding: 8px; border-top: 1px solid var(--border); flex-wrap: wrap; }
#msgDialog .dialog-foot { border: 0; padding: 8px 0 0; }
.grow { flex: 1; }
.field { display: flex; flex-direction: column; margin: 10px 0 0; font-size: .85rem; color: var(--muted); }
.field input, .field select { margin-top: 2px; padding: 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--field); color: var(--text); font: inherit; font-size: 1rem; width: 100%; }
.field input:focus, .field select:focus, .shading input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.field input[aria-invalid="true"], .shading input[aria-invalid="true"] { border-color: var(--danger); outline-color: var(--danger); }
.field-hint { margin: 2px 0 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.azimuth-row { display: grid; grid-template-columns: 120px 1fr; gap: 12px; align-items: center; }
.compass { width: 120px; height: 120px; margin-top: 10px; touch-action: none; cursor: grab; border-radius: 50%; }
.compass:focus-visible { outline: 2px solid var(--accent); }
.compass svg { width: 120px; height: 120px; }
.compass .ring { fill: var(--field); stroke: var(--border); stroke-width: 2; }
.compass .tick { stroke: var(--muted); stroke-width: 1.5; }
.compass text { fill: var(--text); font-size: 13px; font-weight: 700; text-anchor: middle; dominant-baseline: central; paint-order: stroke; stroke: var(--field); stroke-width: 4px; }
.compass .needle { fill: var(--accent); }
.compass .sun { fill: #f2b705; }
h3 { margin: 20px 0 4px; font-size: 1rem; }
table.shading { width: 100%; border-collapse: collapse; font-size: .9rem; }
.shading th { font-weight: 500; font-size: .75rem; color: var(--muted); text-align: left; padding: 4px; vertical-align: bottom; }
.shading td { padding: 2px 4px; }
.shading td:first-child { white-space: nowrap; }
.shading input { width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--field); color: var(--text); font: inherit; }
.shading tr.never td:first-child { color: var(--muted); }
.shading tr.never input { opacity: .5; }
.shading .max { display: block; font-size: .7rem; color: var(--muted); }
.add-body { display: flex; flex-direction: column; min-height: 0; }
.search { position: relative; }
.search input { width: 100%; margin-top: 8px; padding: 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--field); color: var(--text); font: inherit; }
.suggest { position: absolute; left: 0; right: 0; z-index: 1000; margin: 2px 0 0; padding: 0; list-style: none; max-height: 260px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 6px 16px rgba(0, 0, 0, .25); }
.suggest li { padding: 10px; cursor: pointer; border-bottom: 1px solid var(--border); }
.suggest li:last-child { border-bottom: 0; }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--field); }
.suggest small { display: block; color: var(--muted); }
.map { height: min(45vh, 340px); margin-top: 4px; border-radius: 6px; background: var(--field); }

/* first start */
.tutorial { width: min(440px, calc(100vw - 32px)); }
#slides { padding: 24px 20px 8px; text-align: center; }
#slides img { border-radius: 18px; }
#slides h2 { font-size: 1.4rem; margin: 12px 0 8px; }
#slides p { margin: 8px 0; }
#slides .warn { text-align: left; }
#slides .warn svg { color: var(--danger); width: 40px; height: 40px; display: block; margin: 0 auto; }
.tutorial-foot { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px 12px; }
.dots { display: flex; gap: 6px; padding-left: 8px; }
.dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.dots span.on { background: var(--accent); }

/* snackbar */
.snackbar {
  position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 60; transform: translateX(-50%);
  display: flex; align-items: center; gap: 16px; max-width: calc(100vw - 32px); padding: 12px 16px; border-radius: 6px;
  background: #323232; color: #fff; box-shadow: 0 3px 10px rgba(0, 0, 0, .4);
}
.snackbar button { border: 0; background: none; color: #8fd0ff; font-weight: 700; text-transform: uppercase; cursor: pointer; }

.leaflet-container { font: inherit; }
@media (max-width: 400px) {
  .azimuth-row { grid-template-columns: 100px 1fr; }
  .compass, .compass svg { width: 100px; height: 100px; }
}
