:root {
  --bg: #0B0E10;
  --surface: #151A1D;
  --surface2: #1D2428;
  --line: #2A3237;
  --text: #EEF2F3;
  --text2: #C3CDD1;
  --muted: #95A1A7;
  --accent: #5BE0E6;
  --accent-ink: #04282A;
  --accent-soft: #0F2E31;
  --danger: #FF8A80;
  --display: 'Bebas Neue', 'Impact', sans-serif;
  --body: 'Barlow', system-ui, -apple-system, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--body); font-size: 16px; }
body { min-height: 100vh; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; }

#app { max-width: 640px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
.screen { flex: 1; padding: calc(12px + var(--safe-t)) 16px calc(110px + var(--safe-b)); display: flex; flex-direction: column; gap: 18px; }
.screen.has-footer { padding-bottom: calc(190px + var(--safe-b)); }

/* headers */
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; min-height: 52px; }
.title { font-family: var(--display); font-weight: 400; font-size: 50px; line-height: .9; letter-spacing: 1px; }
.title small { font-size: 28px; color: var(--accent); margin-left: 8px; letter-spacing: .5px; }
.navbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 48px; }
.navbar h1 { font-family: var(--display); font-weight: 400; font-size: 30px; letter-spacing: .5px; text-align: center; }
.navbar .right { justify-self: end; }
.back { background: none; border: 0; color: var(--accent); font-weight: 600; display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding: 0; }
.h2 { font-size: 12px; font-weight: 700; letter-spacing: 1.5px; color: var(--muted); text-transform: uppercase; }
.section { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.wrap { flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.display { font-family: var(--display); font-weight: 400; letter-spacing: .5px; }
.money { font-family: var(--display); font-size: 22px; color: var(--accent); white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }

/* buttons */
.btn { min-height: 48px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-weight: 700; padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); background: transparent; }
.btn.small { min-height: 40px; border-radius: 12px; font-size: 14px; padding: 0 12px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.iconbtn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); display: inline-flex; align-items: center; justify-content: center; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }

.chip { min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--line); background: transparent; color: var(--text2); font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 8px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--surface); padding: 4px; border-radius: 14px; }
.seg button { min-height: 42px; border: 0; border-radius: 10px; background: transparent; color: var(--text2); font-weight: 700; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }

