/* ===== DentalWorkshop CRM — mobile PWA (brutalist B/W) ===== */
:root {
  --bg: #0a0a0a;
  --card: #141414;
  --elev: #1e1e1e;
  --text: #f0f0f0;
  --soft: #b8b8b8;
  --dim: #6a6a6a;
  --line: #262626;
  --line2: #3a3a3a;
  --inv-bg: #f0f0f0;
  --inv-tx: #0a0a0a;
  --danger: #ff3b30;
  --ok: #34c759;
  --warn: #ffcc00;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: var(--sans); font-size: 15px;
  overscroll-behavior-y: none;
}
input, textarea, button, select { font-family: inherit; }
button { cursor: pointer; }
/* hidden всегда скрывает — иначе display:flex у .login-view/.sheet-backdrop
   перебивает атрибут [hidden], и оверлеи висят поверх экрана входа. */
[hidden] { display: none !important; }

/* ===== LOGIN ===== */
.login-view {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 24px; padding-top: calc(24px + var(--safe-t));
}
.login-card { width: 100%; max-width: 420px; }
.brand { display: flex; align-items: center; gap: 8px; margin-bottom: 28px; }
.brand-hash { font-family: var(--mono); font-weight: 800; color: var(--dim); font-size: 20px; }
.brand-name { font-family: var(--mono); font-weight: 700; letter-spacing: 1px; font-size: 13px; }
.login-title { font-weight: 900; font-size: 40px; letter-spacing: 1px; }
.login-sub { color: var(--dim); font-family: var(--mono); font-size: 12px; margin: 6px 0 28px; }
.login-error { color: var(--danger); font-family: var(--mono); font-size: 12px; margin-top: 12px; min-height: 16px; }

.field-label { display: block; font-family: var(--mono); font-size: 11px; font-weight: 700; color: var(--dim); letter-spacing: .5px; margin: 14px 0 6px; }
.field {
  width: 100%; background: var(--card); color: var(--text);
  border: 1px solid var(--line2); border-radius: 0; padding: 14px;
  font-size: 16px; outline: none;
}
.field:focus { border-color: var(--inv-bg); }
.field-area { min-height: 84px; resize: vertical; }
select.field { appearance: none; -webkit-appearance: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn-primary {
  width: 100%; background: var(--inv-bg); color: var(--inv-tx);
  border: none; padding: 15px; font-weight: 800; letter-spacing: .5px; font-size: 15px; margin-top: 22px;
}
.btn-primary:active { opacity: .85; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--line2); padding: 13px 16px; font-weight: 700; }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); padding: 13px 16px; font-weight: 700; }
.sheet-foot .btn-primary, .sheet-foot .btn-ghost { width: auto; margin-top: 0; }

/* ===== APP SHELL ===== */
.app-view { min-height: 100dvh; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg); border-bottom: 1px solid var(--line);
  padding: calc(12px + var(--safe-t)) 16px 12px;
}
.topbar-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tb-hash { font-family: var(--mono); color: var(--dim); font-weight: 800; }
.tb-title { font-weight: 900; font-size: 20px; letter-spacing: .5px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-chip { font-family: var(--mono); font-size: 11px; color: var(--soft); border: 1px solid var(--line2); padding: 4px 8px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-icon { background: transparent; border: none; color: var(--soft); font-size: 20px; padding: 4px 6px; }

.sync-bar { display: flex; align-items: center; gap: 8px; padding: 6px 16px; font-family: var(--mono); font-size: 10px; color: var(--dim); border-bottom: 1px solid var(--line); }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); }
.sync-dot.on { background: var(--ok); }
.sync-dot.off { background: var(--danger); }

.page { padding: 12px 12px calc(150px + var(--safe-b)); }

.search-row { margin-bottom: 10px; }
.search-input { width: 100%; background: var(--card); border: 1px solid var(--line2); color: var(--text); font-family: var(--mono); font-size: 14px; padding: 12px; outline: none; }
.search-input:focus { border-color: var(--inv-bg); }

