/* The Plumula web admin: the app's own palette (mobile/src/theme), its light and its dark (the Kotlin
   app's), dense like the owner likes the app's pages. */
:root {
  --paper: #F1EEE3; --card: #FFFFFF; --card2: #FBFAF6; --ink: #20231D; --ink-soft: #52564B; --grey: #7E8077;
  --moss: #46613C; --moss-soft: #DCE3D5; --moss-ink: #2E3A27; --amber: #DB9B5F; --amber-soft: #F2DFC9; --amber-ink: #5A4526;
  --tide: #235E66; --tide-soft: #D9E6E6; --tide-ink: #1B4A50; --red: #A93226; --red-soft: #F8E0DA; --line: #E6E1D3;
  --sand: #EAE6D8; --hairline: rgba(32,35,29,0.16); --shadow: 0 1px 2px rgba(32,35,29,0.06), 0 4px 14px rgba(32,35,29,0.05);
  --hero: #3A5232; --hero-foot: #2F4428; --lichen: #CFE0BF;
  --bar: #46613C; --bubble-user: #DCE3D5; --bubble-bot: #FBFAF6;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #15181A; --card: #20262A; --card2: #1A1F22; --ink: #ECE8DC; --ink-soft: #9DA096; --grey: #8A8D81;
    --moss: #7FA06A; --moss-soft: #2A3527; --moss-ink: #CFE2C0; --amber: #DB9B5F; --amber-soft: #3A2C1C; --amber-ink: #F2D3AE;
    --tide: #7CC0C8; --tide-soft: #1E3033; --tide-ink: #A9D6DB; --red: #EE8A7E; --red-soft: #3D2320; --line: #33383B;
    --sand: #272B2E; --hairline: rgba(236,232,220,0.16); --shadow: none; --bar: #7FA06A; --bubble-user: #2A3527; --bubble-bot: #1A1F22;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #15181A; --card: #20262A; --card2: #1A1F22; --ink: #ECE8DC; --ink-soft: #9DA096; --grey: #8A8D81;
  --moss: #7FA06A; --moss-soft: #2A3527; --moss-ink: #CFE2C0; --amber: #DB9B5F; --amber-soft: #3A2C1C; --amber-ink: #F2D3AE;
  --tide: #7CC0C8; --tide-soft: #1E3033; --tide-ink: #A9D6DB; --red: #EE8A7E; --red-soft: #3D2320; --line: #33383B;
  --sand: #272B2E; --hairline: rgba(236,232,220,0.16); --shadow: none; --bar: #7FA06A; --bubble-user: #2A3527; --bubble-bot: #1A1F22;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font: 400 14px/1.45 "Work Sans", system-ui, -apple-system, sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: "Fraunces", Georgia, serif; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 24px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
a { color: var(--moss); text-decoration: none; } a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; }
.soft { color: var(--ink-soft); } .grey { color: var(--grey); } .small { font-size: 12px; } .nowrap { white-space: nowrap; }
.noscript { padding: 40px; text-align: center; }

/* ---- lock ---- */
.lock { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--hero); }
.lock-card { width: min(380px, 100%); background: var(--card); border-radius: 18px; padding: 26px 24px 22px; box-shadow: 0 10px 40px rgba(0,0,0,0.25); }
.lock-card .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.lock-card .brand img { width: 34px; height: 34px; border-radius: 9px; }
.lock-card p { margin: 0 0 14px; color: var(--ink-soft); font-size: 13px; }
.lock-card label.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); margin: 10px 0 16px; }
.lock-card .err { color: var(--red); font-size: 13px; min-height: 18px; margin: 8px 0 0; }

