/* ============================================================
   Hub design system – base: reset, wallpaper, glass, app shell
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; height: 100%; }
body {
  margin: 0; min-height: 100%; font-family: var(--font); font-size: var(--fs-base); line-height: var(--lh); color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; font-feature-settings: "cv11";
  overscroll-behavior-y: none;
}
.sprite { position: absolute; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }
.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.i.sm { width: 16px; height: 16px; } .i.xs { width: 13px; height: 13px; stroke-width: 2.2; } .i.lg { width: 26px; height: 26px; stroke-width: 1.6; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-xs); }
::selection { background: var(--accent-soft-2); }
.muted { color: var(--text-2); } .small { font-size: 13px; } .hint { color: var(--text-3); font-size: 13px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.num, .time, .range, .ftime, .n, .count, .money { font-variant-numeric: tabular-nums; }
code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
h1, h2, h3 { letter-spacing: var(--track-tight); }

/* ---------- Wallpaper (tinted per app via --wp1..4) ---------- */
.wallpaper { position: fixed; inset: 0; z-index: -1; background: var(--bg); overflow: hidden; pointer-events: none; transition: background var(--dur-slow); }
.wallpaper::before, .wallpaper::after { content: ""; position: absolute; inset: -20%; transition: opacity var(--dur-slow); }
.wallpaper[data-wp="aurora"]::before {
  background:
    radial-gradient(42% 38% at 18% 22%, var(--wp1) 0%, transparent 70%),
    radial-gradient(45% 40% at 82% 18%, var(--wp2) 0%, transparent 70%),
    radial-gradient(50% 45% at 70% 85%, var(--wp3) 0%, transparent 70%),
    radial-gradient(35% 35% at 20% 90%, var(--wp4) 0%, transparent 70%);
  filter: blur(40px) saturate(1.1);
}
.wallpaper[data-wp="dusk"]::before {
  background:
    radial-gradient(60% 50% at 30% 10%, var(--wp4) 0%, transparent 70%),
    radial-gradient(55% 55% at 90% 60%, var(--wp1) 0%, transparent 70%),
    radial-gradient(60% 50% at 10% 90%, var(--wp2) 0%, transparent 70%);
  filter: blur(50px);
}
.wallpaper[data-wp="mist"]::before {
  background: radial-gradient(70% 60% at 50% 0%, var(--wp3) 0%, transparent 70%), radial-gradient(70% 60% at 50% 100%, var(--wp2) 0%, transparent 72%);
  filter: blur(60px); opacity: .85;
}
.wallpaper[data-wp="none"]::before { background: none; }
.wallpaper[data-wp="custom"]::before { background: var(--wallpaper-img) center / cover no-repeat; inset: -3%; filter: blur(8px) saturate(1.05); }
.wallpaper[data-wp="custom"]::after { background: color-mix(in srgb, var(--bg) 42%, transparent); inset: 0; }
@media (prefers-reduced-transparency: reduce) { .wallpaper::before, .wallpaper::after { display: none; } }

/* ---------- Glass ----------
   Layers: tinted translucent fill + sheen gradient (inner light), 1px rim,
   specular top line, soft bottom shade, drop shadow. .float = nav/sheets. */
