/* assets/css/app.css - all styles for the app (was the <style> block in index.php). */
:root {
  --navy-bg: #0b1329;
  --navy-surface: #0f172a;
  --navy-card: #1e293b;
  --navy-border: #334155;
  --navy-hover: #475569;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-blue: #2563eb;
  --accent-blue-hover: #1d4ed8;
  --accent-gold: #d97706;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --radius-lg: 16px;
  --radius-md: 10px;
  --font-heading: "Quicksand", sans-serif;
  --font-body: "Nunito", sans-serif;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { background: var(--navy-bg); color: var(--text-main); font-family: var(--font-body); font-size: 15px; line-height: 1.55; min-height: 100vh; }
h1, h2, h3, h4 { font-family: var(--font-heading); font-weight: 700; color: #fff; line-height: 1.25; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.02rem; margin-bottom: 8px; }
.muted { color: var(--text-muted); }
.small { font-size: 0.82rem; }
[hidden] { display: none !important; }

/* Header */
header { position: sticky; top: 0; z-index: 50; background: rgba(15, 23, 42, 0.95); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--navy-border); padding: 10px 20px; padding-top: max(10px, env(safe-area-inset-top)); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.logo { font-family: var(--font-heading); font-size: 1.15rem; font-weight: 700; color: #fff; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.logo span { color: var(--accent-gold); }
.header-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--navy-card); border: 1px solid var(--navy-border); padding: 6px 12px; border-radius: 99px; font-size: 0.85rem; white-space: nowrap; }
.user-chip { cursor: pointer; color: var(--text-main); font: inherit; font-size: 0.85rem; min-height: 36px; max-width: 220px; }
.user-chip .name { overflow: hidden; text-overflow: ellipsis; }
/* Platform admin menu in the top bar */
.admin-menu-wrap { position: relative; }
.admin-chip { cursor: pointer; color: var(--text-main); font: inherit; font-size: 0.85rem; min-height: 36px; }
.admin-chip:hover, .admin-chip[aria-expanded="true"] { border-color: var(--accent-gold); }
.admin-chip.has-active { border-color: var(--accent-gold); color: #fff; background: rgba(217, 119, 6, 0.15); }
.admin-caret { font-size: 0.7rem; color: var(--text-muted); }
.admin-menu { position: absolute; top: calc(100% + 8px); right: 0; min-width: 230px; z-index: 60; background: var(--navy-card);
              border: 1px solid var(--navy-border); border-radius: 14px; padding: 6px; box-shadow: 0 12px 32px rgba(0,0,0,0.5);
              display: flex; flex-direction: column; gap: 2px; }
.admin-menu[hidden] { display: none; }
.admin-menu button { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: none; color: var(--text-main);
                     font: inherit; font-size: 0.92rem; text-align: left; padding: 10px 12px; border-radius: 10px; cursor: pointer; min-height: 42px; }
.admin-menu button:hover, .admin-menu button:focus-visible { background: var(--navy-surface); outline: none; }
.admin-menu button.active { background: var(--accent-blue); color: #fff; }
.role-tag { background: var(--accent-gold); color: #000; font-size: 0.66rem; font-weight: 800; padding: 1px 7px; border-radius: 99px; text-transform: uppercase; }

/* Layout */
.app-wrap { display: grid; grid-template-columns: 220px 1fr; gap: 24px; max-width: 1240px; margin: 0 auto; padding: 24px 20px; }
.app-wrap.no-nav { grid-template-columns: 1fr; }
nav#appNav { display: flex; flex-direction: column; gap: 6px; position: sticky; top: 80px; height: fit-content; }
nav#appNav button { display: flex; align-items: center; gap: 10px; text-align: left; background: none; border: 1px solid transparent; padding: 11px 16px; border-radius: var(--radius-md); font-family: var(--font-heading); font-weight: 600; font-size: 0.95rem; color: var(--text-muted); cursor: pointer; transition: 0.2s; }
nav#appNav button:hover { background: var(--navy-card); color: #fff; }
nav#appNav button.active { background: var(--accent-blue); color: #fff; font-weight: 700; }
nav#appNav .ico { font-size: 1.1rem; width: 22px; text-align: center; }
main, .main-col { min-width: 0; }
.yard-bar { display: flex; align-items: center; gap: 10px; background: var(--navy-card); border: 1px solid var(--navy-border); border-left: 4px solid var(--accent-gold);
            border-radius: var(--radius-md); padding: 8px 8px 8px 14px; margin-bottom: 16px; }
.yard-bar .yb-main { min-width: 0; flex: 1; }
.yard-bar .yb-name { font-family: var(--font-heading); font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.role-pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 0.7rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em; }
.role-manager { background: var(--accent-gold); color: #000; }
.role-staff { background: var(--accent-blue); color: #fff; }
.role-viewer { background: var(--navy-hover); color: #fff; }
.role-help { font-size: 0.8rem; color: var(--text-muted); display: grid; gap: 4px; margin-top: 10px; }
.invite-link { display: block; background: var(--navy-surface); border: 1px dashed var(--accent-gold); border-radius: var(--radius-md); padding: 10px 12px; color: var(--accent-gold); font-size: 0.85rem; word-break: break-all; margin: 10px 0; }
.tabs2 { display: flex; gap: 6px; margin: 14px 0; }
.tabs2 button { flex: 1; }
fieldset { border: none; min-width: 0; }
fieldset:disabled input, fieldset:disabled select { opacity: 0.75; }

/* Components */
.card { background: var(--navy-card); border: 1px solid var(--navy-border); border-radius: var(--radius-lg); padding: 20px; margin-bottom: 20px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
label { display: block; font-size: 0.82rem; font-weight: 700; color: var(--text-muted); }
label > input, label > select, label > textarea { margin-top: 4px; }
input, select, textarea { width: 100%; min-height: 44px; padding: 10px 12px; background: var(--navy-surface); border: 1px solid var(--navy-border); border-radius: var(--radius-md); color: #fff; font-family: inherit; font-size: 16px; /* 16px stops iOS zooming on focus */ }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-blue); outline-offset: 1px; }
.btn { background: var(--accent-blue); color: #fff; border: none; min-height: 44px; padding: 10px 18px; border-radius: var(--radius-md); font-family: var(--font-heading); font-weight: 700; font-size: 0.95rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: 0.2s; text-decoration: none; }
.btn:hover { background: var(--accent-blue-hover); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-alt { background: transparent; border: 1px solid var(--navy-border); color: var(--text-main); }
.btn-alt:hover { background: var(--navy-hover); }
.btn-danger { background: transparent; border: 1px solid var(--accent-red); color: #fca5a5; }
.btn-danger:hover { background: rgba(239,68,68,0.15); }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 0.82rem; }
.btn-block { width: 100%; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.tile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.tile { background: var(--navy-surface); border: 1px solid var(--navy-border); border-radius: var(--radius-md); padding: 14px 16px; border-top: 4px solid var(--accent-blue); }
.tile.gold { border-top-color: var(--accent-gold); }
.tile.green { border-top-color: var(--accent-green); }
.tile.red { border-top-color: var(--accent-red); }
.tile-val { font-family: var(--font-heading); font-size: 1.5rem; font-weight: 700; color: #fff; margin: 2px 0; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 0.74rem; font-weight: 800; background: var(--navy-border); color: #fff; white-space: nowrap; }
.badge.gold { background: var(--accent-gold); color: #000; }
.badge.blue { background: var(--accent-blue); }
.badge.green { background: var(--accent-green); }
.badge.red { background: var(--accent-red); }

.segmented { display: inline-flex; background: var(--navy-surface); border: 1px solid var(--navy-border); border-radius: 99px; padding: 4px; gap: 4px; }
.segmented button { background: none; border: none; min-height: 36px; padding: 6px 14px; border-radius: 99px; color: var(--text-muted); font-weight: 700; font-size: 0.85rem; cursor: pointer; font-family: inherit; }
.segmented button.active { background: var(--accent-blue); color: #fff; }

.list { display: flex; flex-direction: column; gap: 10px; }
.item { background: var(--navy-surface); padding: 14px 16px; border-radius: var(--radius-md); border: 1px solid var(--navy-border); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
button.item { width: 100%; text-align: left; color: inherit; font: inherit; cursor: pointer; transition: 0.2s; }
button.item:hover { border-color: var(--accent-blue); background: rgba(37, 99, 235, 0.08); }
.item-main { min-width: 0; flex: 1; }
.item-title { font-weight: 800; color: #fff; }
.item-sub { color: var(--text-muted); font-size: 0.85rem; }
.chev { color: var(--text-muted); font-size: 1.3rem; }

.rug { border-left: 4px solid var(--accent-gold); }
.rug-label { font-family: var(--font-heading); font-weight: 700; color: var(--accent-gold); }
.rug-label.night { color: #a5b4fc; }
/* Rug recommendations and wardrobe */
.rug-badge { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; background: var(--navy-surface); border: 1px solid var(--navy-border); border-radius: var(--radius-md); padding: 10px 14px; font-size: 0.85rem; margin-bottom: 12px; }
.rug-card { background: var(--navy-surface); border: 1px solid var(--navy-border); border-left: 4px solid var(--accent-gold); border-radius: var(--radius-md); padding: 14px 16px; margin-bottom: 12px; }
.rug-card.night { border-left-color: #a5b4fc; }
.rug-rec { margin: 8px 0 2px; font-size: 1.02rem; color: #fff; }
.rug-match { margin-top: 8px; padding: 8px 10px; border-radius: 8px; font-size: 0.9rem; }
.rug-match.ok { background: rgba(16, 185, 129, 0.12); border: 1px solid var(--accent-green); }
.rug-match.warn { background: rgba(217, 119, 6, 0.12); border: 1px solid var(--accent-gold); }
.rug-item .icon-btn { width: 36px; height: 36px; font-size: 1.1rem; }
.rug-form .check-row { display: flex; gap: 10px; align-items: center; margin: 12px 0; color: var(--text-main); font-weight: 600; }
.yard-map { height: 340px; border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--navy-border); background: #1f2937; z-index: 0; }
/* Darken the OpenStreetMap tiles to match the app's navy theme */
/* Light tile sets (OpenStreetMap) are darkened to match the app; dark ones are shown as they are */
.yard-map.tiles-light .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.85) contrast(0.9) saturate(0.6); }
.yard-map { position: relative; }
.map-note { position: absolute; left: 10px; right: 10px; bottom: 26px; z-index: 500; background: rgba(15,23,42,0.92); border: 1px solid var(--navy-border); border-radius: 8px; padding: 8px 10px; font-size: 0.8rem; color: var(--text-muted); }
.yard-map.leaflet-container .leaflet-control-attribution { background: rgba(15,23,42,0.8); color: #94a3b8; font-size: 10px; }
.yard-map.leaflet-container .leaflet-control-attribution a { color: #cbd5e1; }
.yard-map.leaflet-container .leaflet-bar a { background: var(--navy-card); color: #fff; border-color: var(--navy-border); }
.yard-map.leaflet-container .leaflet-tooltip { background: #111827; color: #fff; border: 1px solid var(--navy-border); font-family: var(--font-body); }
.yard-map .leaflet-tooltip-top::before { border-top-color: #111827; }
.yard-dot-wrap { background: none; border: none; }
.yard-dot { border-radius: 50%; background: rgba(37, 99, 235, 0.8); border: 2px solid #fff; color: #fff; font-weight: 800; font-family: var(--font-heading);
            display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 6px rgba(37, 99, 235, 0.25), 0 4px 12px rgba(0,0,0,0.5); cursor: pointer; transition: transform 0.15s; }
.yard-dot:hover { transform: scale(1.08); }
.yard-dot.sel { background: rgba(217, 119, 6, 0.9); box-shadow: 0 0 0 6px rgba(217, 119, 6, 0.3), 0 4px 12px rgba(0,0,0,0.5); }
.overlay-wrap { position: relative; }
.tile.has-pill { position: relative; }
.csv-pill { position: absolute; top: 8px; right: 8px; z-index: 5; display: inline-flex; align-items: center; gap: 3px;
            background: rgba(15, 23, 42, 0.88); color: var(--accent-gold); border: 1px solid rgba(217, 119, 6, 0.6); border-radius: 99px;
            padding: 3px 9px; min-height: 26px; font-family: var(--font-heading); font-weight: 700; font-size: 0.7rem; letter-spacing: 0.02em;
            cursor: pointer; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); transition: 0.15s; }
.csv-pill:hover, .csv-pill:focus-visible { background: var(--accent-gold); color: #000; }
.overlay-wrap > .csv-pill { top: 10px; right: 10px; }
.csv-note { margin-top: 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.csv-token-select { width: auto; min-height: 36px; padding: 4px 8px; font-size: 16px; }
.check-row { cursor: pointer; justify-content: flex-start; }
.check-row input[type=checkbox] { width: 22px; height: 22px; min-height: 0; flex-shrink: 0; accent-color: var(--accent-gold); margin: 0; }
.check-row input[type=checkbox]:disabled + span { opacity: .6; }
.horse-access .ha-list { max-height: 280px; overflow-y: auto; }
.horse-access #haScopeRow { display: flex; gap: 10px; align-items: flex-start; }
.notice.danger-notice { background: rgba(239, 68, 68, 0.1); border-color: var(--accent-red); }
.btn-danger-solid { background: var(--accent-red); color: #fff; }
.btn-danger-solid:hover { background: #dc2626; }
.about details { border-bottom: 1px solid var(--navy-border); }
.about details:last-child { border-bottom: none; }
.about summary { cursor: pointer; padding: 12px 0; font-family: var(--font-heading); font-weight: 700; font-size: 1.02rem; color: #fff; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.about summary::-webkit-details-marker { display: none; }
.about summary::after { content: '＋'; color: var(--text-muted); }
.about details[open] summary::after { content: '－'; }
.about-body { padding: 0 0 14px; color: #cbd5e1; font-size: 0.92rem; }
.about-body p { margin-bottom: 8px; }
.about-body ul { margin: 0 0 8px 20px; display: grid; gap: 4px; }
.about-body code, code.ref { background: var(--navy-surface); border: 1px solid var(--navy-border); border-radius: 6px; padding: 0 5px; font-size: 0.85em; color: var(--accent-gold); }
code.ref { font-size: 0.9rem; font-weight: 700; letter-spacing: 0.04em; padding: 1px 7px; }
.filter-chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
.filter-chips button { flex-shrink: 0; background: var(--navy-surface); border: 1px solid var(--navy-border); color: var(--text-muted); border-radius: 99px; padding: 6px 12px; min-height: 34px; font-weight: 700; font-size: 0.8rem; cursor: pointer; font-family: inherit; }
.filter-chips button span { opacity: 0.7; margin-left: 2px; }
.filter-chips button.active { background: var(--accent-blue); border-color: var(--accent-blue); color: #fff; }
.item.idea { position: relative; padding: 0; align-items: stretch; }
.idea-main { flex: 1; min-width: 0; text-align: left; background: none; border: none; color: inherit; font: inherit; padding: 14px 16px; padding-right: 84px; cursor: pointer; border-radius: var(--radius-md); }
.idea-main:hover { background: rgba(37, 99, 235, 0.08); }
.idea-details { white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; margin: 4px 0; }
.idea-pill { top: 12px; right: 12px; }
.import-list { max-height: 360px; overflow-y: auto; }
.import-list .item { align-items: flex-start; gap: 10px; }
.import-list .item-sub.clip { white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
/* Claude builds */
.meter { height: 8px; background: var(--navy-surface); border: 1px solid var(--navy-border); border-radius: 99px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent-blue); }
.diff-file { margin-bottom: 10px; }
.diff-file > summary { cursor: pointer; padding: 6px 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.diff { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.75rem; line-height: 1.45; overflow-x: auto; background: var(--navy-surface); border: 1px solid var(--navy-border); border-radius: var(--radius-md); padding: 6px 0; }
.diff > div { white-space: pre; padding: 0 10px; min-width: max-content; }
.diff .add { background: rgba(16, 185, 129, 0.16); }
.diff .del { background: rgba(239, 68, 68, 0.16); }
.diff .gap { color: var(--text-muted); text-align: center; }
.diff .ln { display: inline-block; width: 3.5em; color: var(--text-muted); user-select: none; }
.import-paste { width: 100%; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.8rem; }
.horse-pill { position: static; vertical-align: middle; margin-left: 10px; }
.api-box { border: 1px solid rgba(217, 119, 6, 0.6); border-radius: 12px; padding: 12px; margin-bottom: 14px; background: var(--navy-surface); }
.status-planned { background: var(--accent-blue); } .status-in_progress { background: var(--accent-gold); color: #000; }
.status-done { background: var(--accent-green); } .status-dropped { background: transparent; border: 1px solid var(--navy-hover); color: var(--text-muted); }
.prio-high { background: rgba(239,68,68,0.2); color: #fca5a5; } .prio-medium { background: rgba(148,163,184,0.15); color: #cbd5e1; } .prio-low { background: transparent; color: var(--text-muted); border: 1px solid var(--navy-border); }
textarea { resize: vertical; line-height: 1.5; }
.sheet-head h2 code.ref { vertical-align: middle; }
.reqs { display: grid; gap: 8px; }
.req { display: flex; gap: 10px; align-items: flex-start; font-size: 0.9rem; }
code.hint { display: block; margin-top: 4px; background: var(--navy-surface); border: 1px solid var(--navy-border); border-radius: 6px; padding: 6px 8px; font-size: 0.78rem; color: var(--accent-gold); word-break: break-all; white-space: pre-wrap; }
.reqs-details summary { cursor: pointer; margin-top: 12px; }
.reqs-details .reqs { margin-top: 8px; }
input[type=file] { padding: 8px; }
button.item.selected { border-color: var(--accent-gold); background: rgba(217, 119, 6, 0.1); }
hr.sep { border: none; border-top: 1px solid var(--navy-border); margin: 16px 0; }
.feedlog-form { display: grid; grid-template-columns: 1.3fr 1fr 1fr auto; gap: 8px; align-items: end; }

table.data { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
table.data th, table.data td { padding: 10px 12px; border-bottom: 1px solid var(--navy-border); text-align: left; vertical-align: top; }
table.data th { background: var(--navy-surface); color: var(--text-muted); font-family: var(--font-heading); font-weight: 700; }
code.tok { color: var(--accent-gold); font-size: 0.8rem; word-break: break-all; }

.chart-box { position: relative; height: 260px; }
.empty { text-align: center; color: var(--text-muted); padding: 24px 8px; }
.notice { background: rgba(217, 119, 6, 0.12); border: 1px solid var(--accent-gold); border-radius: var(--radius-md); padding: 10px 14px; font-size: 0.85rem; margin-bottom: 14px; }
.error-text { color: #fca5a5; font-size: 0.88rem; min-height: 1.2em; }

/* Login */
.login-card { max-width: 420px; margin: 40px auto; }
.login-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }

/* Bottom sheet / modal */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 90; display: flex; align-items: center; justify-content: center; padding: 20px; }
.sheet { background: var(--navy-card); border: 1px solid var(--navy-border); border-radius: var(--radius-lg); width: 100%; max-width: 640px; max-height: 90vh; display: flex; flex-direction: column; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--navy-border); gap: 10px; }
.sheet-body { padding: 18px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet-foot { padding: 12px 18px; padding-bottom: max(12px, var(--safe-b)); border-top: 1px solid var(--navy-border); display: flex; gap: 10px; flex-wrap: wrap; }
.icon-btn { background: none; border: none; color: var(--text-muted); font-size: 1.5rem; width: 44px; height: 44px; border-radius: 99px; cursor: pointer; }
.icon-btn:hover { background: var(--navy-hover); color: #fff; }
.feed-row { display: grid; grid-template-columns: 1fr 80px 96px 44px; gap: 8px; align-items: end; margin-bottom: 8px; }

/* Toast */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(150%); background: #111827; border: 1px solid var(--navy-border); color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 100; max-width: calc(100% - 32px); box-shadow: 0 10px 30px rgba(0,0,0,0.4); transition: transform 0.25s, opacity 0.25s; font-weight: 600; opacity: 0; visibility: hidden; pointer-events: none; }
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; visibility: visible; }
/* While a panel is open, show messages at the top so they don't cover it */
body:has(.sheet-backdrop) #toast { top: max(12px, env(safe-area-inset-top)); bottom: auto; transform: translateX(-50%) translateY(-150%); }
body:has(.sheet-backdrop) #toast.show { transform: translateX(-50%) translateY(0); }
#toast.err { border-color: var(--accent-red); }

/* Mobile tab bar (hidden on desktop) */
#tabbar { display: none; }

@media (max-width: 768px) {
  header { padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top)); }
  .logo { font-size: 1.02rem; }
  #weatherChip .wlabel { display: none; }
  .user-chip .name { display: none; }
  .admin-label, .admin-caret { display: none; }
  .header-right { gap: 6px; }
  header .chip { padding: 6px 9px; }
  .admin-menu-wrap { position: static; }
  .admin-menu { position: fixed; top: calc(52px + env(safe-area-inset-top)); left: 12px; right: 12px; min-width: 0; }
  .app-wrap { grid-template-columns: 1fr; padding: 16px 16px calc(var(--tabbar-h) + var(--safe-b) + 20px); gap: 0; }
  .app-wrap.no-nav { padding-bottom: 24px; }
  nav#appNav { display: none; }
  .card { padding: 16px; border-radius: 14px; margin-bottom: 16px; }
  .tile-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tile { padding: 12px; }
  .tile-val { font-size: 1.25rem; }
  .chart-box { height: 220px; }
  .yard-map { height: 280px; }
  .csv-pill { min-height: 30px; padding: 4px 10px; }

  #tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; background: rgba(15, 23, 42, 0.97); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--navy-border); padding-bottom: var(--safe-b); }
  #tabbar button { flex: 1; min-width: 0; height: var(--tabbar-h); background: none; border: none; color: var(--text-muted); font-family: var(--font-heading); font-size: 0.68rem; font-weight: 700; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; }
  #tabbar button .ico { font-size: 1.3rem; line-height: 1; }
  #tabbar button.active { color: #fff; }
  #tabbar button.active .ico { transform: scale(1.1); }
  #tabbar button span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; padding: 0 2px; }

  /* Sheets slide up from the bottom on phones */
  .sheet-backdrop { align-items: flex-end; padding: 0; }
  .sheet { max-width: none; border-radius: 18px 18px 0 0; max-height: 92vh; border-bottom: none; }
  .feed-row { grid-template-columns: 1fr 70px 44px; }
  .feedlog-form { grid-template-columns: 1fr 1fr; }
  .feedlog-form label:first-child, .feedlog-form .btn { grid-column: 1 / -1; }
  .feed-row .feed-time { grid-column: 1 / 3; }

  /* Tables become stacked cards */
  table.data.stack thead { display: none; }
  table.data.stack, table.data.stack tbody, table.data.stack tr, table.data.stack td { display: block; width: 100%; }
  table.data.stack tr { background: var(--navy-surface); border: 1px solid var(--navy-border); border-radius: var(--radius-md); margin-bottom: 10px; padding: 8px 12px; }
  table.data.stack td { border: none; padding: 4px 0; display: flex; gap: 12px; justify-content: space-between; text-align: right; }
  table.data.stack td::before { content: attr(data-label); color: var(--text-muted); font-weight: 700; text-align: left; flex-shrink: 0; }
  table.data.stack td.full { display: block; text-align: left; }
  table.data.stack td.full::before { display: block; margin-bottom: 2px; }

  #toast { bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px); }
}
/* Feed plan */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid label .small { display: block; font-weight: 400; margin-top: 3px; }
@media (max-width: 480px) { .form-grid { grid-template-columns: 1fr; } }
@media (max-width: 380px) { .logo span { display: none; } }   /* room for the top bar chips on small phones */
.feed-in { width: 62px; min-height: 34px; padding: 4px 6px; }
.feed-in.feed-flags { width: 130px; }
.feed-in[data-k=weight] { width: 78px; }
.feed-table th, .feed-table td { padding-left: 6px; padding-right: 6px; }
.feed-table td:nth-last-child(-n+3) { white-space: nowrap; }
.feed-pair { display: inline-flex; gap: 4px; align-items: center; }
.feed-table td { vertical-align: middle; }
@media (max-width: 768px) { .feed-in, .feed-in[data-k=weight] { width: 90px; } .feed-pair .feed-in { width: 70px; } .feed-in.feed-flags { width: 170px; } table.data.stack td .feed-pair { justify-content: flex-end; } }
@media print {
  body { background: #fff !important; color: #000 !important; }
  header, nav#appNav, #tabbar, #yardBar, #toast, #sheetRoot, .no-print, .csv-pill { display: none !important; }
  .app-wrap { display: block !important; padding: 0 !important; }
  .card, .tile { background: #fff !important; border-color: #bbb !important; color: #000 !important; box-shadow: none !important; break-inside: avoid; }
  .tile-val, h2, h3, strong { color: #000 !important; }
  .muted, .small { color: #444 !important; }
  .feed-in { border: none !important; background: none !important; color: #000 !important; width: auto !important; padding: 0 !important; -moz-appearance: textfield; }
  .feed-in::-webkit-inner-spin-button { display: none; }
  table.data.stack { display: table !important; width: 100% !important; }
  table.data.stack thead { display: table-header-group !important; }
  table.data.stack tbody { display: table-row-group !important; }
  table.data th { background: #fff !important; color: #000 !important; border-bottom: 2px solid #000 !important; }
  .feed-in::placeholder { color: transparent !important; }
  table.data.stack tr { display: table-row !important; background: none !important; border: none !important; }
  table.data.stack td { display: table-cell !important; border-bottom: 1px solid #ccc !important; text-align: left !important; }
  table.data.stack td::before { display: none !important; }
  .chart-box { height: 220px; }
}
/* Sharing links */
.share-backdrop { z-index: 95; }
.share-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.share-box { margin-top: 12px; padding: 12px; border: 1px solid var(--navy-border); border-radius: var(--radius-md); background: var(--navy-surface); }
.share-qr { display: inline-block; background: #fff; padding: 6px; border-radius: 8px; line-height: 0; }
.share-qr svg { max-width: 100%; height: auto; }
.badge.private { background: rgba(239, 68, 68, 0.15); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.5); }
.grow { flex: 1; }
.link-btn { background: none; border: none; color: var(--text-muted); font: inherit; font-size: 0.85rem; cursor: pointer; text-decoration: underline; padding: 4px 0; align-self: center; }
.link-btn:hover { color: #fff; }
@media print { #shareRoot { display: none !important; } }
/* Sidebar folder for platform admin pages */
nav#appNav .nav-caret { margin-left: auto; transition: transform 0.2s; font-size: 1.1rem; }
/* Settings page */
.settings-form .grid { margin-top: 10px; }
.field-help { display: block; font-weight: 400; margin-top: 4px; }
.lock-badge { font-size: 0.68rem; vertical-align: middle; margin-left: 4px; }
.settings-form input:disabled, .settings-form select:disabled { opacity: 0.6; }
.settings-form .check-row { display: flex; gap: 10px; align-items: flex-start; margin-top: 12px; color: var(--text-main); font-weight: 600; }
/* Roadmap search */
.idea-search { display: flex; align-items: center; gap: 8px; background: var(--navy-surface); border: 1px solid var(--navy-border); border-radius: var(--radius-md); padding: 0 12px; }
.idea-search:focus-within { outline: 2px solid var(--accent-blue); outline-offset: 1px; }
.idea-search input { border: none; background: none; padding-left: 0; outline: none; }
.idea-search input:focus { outline: none; }
mark { background: rgba(217, 119, 6, 0.35); color: #fff; border-radius: 3px; padding: 0 1px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