/* ---- shell ---- */
.shell { display: grid; grid-template-columns: 208px 1fr; min-height: 100vh; }
.side { background: var(--hero); color: var(--lichen); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; }
.side .brand { display: flex; align-items: center; gap: 9px; padding: 0 8px 16px; color: #F1EEE3; font-family: "Fraunces", Georgia, serif; font-size: 18px; font-weight: 600; }
.side .brand img { width: 26px; height: 26px; border-radius: 7px; }
.side .brand span { color: var(--lichen); font-family: "Work Sans", sans-serif; font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; margin-left: auto; opacity: 0.8; }
.nav { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; color: var(--lichen); font-weight: 500; }
.nav:hover { background: rgba(207,224,191,0.10); text-decoration: none; }
.nav.on { background: rgba(207,224,191,0.18); color: #FFFFFF; }
.nav .ico { width: 18px; text-align: center; opacity: 0.9; }
.nav .badge { margin-left: auto; background: rgba(207,224,191,0.2); color: #fff; border-radius: 99px; padding: 0 7px; font-size: 11px; font-weight: 600; }
.side .foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; border-top: 1px solid rgba(207,224,191,0.18); padding-top: 10px; }
.side .foot button { background: none; border: 0; text-align: left; cursor: pointer; }
.main { min-width: 0; }
.top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(8px); display: flex; align-items: center; gap: 10px; padding: 10px 22px; border-bottom: 1px solid var(--line); }
.top .crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; font-size: 13px; color: var(--ink-soft); }
.top .crumbs b { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top form { display: flex; gap: 6px; }
.top input { width: 300px; }
.page { padding: 18px 22px 60px; max-width: 1280px; }
.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head .grow { flex: 1; min-width: 200px; }
.page-head p { margin: 3px 0 0; color: var(--ink-soft); font-size: 13px; }

/* ---- controls ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--hairline); background: var(--card); color: var(--ink); font-weight: 500; font-size: 13px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--moss); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--moss); border-color: var(--moss); color: #fff; }
:root[data-theme="dark"] .btn.primary { color: #15181A; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { color: #15181A; } }
.btn.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, transparent); }
.btn.danger:hover { background: var(--red-soft); border-color: var(--red); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--moss); padding: 0 6px; }
.btn.ghost:hover { background: var(--moss-soft); }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; border-radius: 7px; }
.btn.wide { width: 100%; height: 38px; font-size: 14px; }
.input, input[type="text"], input[type="password"], input[type="search"], input[type="date"], select, textarea { height: 30px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--hairline); background: var(--card); outline: none; font-size: 13px; }
textarea { height: auto; padding: 8px 10px; }
.input:focus, input:focus, select:focus, textarea:focus { border-color: var(--moss); box-shadow: 0 0 0 3px color-mix(in srgb, var(--moss) 18%, transparent); }
.lock-card input[type="password"] { width: 100%; height: 38px; font-size: 14px; }
.lock-card input[type="checkbox"] { width: 15px; height: 15px; margin: 0; accent-color: var(--moss); }
.seg { display: inline-flex; background: var(--sand); border-radius: 9px; padding: 2px; gap: 2px; }
.seg button { border: 0; background: transparent; height: 26px; padding: 0 10px; border-radius: 7px; cursor: pointer; font-size: 12px; font-weight: 500; color: var(--ink-soft); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---- surfaces ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.card.pad { padding: 14px 16px; }
.card h2 { margin-bottom: 8px; }
.card-head { display: flex; align-items: center; gap: 8px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.card-head h2 { margin: 0; font-size: 15px; }
.card-head .count { color: var(--grey); font-size: 12px; }
.grid { display: grid; gap: 12px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.side-main { grid-template-columns: 340px minmax(0, 1fr); align-items: start; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.empty { padding: 26px 16px; text-align: center; color: var(--grey); font-size: 13px; }
.loading { padding: 40px; text-align: center; color: var(--grey); }
.loading::before { content: ""; display: inline-block; width: 14px; height: 14px; margin-right: 8px; vertical-align: -2px; border: 2px solid var(--line); border-top-color: var(--moss); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-box { background: var(--red-soft); color: var(--red); border-radius: 10px; padding: 12px 14px; font-size: 13px; }
.warn-box { background: var(--amber-soft); color: var(--amber-ink); border-radius: 10px; padding: 10px 14px; font-size: 13px; }

/* ---- stats ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(172px, 1fr)); gap: 10px; margin-bottom: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px 12px; box-shadow: var(--shadow); }
.tile .k { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--grey); }
.tile .v { font-family: "Fraunces", Georgia, serif; font-size: 26px; font-weight: 600; line-height: 1.15; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .s { font-size: 12px; color: var(--ink-soft); margin-top: 1px; }
.tile.link { cursor: pointer; } .tile.link:hover { border-color: var(--moss); }

/* ---- chips ---- */
.chip { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 99px; font-size: 11px; font-weight: 600; background: var(--sand); color: var(--ink-soft); white-space: nowrap; }
.chip.moss { background: var(--moss-soft); color: var(--moss-ink); }
.chip.tide { background: var(--tide-soft); color: var(--tide-ink); }
.chip.amber { background: var(--amber-soft); color: var(--amber-ink); }
.chip.red { background: var(--red-soft); color: var(--red); }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--grey); padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--card2); position: sticky; top: 0; }
td { padding: 7px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--moss-soft) 35%, transparent); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td .clip { display: block; max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 13px; }
.kv dt { color: var(--grey); } .kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---- accounts ---- */
.acct-list { display: flex; flex-direction: column; gap: 8px; }
.acct { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; box-shadow: var(--shadow); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 14px; }
.acct .title { display: flex; align-items: center; gap: 6px; min-width: 0; }
.acct .title a { font-weight: 600; font-size: 14px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct .meta { font-size: 12px; color: var(--ink-soft); display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.acct .actions { grid-row: span 2; display: flex; align-items: flex-start; gap: 5px; justify-content: flex-end; }
.acct .strip { grid-column: 1 / -1; }
.acct .result { grid-column: 1 / -1; font-size: 12px; }
.acct .result.ok { color: var(--moss); } .acct .result.bad { color: var(--red); }
.idline { display: inline-flex; align-items: center; gap: 4px; min-width: 0; }
.idline .mono { color: var(--grey); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy { border: 0; background: none; color: var(--moss); font-size: 11px; font-weight: 600; cursor: pointer; padding: 0 2px; }
.strip { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.strip .thumb { flex: 0 0 auto; width: 64px; cursor: pointer; text-decoration: none; color: inherit; }
.strip .thumb .ph { width: 64px; height: 64px; border-radius: 9px; }
.strip .thumb .cap { font-size: 10.5px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

/* ---- photos ---- */
.ph { position: relative; background: var(--sand); overflow: hidden; display: block; }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; animation: fade 0.25s ease; }
.ph.ph-none::after, .ph.ph-miss::after { content: "🌱"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 18px; opacity: 0.35; }
.ph.ph-miss::after { content: "—"; }
.ph .hb { position: absolute; left: 4px; right: 4px; bottom: 4px; height: 3px; border-radius: 2px; background: rgba(255,255,255,0.45); }
.ph .hb i { display: block; height: 100%; border-radius: 2px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.plants { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.plant-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; color: inherit; box-shadow: var(--shadow); }
.plant-card:hover { border-color: var(--moss); text-decoration: none; }
.plant-card .ph { aspect-ratio: 1; }
.plant-card .body { padding: 7px 9px 9px; }
.plant-card .name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plant-card .latin { font-style: italic; font-size: 12px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plant-card .foot { display: flex; align-items: center; gap: 6px; margin-top: 5px; font-size: 11px; color: var(--grey); }
.health { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-variant-numeric: tabular-nums; }
.health .bar { width: 46px; height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; }
.health .bar i { display: block; height: 100%; border-radius: 3px; }

/* ---- plant ---- */
.hero-photo { aspect-ratio: 1; border-radius: 12px; cursor: zoom-in; }
.prose { font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.prose + .prose { margin-top: 6px; }
.label { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--grey); margin: 12px 0 4px; }
.label:first-child { margin-top: 0; }
ol.steps { margin: 0; padding-left: 18px; font-size: 13px; } ol.steps li { margin: 2px 0; }
.timeline { display: flex; flex-direction: column; gap: 8px; padding: 14px; }
.ev { display: flex; gap: 8px; }
.ev .when { flex: 0 0 auto; width: 86px; font-size: 11px; color: var(--grey); padding-top: 3px; text-align: right; }
.ev .what { flex: 1; min-width: 0; }
.bubble { display: inline-block; max-width: 92%; border-radius: 12px; padding: 7px 10px; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; border: 1px solid var(--line); background: var(--bubble-bot); }
.ev.user .bubble { background: var(--bubble-user); border-color: transparent; }
.ev.user .what { text-align: right; }
.bubble .ph { width: 160px; height: 160px; border-radius: 9px; margin-bottom: 6px; cursor: zoom-in; }
.bubble .model { display: block; font-size: 10.5px; color: var(--grey); margin-top: 3px; }
.ev-card { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--card2); font-size: 13px; }
.ev-card .h { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-weight: 600; margin-bottom: 3px; }
.ev-card .ph { width: 120px; height: 120px; border-radius: 8px; margin-top: 6px; cursor: zoom-in; }
.ev.tiny .what { font-size: 12px; color: var(--ink-soft); padding-top: 2px; }
details { font-size: 12px; }
details summary { cursor: pointer; color: var(--moss); font-weight: 500; }
pre { margin: 6px 0 0; padding: 10px; background: var(--card2); border: 1px solid var(--line); border-radius: 8px; overflow: auto; max-height: 420px; font: 11.5px/1.45 ui-monospace, "SF Mono", Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---- charts ---- */
.chart { position: relative; padding: 4px 4px 0; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis { fill: var(--grey); font-size: 10px; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .bar { fill: var(--bar); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart .bar.hover { opacity: 0.8; }
.tip { position: fixed; z-index: 50; pointer-events: none; background: var(--ink); color: var(--paper); border-radius: 8px; padding: 6px 9px; font-size: 12px; box-shadow: 0 6px 20px rgba(0,0,0,0.2); white-space: nowrap; }
.tip b { font-weight: 600; }

/* ---- dialog, toast, lightbox ---- */
dialog { border: 0; border-radius: 16px; padding: 0; width: min(440px, calc(100vw - 32px)); background: var(--card); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
dialog::backdrop { background: rgba(20,24,18,0.45); }
.dlg { padding: 20px 20px 16px; }
.dlg h2 { margin-bottom: 8px; }
.dlg p { margin: 0 0 12px; color: var(--ink-soft); font-size: 13px; }
.dlg .fields { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.dlg .fields label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.dlg .fields input, .dlg .fields select { height: 34px; }
.dlg .buttons { display: flex; justify-content: flex-end; gap: 8px; }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast { max-width: 420px; background: var(--ink); color: var(--paper); border-radius: 10px; padding: 9px 13px; font-size: 13px; box-shadow: 0 8px 26px rgba(0,0,0,0.25); animation: rise 0.2s ease; }
.toast.bad { background: var(--red); color: #fff; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.lightbox { position: fixed; inset: 0; z-index: 70; background: rgba(10,12,9,0.88); display: grid; place-items: center; cursor: zoom-out; padding: 24px; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; }

/* ---- narrow ---- */
@media (max-width: 980px) {
  .grid.side-main, .grid.two, .grid.three { grid-template-columns: minmax(0, 1fr); }
  .top input { width: 180px; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; overflow-x: auto; padding: 8px; gap: 4px; }
  .side .brand { padding: 0 8px 0 4px; }
  .side .brand span, .nav .ico, .nav .badge { display: none; }
  .side .foot { margin: 0; flex-direction: row; border: 0; padding: 0; }
  .nav { white-space: nowrap; padding: 6px 9px; }
  .top { padding: 8px 16px; flex-wrap: wrap; }
  .top form { width: 100%; } .top input { flex: 1; width: auto; }
  .page { padding: 14px 16px 50px; }
  .acct { grid-template-columns: minmax(0, 1fr); }
  .acct .actions { grid-row: auto; justify-content: flex-start; max-width: none; }
  .ev .when { width: 60px; }
}