.filter-row { display: flex; gap: 6px; margin-bottom: 10px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.chip { background: var(--card); border: 1px solid var(--line2); color: var(--soft); font-family: var(--mono); font-size: 11px; font-weight: 700; padding: 8px 12px; white-space: nowrap; }
.chip-active { background: var(--inv-bg); color: var(--inv-tx); border-color: var(--inv-bg); }

.mini-select { background: var(--card); border: 1px solid var(--line2); color: var(--soft); font-family: var(--mono); font-size: 11px; font-weight: 700; padding: 8px 10px; white-space: nowrap; outline: none; appearance: none; -webkit-appearance: none; max-width: 48vw; }
.mini-select:focus { border-color: var(--inv-bg); }

.count-line { font-family: var(--mono); font-size: 11px; color: var(--dim); margin: 0 2px 10px; }

/* ===== TABS ===== */
.tabs { display: flex; gap: 0; margin-bottom: 12px; border: 1px solid var(--line2); }
.tab { flex: 1; background: transparent; border: none; border-right: 1px solid var(--line2); color: var(--dim); font-family: var(--mono); font-size: 11px; font-weight: 800; padding: 11px 4px; letter-spacing: .3px; }
.tab:last-child { border-right: none; }
.tab-active { background: var(--inv-bg); color: var(--inv-tx); }

/* ===== SEGMENTED ===== */
.seg { display: flex; gap: 0; border: 1px solid var(--line2); margin-bottom: 4px; }
.seg-btn { flex: 1; background: transparent; border: none; border-right: 1px solid var(--line2); color: var(--dim); font-family: var(--mono); font-size: 11px; font-weight: 800; padding: 10px 4px; }
.seg-btn:last-child { border-right: none; }
.seg-active { background: var(--inv-bg); color: var(--inv-tx); }

/* ===== LIST + generic cards ===== */
.list { display: flex; flex-direction: column; gap: 8px; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-left-width: 3px; padding: 13px 14px; display: flex; align-items: center; gap: 12px;
}
.card:active { background: var(--elev); }
.card-main { min-width: 0; flex: 1; }
.card-name { font-weight: 800; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-sub { font-family: var(--mono); font-size: 12px; color: var(--dim); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-pills { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.card-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.badge-nr { font-family: var(--mono); font-size: 9px; font-weight: 800; color: var(--inv-tx); background: var(--danger); padding: 2px 6px; }
.tag-pill { font-family: var(--mono); font-size: 10px; color: var(--soft); border: 1px solid var(--line2); padding: 2px 6px; }
.pill { font-family: var(--mono); font-size: 10px; color: var(--soft); border: 1px solid var(--line2); padding: 2px 6px; white-space: nowrap; }
.pill-danger { color: var(--inv-tx); background: var(--danger); border-color: var(--danger); font-weight: 800; }
.pill-ok { color: var(--inv-tx); background: var(--ok); border-color: var(--ok); font-weight: 800; }
.pill-warn { color: var(--inv-tx); background: var(--warn); border-color: var(--warn); font-weight: 800; }

/* column card for tasks/events */
.card-col { display: block; }
.card-col .row-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-col .eyebrow { font-family: var(--mono); font-size: 10px; color: var(--dim); font-weight: 700; }
.card-col .card-name { white-space: normal; margin-top: 4px; }
.card-col .card-desc { font-size: 13px; color: var(--soft); margin-top: 4px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card-col .meta-row { display: flex; flex-wrap: wrap; gap: 5px 10px; margin-top: 8px; font-family: var(--mono); font-size: 11px; color: var(--dim); }
.card-col .meta-row b { color: var(--soft); font-weight: 700; }
.card-x { background: transparent; border: none; color: var(--dim); font-size: 20px; line-height: 1; padding: 0 2px; }

.empty { text-align: center; color: var(--dim); font-family: var(--mono); font-size: 13px; padding: 48px 0; }

/* ===== DASHBOARD ===== */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); padding: 14px; }
.tile-inv { background: var(--inv-bg); color: var(--inv-tx); }
.tile-num { font-size: 30px; font-weight: 900; line-height: 1; }
.tile-lbl { font-family: var(--mono); font-size: 10px; font-weight: 800; margin-top: 8px; letter-spacing: .3px; }
.tile-sub { font-family: var(--mono); font-size: 10px; color: var(--dim); margin-top: 3px; }
.tile-inv .tile-sub { color: #555; }

.panel { background: var(--card); border: 1px solid var(--line); padding: 14px; margin-bottom: 10px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.panel-title { font-weight: 800; font-size: 13px; letter-spacing: .3px; }
.panel-badge { font-family: var(--mono); font-size: 10px; color: var(--dim); }

.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: block; }
.bar-head { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11px; margin-bottom: 4px; }
.bar-head .bl { color: var(--soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 62%; }
.bar-head .bv { color: var(--dim); }
.bar-track { height: 6px; background: var(--elev); }
.bar-fill { height: 6px; background: var(--inv-bg); }

.periods { display: flex; flex-direction: column; gap: 10px; }
.period-row { display: flex; align-items: baseline; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.period-lbl { font-family: var(--mono); font-size: 12px; color: var(--soft); }
.period-val { font-size: 22px; font-weight: 900; }

/* ===== BOTTOM NAV ===== */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: var(--bg); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.nav-btn { flex: 1; background: transparent; border: none; color: var(--dim); display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 10px 0 8px; }
.nav-btn.nav-active { color: var(--text); }
.nav-ic { font-size: 18px; }
.nav-lbl { font-family: var(--mono); font-size: 10px; font-weight: 700; }

/* ===== FAB ===== */
.fab {
  position: fixed; z-index: 21; right: 16px; bottom: calc(72px + var(--safe-b));
  width: 56px; height: 56px; border: none; background: var(--inv-bg); color: var(--inv-tx);
  display: flex; align-items: center; justify-content: center;
  font-size: 34px; font-weight: 300; line-height: 1; padding: 0 0 3px; box-shadow: 0 6px 20px rgba(0,0,0,.5);
}
.fab:active { opacity: .85; }

/* ===== SHEET ===== */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; }
.sheet { width: 100%; max-height: 94dvh; background: var(--bg); border-top: 1px solid var(--line2); display: flex; flex-direction: column; animation: slideup .18s ease-out; }
@keyframes slideup { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 16px; border-bottom: 1px solid var(--line); }
.sheet-title { font-weight: 900; font-size: 16px; letter-spacing: .5px; }
.sheet-close { background: transparent; border: none; color: var(--soft); font-size: 26px; line-height: 1; padding: 0 4px; }
.sheet-body { padding: 16px; overflow-y: auto; }
.sheet-foot { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--line); }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px calc(14px + var(--safe-b)); }
.sheet-actions:empty { display: none; }
.sheet-actions button { flex: 1; min-width: 45%; padding: 13px; font-weight: 800; font-family: var(--mono); font-size: 12px; border: 1px solid var(--line2); background: transparent; color: var(--text); }
.act-primary { background: var(--inv-bg) !important; color: var(--inv-tx) !important; border-color: var(--inv-bg) !important; }
.act-warn { color: var(--warn) !important; border-color: var(--warn) !important; }
.foot-spacer { flex: 1; }
.checkbox-row { display: flex; align-items: center; gap: 10px; margin-top: 18px; font-size: 15px; }
.checkbox-row input { width: 20px; height: 20px; accent-color: var(--inv-bg); }
.status-line { font-family: var(--mono); font-size: 11px; font-weight: 800; padding: 8px 10px; border: 1px solid var(--line2); margin-bottom: 14px; text-align: center; letter-spacing: .5px; }

.equip-types { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 6px; }
.chk { display: flex; align-items: center; gap: 7px; font-size: 14px; color: var(--soft); }
.chk input { width: 18px; height: 18px; accent-color: var(--inv-bg); }

/* contact history (events / tasks) — под десктопный вид */
.hist-section { margin-top: 24px; }
.hist-eyebrow { font-family: var(--mono); font-size: 10px; color: var(--dim); font-weight: 700; letter-spacing: .5px; }
.hist-title { font-weight: 900; font-size: 18px; margin-top: 4px; letter-spacing: .3px; }
.hist-desc { font-family: var(--mono); font-size: 11px; color: var(--dim); margin: 4px 0 12px; }
.hist-cards { display: flex; flex-direction: column; gap: 8px; }
.hist-card { background: var(--card); border: 1px solid var(--line2); padding: 13px 14px; }
.hist-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
.hist-card-name { font-weight: 800; font-size: 15px; }
.hist-card-date { font-family: var(--mono); font-size: 11px; color: var(--soft); margin-top: 6px; }
.hist-card-foot { font-family: var(--mono); font-size: 11px; color: var(--dim); margin-top: 9px; }
.hist-card-foot b { color: var(--text); font-weight: 700; }
.hist-prio { font-family: var(--mono); font-size: 11px; color: var(--dim); white-space: nowrap; }
.hist-prio b { color: var(--soft); font-weight: 700; }
.hist-btn { margin-top: 10px; }
.hist-empty { padding: 14px; text-align: center; font-family: var(--mono); font-size: 11px; color: var(--dim); border: 1px dashed var(--line2); }

/* contact multi-picker */
.picker-tabs { display: flex; border: 1px solid var(--line2); margin-top: 8px; }
.picker-tab { flex: 1; background: transparent; border: none; border-right: 1px solid var(--line2); color: var(--dim); font-family: var(--mono); font-size: 11px; font-weight: 800; padding: 9px 4px; }
.picker-tab:last-child { border-right: none; }
.picker-tab-active { background: var(--inv-bg); color: var(--inv-tx); }
.picker { border: 1px solid var(--line2); max-height: 240px; overflow-y: auto; margin-top: 8px; }
.picker-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.picker-item:last-child { border-bottom: none; }
.picker-item.sel { background: var(--elev); }
.picker-check { width: 20px; text-align: center; font-family: var(--mono); color: var(--dim); }
.picker-item.sel .picker-check { color: var(--ok); }
.picker-check.picker-rm { color: var(--danger) !important; }
.picker-name { flex: 1; min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-sub { font-family: var(--mono); font-size: 11px; color: var(--dim); }
.picker-empty { padding: 14px; text-align: center; font-family: var(--mono); font-size: 12px; color: var(--dim); }

/* posters */
.posters { display: flex; gap: 10px; flex-wrap: wrap; }
.poster-wrap { position: relative; }
.posters img { width: 84px; height: 84px; object-fit: cover; border: 1px solid var(--line2); display: block; }
.poster-del { position: absolute; top: -7px; right: -7px; width: 22px; height: 22px; border-radius: 50%; background: var(--danger); color: #fff; border: none; font-size: 15px; line-height: 1; display: flex; align-items: center; justify-content: center; }

/* ===== TOAST ===== */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(90px + var(--safe-b)); z-index: 60;
  background: var(--inv-bg); color: var(--inv-tx); font-family: var(--mono); font-size: 12px; font-weight: 700;
  padding: 10px 16px; max-width: 90vw; text-align: center;
}
.toast.err { background: var(--danger); color: #fff; }