/* cards & lists */
.card { background: var(--surface); border-radius: 16px; padding: 14px; }
.list { background: var(--surface); border-radius: 16px; overflow: hidden; }
.list > * + * { border-top: 1px solid var(--line); }
.item { width: 100%; background: transparent; border: 0; text-align: left; padding: 12px 14px; display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; min-height: 52px; }
.kv { padding: 10px 14px; display: flex; flex-direction: column; gap: 2px; }
.kv .k { font-size: 12px; color: var(--muted); }
.avatar { width: 44px; height: 44px; border-radius: 22px; background: var(--accent-soft); color: var(--accent); font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.avatar.lg { width: 72px; height: 72px; border-radius: 36px; font-family: var(--display); font-size: 34px; font-weight: 400; }
.dot { width: 8px; height: 8px; border-radius: 4px; display: inline-block; flex-shrink: 0; }
.crewtag { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border-radius: 14px; background: var(--bg); font-size: 13px; font-weight: 600; }
.crewtag i { width: 20px; height: 20px; border-radius: 10px; color: #0B0E10; font-style: normal; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.empty { border: 1px dashed var(--line); border-radius: 16px; padding: 22px; text-align: center; color: var(--muted); font-size: 14px; }
.badge { font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; padding: 3px 8px; border-radius: 8px; background: var(--surface2); color: var(--text2); }
.badge.done { background: #173A2A; color: #8FE3B0; }
.badge.cancelled { background: #3A1C1C; color: var(--danger); }
.highlight { background: var(--accent-soft); border: 1px solid #1E5A5E; }

/* forms */
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.field input, .field select, .field textarea, .input {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; min-height: 48px; padding: 10px 12px; color: var(--text); font-size: 16px; font-weight: 500; width: 100%; min-width: 0;
}
.field textarea { resize: vertical; min-height: 84px; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=date], input[type=time] { -webkit-appearance: none; appearance: none; }
.search { display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: 14px; padding: 0 14px; min-height: 48px; color: var(--muted); }
.search input { flex: 1; border: 0; background: transparent; color: var(--text); font-size: 16px; outline: none; min-width: 0; }
.check { width: 24px; height: 24px; border-radius: 7px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; box-shadow: inset 0 0 0 2px #4A555B; color: var(--accent-ink); }
.check.on { background: var(--accent); box-shadow: none; }
.priceinput { width: 84px; text-align: right; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; min-height: 40px; padding: 0 8px; color: var(--accent); font-weight: 700; font-size: 16px; }

/* calendar */
.weekdays, .month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.weekdays { font-size: 12px; font-weight: 600; color: var(--muted); text-align: center; letter-spacing: 1px; margin-bottom: 4px; }
.month { row-gap: 2px; }
.day { height: 54px; border: 0; background: transparent; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--text); }
.day .n { width: 36px; height: 36px; border-radius: 18px; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 500; }
.day.out .n { color: #4F5A60; }
.day.past .n { color: #8A959B; }
.day.today .n { box-shadow: inset 0 0 0 2px var(--accent); color: var(--accent); font-weight: 700; }
.day.sel .n { background: var(--accent); color: var(--accent-ink); font-weight: 700; box-shadow: none; }
.day .dots { display: flex; gap: 3px; height: 6px; }
.day .dots span { width: 6px; height: 6px; border-radius: 3px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.agenda { background: var(--surface); border-radius: 24px; padding: 18px 14px; display: flex; flex-direction: column; gap: 10px; }
.job { display: flex; gap: 12px; background: var(--surface2); border-radius: 16px; padding: 12px 14px; border: 0; width: 100%; text-align: left; color: var(--text); }
.job .bar { width: 4px; border-radius: 2px; flex-shrink: 0; }
.job .time { width: 54px; flex-shrink: 0; }
.job .time b { font-family: var(--display); font-weight: 400; font-size: 22px; line-height: 1; display: block; }
.job.cancelled { opacity: .5; }
.job.cancelled .name { text-decoration: line-through; }

/* tab bar + footers */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: rgba(21, 26, 29, .96); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 6px 8px calc(8px + var(--safe-b)); }
.tabbar nav { max-width: 640px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: center; }
.tab { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; color: #8A969C; font-size: 11px; font-weight: 600; min-height: 48px; justify-content: center; }
.tab.on { color: var(--accent); }
.tab.plus { justify-self: center; width: 56px; height: 56px; border-radius: 18px; background: var(--accent); color: var(--accent-ink); }
.footer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: rgba(21, 26, 29, .98); border-top: 1px solid var(--line); padding: 12px 16px calc(14px + var(--safe-b)); }
.footer > div { max-width: 608px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }

/* message preview */
.bubble { align-self: flex-end; max-width: 88%; background: #2E7CF6; color: #fff; border-radius: 20px 20px 6px 20px; padding: 10px 14px; font-size: 15px; line-height: 1.35; white-space: pre-line; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + var(--safe-b)); z-index: 50; background: var(--text); color: var(--bg); font-weight: 600; padding: 12px 18px; border-radius: 14px; max-width: calc(100% - 32px); box-shadow: 0 6px 24px rgba(0,0,0,.4); }
.toast.err { background: var(--danger); color: #2A0905; }
.banner { background: #2A2210; border: 1px solid #5A4718; color: #F5D58A; border-radius: 14px; padding: 12px 14px; font-size: 14px; display: flex; flex-direction: column; gap: 8px; }
.login { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; gap: 18px; padding: 24px; max-width: 420px; margin: 0 auto; }
.login img { width: 100%; max-width: 340px; align-self: center; }
.color-swatch { width: 36px; height: 36px; border-radius: 18px; border: 2px solid transparent; }
.color-swatch.on { border-color: var(--text); }
.suggest { position: relative; }
.suggest .menu { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 10; background: var(--surface2); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
.banner.club { background: var(--accent-soft); border-color: #1E5A5E; color: var(--text); }
.banner.club b { color: var(--accent); }
.qr { background: #fff; border-radius: 16px; padding: 12px; width: 220px; height: 220px; align-self: center; }
.codeinput { font-size: 28px; letter-spacing: 8px; text-align: center; font-weight: 700; }
.tabbar nav.six { grid-template-columns: repeat(6, minmax(0, 1fr)); }

/* finances */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--surface); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 2px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-family: var(--display); font-size: 32px; line-height: 1.05; color: var(--text); }
.stat .s { font-size: 12px; color: var(--muted); }
.stat.hero { grid-column: 1 / -1; }
.stat.hero .v { font-size: 52px; color: var(--accent); }
.chart { background: var(--surface); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 10px; position: relative; }
.cols { display: flex; align-items: flex-end; gap: 4px; height: 160px; padding-right: 44px; border-bottom: 1px solid var(--line); position: relative; }
.cols .gl { position: absolute; left: 0; right: 0; border-top: 1px dashed #263036; pointer-events: none; }
.cols .gl span { position: absolute; right: 0; top: -7px; width: 40px; text-align: right; font-size: 10px; color: var(--muted); }
.col { position: relative; z-index: 1; flex: 1; min-width: 0; height: 100%; display: flex; align-items: flex-end; justify-content: center; background: none; border: 0; padding: 0; cursor: pointer; }
.col i { display: block; width: 70%; max-width: 28px; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.col.dim i { opacity: .45; }
.col.on i { background: #9BF0F3; }
.xlabels { display: flex; gap: 4px; padding-right: 44px; }
.xlabels span { flex: 1; min-width: 0; text-align: center; font-size: 10px; color: var(--muted); overflow: hidden; }
.tip { background: var(--text); color: var(--bg); border-radius: 10px; padding: 8px 10px; font-size: 13px; font-weight: 600; align-self: flex-start; }
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; font-size: 14px; }
.hbar .track { grid-column: 1 / -1; height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.hbar .track i { display: block; height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; }
.hbar .val { font-weight: 700; white-space: nowrap; }
.hbar .val small { color: var(--muted); font-weight: 500; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; font-weight: 700; padding: 6px 4px; border-bottom: 1px solid var(--line); }
table.data td { padding: 8px 4px; border-bottom: 1px solid var(--line); }
table.data td.n, table.data th.n { text-align: right; white-space: nowrap; }
.tipnote { color: #8FE3B0; font-weight: 700; white-space: nowrap; }
