:root {
  --bg: #f4f4f7; --surface: #ffffff; --surface-2: #f0f0f5; --text: #17171c; --muted: #6e6e7a;
  --line: rgba(20, 20, 40, .08); --accent: #4f46e5; --accent-2: #7c3aed; --accent-soft: #eeedfd;
  --on-accent: #ffffff; --warn: #b45309; --warn-soft: #fff7e8; --danger: #dc2626; --danger-soft: #fdeeee;
  --ok: #047857; --ok-soft: #e8f7f0;
  --shadow: 0 1px 2px rgba(20, 20, 40, .04), 0 8px 24px rgba(20, 20, 40, .06);
  --radius: 20px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0c11; --surface: #16161d; --surface-2: #1f1f28; --text: #ededf2; --muted: #9a9aa8;
    --line: rgba(255, 255, 255, .08); --accent: #8b85ff; --accent-2: #b48cff; --accent-soft: #23223a;
    --on-accent: #0c0c11; --warn: #fbbf24; --warn-soft: #2a2113; --danger: #f87171; --danger-soft: #2a1515;
    --ok: #34d399; --ok-soft: #10251d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
       font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
       font-feature-settings: "tnum" 1, "cv11" 1; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sprite { display: none; }
.hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* layout: bottom tab bar on narrow screens, sidebar on wide ones; without a session one centred column */
.app { min-height: 100vh; }
.side { display: none; }
.content { padding: 18px 18px calc(96px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }
.top { display: flex; align-items: center; justify-content: space-between; margin: 6px 2px 18px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; letter-spacing: -.02em; }
.logo { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; color: #fff; font-weight: 800;
        background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; font-weight: 700;
          background: var(--accent-soft); color: var(--accent); flex: none; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around;
        padding: 10px 12px calc(14px + env(safe-area-inset-bottom));
        background: color-mix(in srgb, var(--surface) 88%, transparent);
        backdrop-filter: blur(16px); border-top: 1px solid var(--line); }
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: .72rem; color: var(--muted); padding: 4px 14px; border-radius: 14px; }
.tabs a.on { color: var(--accent); font-weight: 600; }
.tabs a.on svg { background: var(--accent-soft); border-radius: 12px; padding: 4px 14px; width: 54px; height: 30px; }

@media (min-width: 900px) {
  .app.with-side { display: grid; grid-template-columns: 220px 1fr; }
  .side { display: block; padding: 22px 14px; border-right: 1px solid var(--line); background: var(--surface); }
  .side .brand { margin: 0 8px 26px; }
  .side a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; color: var(--muted); font-weight: 550; margin-bottom: 4px; }
  .side a.on { background: var(--accent-soft); color: var(--accent); }
  .side .who { margin-top: 40px; display: flex; align-items: center; gap: 10px; padding: 0 8px; font-size: .85rem; }
  .side .who small { display: block; color: var(--muted); font-size: .75rem; }
  .with-side .content { padding: 26px 30px; max-width: 1080px; margin: 0; }
  .top, .tabs { display: none; }
  .cols { display: grid; grid-template-columns: 340px 1fr; gap: 20px; align-items: start; }
}

h1 { margin: 0 0 16px; font-size: 1.5rem; letter-spacing: -.03em; }