.glass {
  background: var(--glass-sheen), var(--glass);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(var(--saturate));
  backdrop-filter: blur(var(--blur)) saturate(var(--saturate));
  box-shadow: inset 0 0 0 1px var(--glass-edge), inset 0 1.5px 0 var(--glass-hi), inset 0 -1px 0 var(--glass-lo), var(--glass-shadow);
}
.glass.strong { background: var(--glass-sheen), var(--glass-strong); }
.glass.float {
  -webkit-backdrop-filter: blur(var(--blur-float)) saturate(var(--saturate));
  backdrop-filter: blur(var(--blur-float)) saturate(var(--saturate));
  box-shadow: inset 0 0 0 1px var(--glass-edge), inset 0 1.5px 0 var(--glass-hi), inset 0 -1px 0 var(--glass-lo), var(--glass-shadow-float);
}
/* Floating glass (nav, sheets): same recipe as .float, plus an inner light gradient. */
.bottomnav.glass, .sidebar.glass, .modal.glass {
  -webkit-backdrop-filter: blur(var(--blur-float)) saturate(var(--saturate));
  backdrop-filter: blur(var(--blur-float)) saturate(var(--saturate));
  box-shadow: inset 0 0 0 1px var(--glass-edge), inset 0 1.5px 0 var(--glass-hi), inset 0 -1px 0 var(--glass-lo), var(--glass-shadow-float);
}
.glass.float::before, .bottomnav.glass::before, .sidebar.glass::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(160deg, var(--glass-hi) 0%, transparent 38%, transparent 72%, var(--glass-lo) 100%);
  opacity: .45;
}
:where(.glass.float) { position: relative; border-radius: var(--r-xl); }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass, .glass.strong, .glass.float { background: var(--surface-solid); }
}
@media (prefers-reduced-transparency: reduce) {
  .glass, .glass.strong, .glass.float, .focus { background: var(--surface-solid); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .trow, .card, .card-box, .widget { background: var(--surface-solid); }
}

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100dvh; }
.sidebar {
  display: none; width: var(--sidebar-w); flex: none; padding: 14px 12px 16px; margin: 14px 0 14px 14px;
  border-radius: var(--r-xl); position: sticky; top: 14px; height: calc(100dvh - 28px); overflow-y: auto; flex-direction: column; gap: 3px; scrollbar-width: thin;
}
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 12px 16px 10px; padding-top: calc(10px + env(safe-area-inset-top)); position: sticky; top: 0; z-index: 20; }
.topbar .bar { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; padding: 8px 10px 8px 18px; border-radius: var(--r-pill); min-height: 54px; }
.topbar h1 { font-size: var(--fs-lg); font-weight: 800; margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 10px; }
.topbar .sub { color: var(--text-3); font-weight: 600; font-size: 13px; letter-spacing: 0; }
.content { flex: 1; padding: 6px 16px calc(var(--nav-h) + 34px + env(safe-area-inset-bottom)); }
.content.narrow { max-width: var(--content-max); width: 100%; margin: 0 auto; }
.content.wide { max-width: 1600px; width: 100%; margin: 0 auto; }
.with-panel { display: flex; gap: 18px; align-items: flex-start; }
.with-panel > .content { flex: 1; min-width: 0; }
.side-panel { display: none; }

/* page header tabs (below the top bar) */
.page-tabs { display: flex; gap: 4px; padding: 2px 0 12px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.page-tabs::-webkit-scrollbar { display: none; }
.page-tabs button { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: var(--r-pill); font-weight: 700; font-size: 13.5px; color: var(--text-2); white-space: nowrap; flex: none; transition: background var(--dur) var(--ease), color var(--dur); }
.page-tabs button:hover { background: var(--surface-2); color: var(--text); }
.page-tabs button.active { background: var(--accent-soft); color: var(--accent-ink); }
.page-tabs button .i { width: 16px; height: 16px; }

/* brand + app switcher */
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 12px; font-weight: 800; font-size: 17px; letter-spacing: var(--track-tight); }
.brand .logo { width: 30px; height: 30px; border-radius: 10px; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; box-shadow: 0 6px 14px -6px var(--accent); transition: background var(--dur-slow); }
.brand .logo .i { width: 16px; height: 16px; stroke-width: 2.6; }
.appswitch { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface-2); margin: 0 2px 12px; }
.appswitch button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 4px 6px; border-radius: 11px; font-size: 10.5px; font-weight: 700; color: var(--text-3); transition: background var(--dur) var(--ease), color var(--dur); position: relative; }
.appswitch button .i { width: 18px; height: 18px; }
.appswitch button:hover { color: var(--text); }
.appswitch button.active { background: var(--surface-solid); color: var(--text); box-shadow: var(--shadow-sm); }
.appswitch button.active .i { color: var(--a); }
.appswitch button[data-app="home"] { --a: var(--app-home); } .appswitch button[data-app="tasks"] { --a: var(--app-tasks); }
.appswitch button[data-app="finance"] { --a: var(--app-finance); } .appswitch button[data-app="inventory"] { --a: var(--app-inventory); }
.appswitch button.locked::after { content: ""; position: absolute; right: 6px; top: 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--warn); }
.topbar .appswitch { margin: 0; padding: 3px; border-radius: var(--r-pill); gap: 2px; }
.topbar .appswitch button { width: 36px; height: 36px; padding: 0; border-radius: 50%; flex: none; }
.topbar .appswitch button span { display: none; }
.appswitch button.has-dot::before { content: ""; position: absolute; right: 5px; top: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--surface-2); }
.appswitch button.has-dot.locked::before { display: none; }
/* phones: leave room for the page title (the switcher + actions would otherwise squeeze it to "Übers…") */
@media (max-width: 899px) {
  .topbar { gap: 6px; padding-left: 10px; padding-right: 10px; }
  .topbar .bar { gap: 4px; padding: 6px 6px 6px 14px; }
  .topbar h1 { font-size: 17px; }
  .topbar .appswitch { padding: 2px; gap: 0; }
  .topbar .appswitch button { width: 32px; height: 32px; }
  .topbar .appswitch button .i { width: 17px; height: 17px; }
  .topbar .bar > .btn.icon { width: 34px; height: 34px; }
  .btn.hide-sm { display: none; } /* .btn's inline-flex would otherwise win over .hide-sm */
}

