/* 52 Studio CRM. Palette and type follow 52studio.pl: ink, paper, orange, square corners, uppercase eyebrows. */
:root {
  --ink: #151617; --ink-2: #1d1e20; --paper: #f6f5f1; --white: #fff; --muted: #70716f;
  --line: #dcddd7; --line-2: #c9cec1; --soft: #eaece4; --orange: #ff642d; --orange-dark: #c24111;
  --dark-line: #333435; --danger: #b8321c; --ease: cubic-bezier(.2, .7, .2, 1);
  --tab-h: 66px; --safe: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 15px/1.5 Arial, Helvetica, sans-serif; -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tab-h) + 28px + var(--safe));
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
::selection { background: var(--orange); color: var(--ink); }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 3px; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- header and tabs */
/* Installed on iPhone the status bar overlays the page (black-translucent), so the bar grows by the notch height. */
.appbar {
  position: sticky; top: 0; z-index: 20; height: calc(64px + env(safe-area-inset-top, 0px)); display: flex; align-items: center; gap: 12px;
  padding: env(safe-area-inset-top, 0px) max(16px, calc((100% - 760px) / 2)) 0; background: var(--ink); color: var(--paper); border-bottom: 1px solid var(--dark-line);
}
.brand { display: inline-flex; align-items: center; gap: 11px; }
.brand-digits { font: italic 900 34px/.9 "Arial Black", Arial, sans-serif; letter-spacing: -4px; padding-right: 4px; }
.brand-digits b { color: var(--orange); font-weight: 900; }
.brand-words { display: flex; flex-direction: column; gap: 3px; border-left: 1px solid #565655; padding-left: 11px; font-size: 10px; font-weight: 700; letter-spacing: 2.4px; }
.brand-words span:last-child { font-size: 8px; color: #b7b8b3; letter-spacing: 2.2px; }
.me { margin-left: auto; min-height: 38px; padding: 0 14px; border: 1px solid #545557; background: none; color: var(--paper); font-size: 12px; font-weight: 700; transition: border-color .2s; }
.me:hover { border-color: var(--orange); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex;
  padding: 0 max(4px, calc((100% - 760px) / 2)) var(--safe); background: var(--ink); border-top: 1px solid var(--dark-line);
}
.tab {
  flex: 1; position: relative; height: var(--tab-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  color: #a5a7a0; font-size: 10px; font-weight: 700; letter-spacing: .5px; transition: color .2s;
}
.tab .icon { width: 22px; height: 22px; }
.tab:hover, .tab[aria-current] { color: var(--paper); }
.tab[aria-current]::after { content: ""; position: absolute; top: 0; left: 24%; right: 24%; height: 2px; background: var(--orange); }
.fab-ic { width: 44px; height: 44px; margin-top: -20px; display: grid; place-items: center; background: var(--orange); color: var(--ink); transform: skewX(-8deg); }
.fab-ic .icon { transform: skewX(8deg); stroke-width: 2.4; }
.fab[aria-current]::after { display: none; }
body:not(.owner) .tab[data-tab="team"] { display: none; }

/* ---------- layout and type */
main { width: min(760px, 100% - 32px); margin: 0 auto; padding-top: 26px; }
.splash { padding: 18vh 0; text-align: center; color: var(--muted); }
.title { margin: 0; font-size: 40px; line-height: 1.05; letter-spacing: -2px; font-weight: 700; overflow-wrap: anywhere; }
.title i { color: var(--orange); font-style: normal; }
.title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.sub { margin: 8px 0 22px; color: var(--muted); font-size: 13px; }
.eyebrow {
  display: flex; align-items: center; gap: 12px; margin: 34px 0 14px;
  font-size: 11px; line-height: 1.4; font-weight: 700; letter-spacing: 2.1px; text-transform: uppercase; color: #676b63;
}
.eyebrow::before { content: ""; width: 6px; height: 6px; flex: none; background: var(--orange); }
.back { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 14px; font-size: 12px; font-weight: 700; color: var(--muted); }
.back:hover { color: var(--orange-dark); }
.card { background: var(--white); border: 1px solid var(--line); padding: 18px; }
.card + .card, .order + .card, form + .card { margin-top: 10px; }
.hint { margin: 10px 0 0; font-size: 12px; line-height: 1.6; color: var(--muted); }
.hint.late { color: var(--danger); font-weight: 700; }
.empty { margin: 0; padding: 26px 18px; border: 1px dashed var(--line-2); text-align: center; font-size: 13px; color: var(--muted); }
.link { padding: 0; border: 0; background: none; font-size: 12px; font-weight: 700; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--orange-dark); }
.link.danger { color: var(--danger); }

/* ---------- buttons */
.btn {
  width: 100%; min-height: 52px; padding: 0 20px; display: flex; align-items: center; justify-content: center; gap: 14px;
  border: 1px solid transparent; background: none; font-size: 13px; font-weight: 700; text-align: center;
  transition: background .2s, border-color .2s, transform .2s;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .6; cursor: default; transform: none; }
.btn.primary { background: var(--orange); color: #101112; }
.btn.primary:hover { background: #ff7c4c; }
.btn.ghost { background: var(--white); border-color: var(--line-2); }
.btn.ghost:hover { border-color: var(--orange); }
.btn.sm { min-height: 42px; padding: 0 14px; font-size: 12px; }
main > .btn, form > .btn { margin-top: 12px; }
.btn-row { display: flex; gap: 10px; margin-top: 10px; }
.done-note { min-height: 52px; display: grid; place-items: center; background: var(--soft); font-size: 13px; font-weight: 700; color: #5d6057; }
.sticky { position: sticky; bottom: calc(var(--tab-h) + 12px + var(--safe)); z-index: 5; margin-top: 22px; }

/* ---------- KPI, bars, rows */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { min-height: 124px; display: flex; flex-direction: column; gap: 6px; padding: 16px; background: var(--white); border: 1px solid var(--line); transition: border-color .2s, transform .2s; }
a.kpi:hover { border-color: var(--orange); transform: translateY(-2px); }
.kpi.hero { grid-column: 1 / -1; background: var(--ink); border-color: var(--ink); color: var(--paper); }
.k-label { font-size: 10px; font-weight: 700; letter-spacing: 1.6px; text-transform: uppercase; color: #6b6f65; }
.hero .k-label { color: #b9bbb3; }
.kpi b { font-size: 30px; line-height: 1.05; letter-spacing: -1.2px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi.hero b { font-size: 44px; letter-spacing: -2px; color: var(--white); }
.k-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.hero .k-foot { color: #bcbeb7; }
.hero .k-foot .icon { color: var(--orange); }

.bars { height: 180px; display: flex; gap: 8px; padding: 18px 16px 12px; }
.bar { flex: 1; display: grid; grid-template-rows: 1fr auto; gap: 6px; text-align: center; }
.bar div { display: flex; align-items: flex-end; }
.bar i { width: 100%; min-height: 4px; background: var(--ink); }
.bar.top i { background: var(--orange); }
.bar span { font-size: 10px; font-weight: 700; letter-spacing: 1px; color: var(--muted); }

.row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid #e0e3da; }
.row:first-child { border-top: 0; padding-top: 0; }
.row:last-child { padding-bottom: 0; }
.avatar { width: 40px; height: 40px; flex: none; display: grid; place-items: center; background: var(--ink); color: var(--paper); font-size: 13px; font-weight: 700; letter-spacing: .5px; }
.avatar.owner { background: var(--orange); color: var(--ink); }
.r-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.r-main b { font-size: 15px; font-weight: 700; }
.r-main > span { font-size: 12px; color: var(--muted); }
.r-main .acts { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 6px; }
.r-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.r-amt { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row.total .r-amt { font-size: 20px; }
.share { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.share input { width: 82px; min-height: 38px; padding: 6px 8px; text-align: right; font-size: 14px; }

/* ---------- orders */
.order { display: flex; align-items: center; gap: 14px; margin-top: 10px; padding: 14px; background: var(--white); border: 1px solid var(--line); transition: border-color .2s; }
.order:hover { border-color: var(--orange); }
.plate {
  flex: none; width: 96px; padding: 6px 6px 6px 14px; position: relative; border: 1.5px solid var(--ink); background: var(--white);
  font: 700 12px/1.2 Arial, sans-serif; letter-spacing: .8px; text-align: center; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.plate::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 8px; background: #2a4fb3; } /* EU band of a Polish plate */
.o-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.o-main b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.o-main span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.o-right { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.o-right b { font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.badge { display: inline-flex; align-items: center; padding: 4px 8px; border: 1px solid var(--line-2); font-size: 10px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: #55594f; white-space: nowrap; }
.s-in_progress { background: var(--orange); border-color: var(--orange); color: var(--ink); }
.s-ready { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.s-closed { background: var(--soft); border-color: var(--soft); color: #5d6057; }

.chips { display: flex; gap: 8px; margin-bottom: 6px; padding-bottom: 4px; overflow-x: auto; scrollbar-width: none; }
.chip { flex: none; min-height: 38px; padding: 0 14px; display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line-2); background: var(--white); font-size: 12px; font-weight: 700; }
.chip span { font-size: 11px; font-weight: 400; color: var(--muted); }
.chip:hover { border-color: var(--orange); }
.chip.active { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip.active span { color: var(--orange); }

.kv { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-top: 1px solid #e0e3da; font-size: 14px; }
.kv:first-child { border-top: 0; padding-top: 0; }
.kv:last-child { padding-bottom: 0; }
.kv > span { color: var(--muted); }
.kv > b { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kv a { text-decoration: underline; text-underline-offset: 3px; }
.note { margin: 0; font-size: 14px; line-height: 1.6; white-space: pre-wrap; }

/* ---------- forms */
.field { display: block; margin-top: 14px; }
.field:first-child { margin-top: 0; }
.field > span { display: block; margin-bottom: 7px; font-size: 10px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: #676b63; }
input, select, textarea {
  width: 100%; min-height: 48px; padding: 12px 14px; border: 1px solid var(--line-2); border-radius: 0;
  background: var(--paper); font-size: 16px; appearance: none;
}
textarea { min-height: 92px; resize: vertical; line-height: 1.5; }
select {
  padding-right: 38px;
  background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23151617' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center / 16px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); background-color: var(--white); }
input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; padding: 0; appearance: auto; accent-color: var(--orange); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.two > .field, .two > .field:first-child { margin-top: 14px; }
.card > .two:first-child > .field { margin-top: 0; }
.team-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid #e0e3da; }
.team-row label { flex: 1; display: flex; align-items: center; gap: 10px; font-size: 14px; }
.team-row input[type="number"] { width: 92px; min-height: 40px; padding: 8px 10px; text-align: right; }

/* ---------- damage map */
.types { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 12px; }
.type { padding: 10px 4px; display: flex; flex-direction: column; align-items: center; gap: 6px; border: 1px solid var(--line-2); background: var(--white); font-size: 11px; font-weight: 700; }
.type i, .legend i { width: 12px; height: 12px; }
.type[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.diagram { display: grid; place-items: center; padding: 18px; background: var(--ink); }
.stage { position: relative; width: min(240px, 72%); aspect-ratio: 300 / 520; }
.stage svg { display: block; width: 100%; height: 100%; }
.editable .stage { cursor: crosshair; touch-action: manipulation; }
.pin { position: absolute; width: 26px; height: 26px; margin: -13px 0 0 -13px; padding: 0; display: grid; place-items: center; border: 2px solid var(--ink); color: var(--ink); font-size: 12px; font-weight: 700; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dmg { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 13px; }
.num { width: 24px; height: 24px; flex: none; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--ink); }
.dmg input { min-height: 40px; padding: 8px 10px; font-size: 14px; }
.rm { width: 40px; height: 40px; flex: none; border: 1px solid var(--line-2); background: var(--white); font-size: 18px; }
.rm:hover { border-color: var(--danger); color: var(--danger); }

/* ---------- photos */
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo {
  position: relative; aspect-ratio: 1; padding: 6px; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: var(--soft); border: 1px solid var(--line); font-size: 11px; font-weight: 700; color: var(--muted); text-align: center;
}
.photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo .tag { position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 6px; background: rgba(21, 22, 23, .8); color: var(--paper); font-size: 10px; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photo.add { border-style: dashed; border-color: var(--line-2); background: var(--white); }
.photo.add:hover { border-color: var(--orange); color: var(--ink); }
.photo.add .icon { width: 24px; height: 24px; }
.photo.sel { outline: 3px solid var(--orange); outline-offset: -3px; }
.viewer { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(10, 10, 11, .94); cursor: zoom-out; }
.viewer img { max-width: 100%; max-height: 100%; }
.canvas-card { padding: 10px; }
.canvas-card canvas { display: block; width: 100%; height: auto; }

/* ---------- calendar and analytics */
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.cal-head b { flex: 1; font-size: 17px; letter-spacing: -.3px; }
.cal-head a { min-width: 40px; min-height: 40px; padding: 0 12px; display: grid; place-items: center; border: 1px solid var(--line-2); font-size: 12px; font-weight: 700; }
.cal-head a:hover { border-color: var(--orange); }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.dow { padding: 4px 0; text-align: center; font-size: 10px; font-weight: 700; letter-spacing: 1px; color: var(--muted); }
.cal-day { position: relative; aspect-ratio: 1; display: grid; place-items: center; border: 1px solid var(--line); background: var(--paper); font-size: 14px; font-weight: 700; }
.cal-day:hover { border-color: var(--orange); }
.cal-day.blank { border: 0; background: none; }
.cal-day.today { border-color: var(--ink); }
.cal-day.sel { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.cal-day i { position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; padding: 0 3px; background: var(--orange); color: var(--ink); font: 700 10px/16px Arial, sans-serif; font-style: normal; }
.dbars { height: 200px; display: flex; align-items: flex-end; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.dbar { flex: 0 0 32px; height: 100%; padding: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; border: 0; background: none; }
.dbar small { font-size: 9px; color: var(--muted); writing-mode: vertical-rl; transform: rotate(180deg); }
.dbar i { width: 100%; background: var(--ink); }
.dbar.sel i, .dbar:hover i { background: var(--orange); }
.dbar span { font-size: 11px; font-weight: 700; }
.install { display: flex; align-items: flex-start; gap: 14px; }
.install img { flex: none; }
.install p { margin: 0; font-size: 13px; line-height: 1.6; color: #55594f; }
.task b { white-space: pre-wrap; }
.task.done { opacity: .6; }
.task a { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- login / first run */
body.guest { background: var(--ink); color: var(--paper); padding-bottom: 0; }
body.guest .tabbar, body.guest .me { display: none; }
body.guest main { width: min(1160px, 100% - 40px); }
body.guest .appbar { padding-inline: max(20px, calc((100% - 1160px) / 2)); }
.auth { display: flex; flex-direction: column; padding: 28px 0 48px; }
.mark { order: -1; display: flex; margin: 0 0 30px -6px; font: italic 900 150px/.9 "Arial Black", Arial, sans-serif; letter-spacing: -16px; user-select: none; }
.mark span { color: #eeeeea; text-shadow: 0 3px 0 #acada6; }
.mark b { color: var(--orange); font-weight: 900; text-shadow: 0 3px 0 #ad3c16; }
.auth .eyebrow { margin: 0 0 18px; color: #c8c9c2; }
.hero-title { margin: 0 0 16px; font-size: clamp(42px, 11vw, 78px); line-height: 1.03; letter-spacing: -3px; font-weight: 700; }
.hero-title span { color: var(--orange); }
.hero-sub { max-width: 420px; margin: 0 0 26px; font-size: 14px; line-height: 1.8; color: #bcbeb7; }
.auth-form { max-width: 420px; padding-top: 24px; border-top: 1px solid var(--dark-line); }
.auth .field > span { color: #c1c4bb; }
.auth input { background: var(--ink-2); border-color: #3c3d3f; color: var(--paper); }
.auth input:focus { background: var(--ink-2); border-color: var(--orange); }
.err { min-height: 20px; margin: 12px 0 0; font-size: 13px; color: #ff8a63; }
.racing { display: flex; gap: 6px; margin-top: 18px; }
.racing i { width: 25px; height: 8px; background: var(--orange); transform: skewX(-24deg); }
.racing i:nth-child(2) { opacity: .5; }
.racing i:nth-child(3) { opacity: .2; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + 24px + var(--safe)); z-index: 60; max-width: calc(100% - 32px);
  padding: 12px 16px; background: var(--ink); color: var(--paper); border-left: 4px solid var(--orange);
  font-size: 13px; font-weight: 700; opacity: 0; pointer-events: none; transform: translate(-50%, 16px); transition: opacity .25s var(--ease), transform .25s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 380px) {
  .title { font-size: 34px; }
  .plate { width: 84px; }
  .kpi b { font-size: 24px; }
}
@media (min-width: 900px) {
  body { padding-bottom: 48px; }
  .tabbar { position: sticky; top: 64px; bottom: auto; border-top: 0; border-bottom: 1px solid var(--dark-line); }
  .tab { height: 52px; flex-direction: row; gap: 8px; font-size: 12px; }
  .tab .icon { width: 18px; height: 18px; }
  .tab[aria-current]::after { top: auto; bottom: 0; }
  .fab-ic { width: 30px; height: 30px; margin: 0; }
  .sticky { bottom: 16px; }
  .toast { bottom: 28px; }
  .title { font-size: 52px; letter-spacing: -2.4px; }
  .kpis { grid-template-columns: 1.3fr 1fr 1fr; }
  .kpi.hero { grid-column: auto; }
  .auth { display: grid; grid-template-columns: 1.1fr 1fr; align-items: center; gap: 40px; min-height: calc(100vh - 64px); padding: 40px 0; }
  .mark { order: 0; justify-self: center; margin: 0; font-size: 300px; letter-spacing: -32px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