/* hero */
.hero { border-radius: var(--radius); padding: 18px 20px; color: #fff; margin-bottom: 16px;
        background: radial-gradient(120% 140% at 100% 0%, var(--accent-2) 0%, var(--accent) 55%, #3730a3 100%); }
@media (prefers-color-scheme: dark) { .hero { background: radial-gradient(120% 140% at 100% 0%, #6d28d9 0%, #4338ca 55%, #1e1b4b 100%); } }
.hero small { opacity: .8; font-size: .8rem; }
.hero .big { font-size: 2.2rem; font-weight: 750; letter-spacing: -.03em; line-height: 1.1; margin-top: 2px; }
.hero .big span { font-size: 1rem; font-weight: 500; opacity: .85; margin-left: 4px; }
.hero .meta { display: flex; gap: 16px; margin-top: 10px; font-size: .85rem; opacity: .92; }

/* cards and forms */
.card { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; border: 1px solid var(--line); }
.card h3 { margin: 0 0 12px; font-size: 1rem; letter-spacing: -.01em; }
.card.danger { background: var(--danger-soft); box-shadow: none; border: 0; }
.card.danger h3 { color: var(--danger); }
.field { margin-bottom: 12px; display: block; }
.field > span { display: block; font-size: .78rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid transparent;
                          border-radius: 14px; padding: 13px 14px; min-height: 48px; min-width: 0; outline: none; }
/* Safari on the iPhone gives a date field a fixed width that ignores width: 100%, and centres its text. */
input[type="date"] { -webkit-appearance: none; appearance: none; display: block; }
input::-webkit-date-and-time-value { text-align: left; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 4px var(--accent-soft); }
textarea { min-height: 76px; resize: vertical; }
/* minmax(0, …): a column never grows past half because of its content, such as a date field. */
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 359px) { .two { grid-template-columns: minmax(0, 1fr); gap: 0; } }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips input { position: absolute; opacity: 0; pointer-events: none; width: 1px; }
.chips label { padding: 9px 14px; border-radius: 999px; background: var(--surface-2); font-weight: 600; font-size: .9rem; cursor: pointer; }
.chips input:checked + label { background: var(--accent); color: var(--on-accent); }
.chips input:focus-visible + label { box-shadow: 0 0 0 3px var(--accent-soft); }
.chips .other { flex: 1; min-width: 90px; }
.chips .other input { position: static; opacity: 1; pointer-events: auto; width: 100%; min-height: 40px; padding: 8px 12px; border-radius: 999px; }

.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 52px; border: 0; border-radius: 16px;
       font: 650 1rem ui-sans-serif, system-ui, sans-serif; cursor: pointer; color: var(--on-accent);
       background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn.quiet { background: var(--surface-2); color: var(--text); box-shadow: none; }
.btn.danger { background: var(--danger); color: #fff; box-shadow: none; }
.btn.small { min-height: 40px; font-size: .88rem; padding: 0 12px; white-space: nowrap; width: auto; }
.btn + .btn { margin-top: 10px; }
.actions { display: flex; gap: 8px; margin-top: 10px; }
.actions .btn + .btn { margin-top: 0; }
.gap { height: 18px; }

.toast { display: flex; gap: 10px; align-items: center; background: var(--ok-soft); color: var(--ok); border-radius: 16px; padding: 12px 14px; margin-bottom: 16px; font-size: .88rem; font-weight: 550; }
.toast svg { width: 20px; height: 20px; flex: none; }
.note { display: flex; gap: 10px; background: var(--warn-soft); color: var(--warn); border-radius: 16px; padding: 12px 14px; margin-bottom: 16px; font-size: .88rem; }
.note svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.note b { color: var(--text); }
.note.error { background: var(--danger-soft); color: var(--danger); }

/* entries */
.sect { display: flex; justify-content: space-between; align-items: baseline; margin: 22px 4px 10px; }
.sect h2 { margin: 0; font-size: 1.05rem; letter-spacing: -.01em; }
.sect small { color: var(--muted); }
.entry { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 16px; }
.entry + .entry { border-top: 1px solid var(--line); border-radius: 0; }
.date { width: 46px; flex: none; text-align: center; border-radius: 12px; background: var(--surface-2); padding: 6px 0; line-height: 1.1; }
.date b { display: block; font-size: 1.05rem; }
.date small { font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.entry .what { flex: 1; min-width: 0; }
.entry .what div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 550; }
.entry .what small { color: var(--muted); font-size: .8rem; }
.pill { font-weight: 700; font-size: .88rem; background: var(--accent-soft); color: var(--accent); padding: 5px 10px; border-radius: 999px; white-space: nowrap; }
.more { color: var(--muted); padding: 6px; border-radius: 10px; }
.more svg { width: 18px; height: 18px; }
.entry-list { padding: 4px; }
.empty { color: var(--muted); padding: 12px; margin: 0; }

/* report */
.seg { display: flex; background: var(--surface-2); border-radius: 14px; padding: 4px; margin-bottom: 14px; overflow-x: auto; }
.seg a { flex: 1; text-align: center; padding: 9px; border-radius: 10px; font-weight: 600; font-size: .9rem; color: var(--muted); white-space: nowrap; }
.seg a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.month { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.month b { font-size: 1.15rem; letter-spacing: -.02em; }
.month .center { text-align: center; }
.circle { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); box-shadow: var(--shadow); border: 1px solid var(--line); }
.circle svg { width: 18px; height: 18px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 14px; box-shadow: var(--shadow); }
.stat small { color: var(--muted); font-size: .76rem; font-weight: 600; }
.stat div { font-size: 1.5rem; font-weight: 750; letter-spacing: -.03em; margin-top: 2px; }
.stat div span { font-size: .85rem; color: var(--muted); font-weight: 500; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 650; padding: 5px 10px; border-radius: 999px; background: var(--ok-soft); color: var(--ok); }
.badge.open { background: var(--surface-2); color: var(--muted); }
.badge svg { width: 14px; height: 14px; }
.muted { color: var(--muted); font-size: .82rem; }

/* invoices */
.inv { display: flex; align-items: center; gap: 12px; padding: 12px; }
.inv + .inv { border-top: 1px solid var(--line); }
.doc { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.doc.grey { background: var(--surface-2); color: var(--muted); }
.inv .what { flex: 1; }
.inv .what b { display: block; }
.inv .what small { color: var(--muted); font-size: .8rem; }
.dl { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); }
.dl svg { width: 18px; height: 18px; }

/* sign-out */
button.avatar { border: 0; padding: 0; font-family: inherit; cursor: pointer; }
.side .out { margin: 14px 8px 0; }

/* sign-in and invitation */
.welcome { text-align: center; margin: 12vh 0 24px; }
.welcome .logo.big { width: 64px; height: 64px; border-radius: 20px; font-size: 1.8rem; margin: 0 auto 14px; }
.welcome .name { font-size: 1.5rem; font-weight: 750; letter-spacing: -.03em; }
.center { text-align: center; }
.below { margin: 12px 0 0; }
.card .note { margin: 12px 0 0; }
[hidden] { display: none !important; }

/* devices */
.dl.remove { color: var(--danger); }
.link { display: flex; gap: 14px; align-items: center; }
.qr { flex: none; background: #fff; border-radius: 10px; line-height: 0; }
.qr svg { width: auto; height: auto; stroke-width: 1; stroke-linecap: butt; stroke-linejoin: miter; }
.link input { font-size: .8rem; }

/* settings, profile and clients */
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); font-weight: 600; font-size: .9rem; margin: 0 0 8px; }
.back svg { width: 18px; height: 18px; }
.lead { margin: -8px 0 16px; }
.lead b { color: var(--text); }
a.inv { color: inherit; }
.warntext { color: var(--warn) !important; }
.check { display: flex; gap: 10px; align-items: center; font-size: .9rem; }
.check input { width: 20px; min-height: 20px; height: 20px; accent-color: var(--accent); }
.empty a { color: var(--accent); font-weight: 600; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