/* sidebar nav */
.navbtn { display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 12px; border-radius: 12px; color: var(--text-2); font-weight: 600; font-size: 14px; text-align: left; transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
.navbtn:hover { background: var(--surface-2); color: var(--text); }
.navbtn.active { background: var(--accent-soft); color: var(--accent-ink); }
.navbtn.active .i { color: var(--accent-ink); }
.navbtn .count { margin-left: auto; font-size: 11.5px; font-weight: 700; color: var(--text-3); background: var(--surface-2); padding: 1px 7px; border-radius: 99px; }
.navbtn.active .count { background: var(--accent); color: var(--accent-text); }
.navsec { margin-top: 18px; padding: 0 12px 6px; font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--text-3); display: flex; align-items: center; justify-content: space-between; }
.navsec button { color: var(--text-3); display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; }
.navsec button:hover { background: var(--surface-2); color: var(--text); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--p, var(--text-3)); flex: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--p, var(--text-3)) 25%, transparent); }
.sidebar .spacer { flex: 1; }
.sidebar .foot { padding: 8px 12px 0; font-size: 11.5px; color: var(--text-3); display: flex; justify-content: space-between; align-items: center; }
.navbtn.primary-add { color: var(--accent-ink); margin-top: 8px; }

/* bottom floating pill nav (phone / tablet) */
.bottomnav { position: fixed; left: 14px; right: 14px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 30; display: flex; align-items: center; height: var(--nav-h); border-radius: var(--r-pill); padding: 6px; }
.bottomnav button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: 100%; border-radius: var(--r-pill); font-size: 10.5px; font-weight: 600; color: var(--text-2); transition: color var(--dur) var(--ease), background var(--dur) var(--ease); min-width: 0; }
.bottomnav button span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.bottomnav button .i { width: 22px; height: 22px; }
.bottomnav button.active { color: var(--accent-ink); background: var(--accent-soft); }
.bottomnav button.fab-slot { flex: 0 0 64px; }
.fab { width: 48px; height: 48px; border-radius: 50%; background: var(--primary); color: var(--primary-text); display: grid; place-items: center; box-shadow: var(--shadow-md); transition: transform var(--dur-fast) var(--ease); }
.fab:active { transform: scale(.94); }
.fab .i { stroke-width: 2.4; width: 24px; height: 24px; }

@media (min-width: 900px) {
  .sidebar { display: flex; }
  .bottomnav { display: none; }
  .content { padding: 6px 22px 40px 22px; }
  .topbar { padding: 14px 22px 8px 22px; }
  .topbar h1 { font-size: var(--fs-xl); }
  .topbar .appswitch { display: none; }
  :root { --nav-h: 0px; }
}
@media (min-width: 1400px) {
  .side-panel { display: flex; flex-direction: column; gap: 18px; width: var(--panel-w); flex: none; margin: 0 22px 0 0; position: sticky; top: 14px; max-height: calc(100dvh - 28px); overflow-y: auto; padding: 18px; border-radius: var(--r-xl); scrollbar-width: thin; }
}

/* ---------- Motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } } @keyframes fadeout { from { opacity: 1 } to { opacity: 0 } }
@keyframes spin { to { transform: rotate(360deg) } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Misc ---------- */
.only-sm { display: inline-flex; } .hide-sm { display: none; }
@media (min-width: 900px) { .only-sm { display: none; } .hide-sm { display: inline; } .btn.hide-sm { display: inline-flex; } }
.btn.only-sm.active { color: var(--accent-ink); }
.offline { position: fixed; top: 0; left: 0; right: 0; z-index: 200; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 14px; padding-top: calc(8px + env(safe-area-inset-top)); background: var(--warn); color: #1a1200; font-size: 13px; font-weight: 700; }
.loading { display: grid; place-items: center; min-height: 50dvh; color: var(--text-3); }
.spinner { width: 24px; height: 24px; border-radius: 50%; border: 2.5px solid var(--border-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; }
