/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 14px; white-space: nowrap;
  transition: background-color .15s var(--ease), opacity .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: default; }
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { filter: brightness(1.12); }
.btn--ghost { border: 1px solid var(--line-strong); background: var(--bg); }
.btn--ghost:hover { background: var(--surface); }
.btn--danger { background: var(--bad); color: #fff; }
.btn--quiet { color: var(--ink-2); padding: 0 10px; }
.btn--quiet:hover { color: var(--ink); background: var(--surface); }
.btn--block { width: 100%; }
.btn--sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn.is-busy { position: relative; color: transparent !important; }
.btn.is-busy::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--accent-ink) transparent var(--accent-ink) transparent;
  animation: spin .7s linear infinite;
}
.btn--ghost.is-busy::after { border-color: var(--ink) transparent var(--ink) transparent; }

.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border-radius: var(--radius-sm); color: var(--ink);
}
.icon-btn:hover { background: var(--surface); }
.icon-btn--filled { background: var(--accent); color: var(--accent-ink); }
.icon-btn--filled:hover { background: var(--accent); filter: brightness(1.12); }

.fab {
  position: fixed; right: 16px; bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); z-index: var(--z-fab);
  display: grid; place-items: center; width: 56px; height: 56px; border-radius: 16px;
  background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-fab);
}
.fab .ic { width: 24px; height: 24px; }
@media (min-width: 1024px) { .fab { bottom: 24px; right: 24px; } }

.spinner {
  display: inline-block; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--line-strong); border-top-color: var(--ink);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- form fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field__label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field__hint { font-size: 12px; color: var(--ink-3); }
.field__error { display: none; font-size: 12px; color: var(--bad); }
.field.has-error .input, .field.has-error .select { border-color: var(--bad); }
.field.has-error .field__error { display: block; }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--bg);
  font-size: 16px; line-height: 1.3; transition: border-color .15s;
}
.textarea { min-height: 88px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--focus-ring); }
.select { appearance: none; padding-right: 36px;
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%235a5a62' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center; }
.input-wrap { position: relative; display: block; }
.input-wrap .input { padding-right: 48px; }
.input-wrap__btn { position: absolute; right: 2px; top: 2px; width: 40px; height: 40px; display: grid; place-items: center; color: var(--ink-3); }
.input-wrap--icon .input { padding-left: 40px; padding-right: 12px; }
.input-wrap__icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.form-grid { display: grid; gap: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row--3 { grid-template-columns: 1fr 1fr 1fr; }
.form-error { color: var(--bad); font-size: 14px; background: var(--bad-soft); padding: 10px 12px; border-radius: var(--radius-sm); }
.form-section { font-size: 12px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; margin-top: 6px; }

.check { display: flex; align-items: center; gap: 10px; min-height: 40px; cursor: pointer; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; min-height: 40px; cursor: pointer; font-size: 14px; }
.switch input { position: absolute; opacity: 0; }
.switch__track { width: 40px; height: 24px; border-radius: 99px; background: var(--line-strong); position: relative; transition: background .15s; flex: none; }
.switch__track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-1); transition: transform .15s var(--ease); }
.switch input:checked + .switch__track { background: var(--accent); }
.switch input:checked + .switch__track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--focus); outline-offset: 2px; }

.segmented { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; padding: 3px; border-radius: var(--radius-sm); background: var(--surface-2); }
.segmented button, .segmented label { display: grid; place-items: center; min-height: 36px; padding: 0 12px; border-radius: var(--radius-xs); font-size: 13px; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented [aria-pressed="true"], .segmented label:has(input:checked) { background: var(--bg); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-1), 0 0 0 1px rgba(0, 0, 0, .04); }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--focus); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: 99px; font-size: 13px; background: var(--bg); white-space: nowrap;
}
.chip.is-selected, .chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }

.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 500; padding: 2px 8px; border-radius: var(--radius-xs); background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.tag__dot { width: 6px; height: 6px; border-radius: 99px; background: var(--tag-color, var(--ink-3)); }
.tag--ok { background: var(--ok-soft); color: var(--ok); }
.tag--dark { background: var(--ink); color: var(--bg); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 99px; background: var(--status-color, var(--ink-3)); }

.avatar {
  display: inline-grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 12px;
  background: var(--surface-2); color: var(--ink); font-weight: 600; font-size: 14px;
}
.avatar--sm { width: 32px; height: 32px; border-radius: 9px; font-size: 12px; }
.avatar--xl { width: 56px; height: 56px; border-radius: 14px; font-size: 20px; background: var(--accent); color: var(--accent-ink); }
.avatar--staff { width: 24px; height: 24px; border-radius: 7px; font-size: 11px; background: var(--c, var(--ink)); color: #fff; }

.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; font-size: 11px; font-weight: 700; background: var(--surface-2); }

/* ---------- cards, lists ---------- */
.card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); }
.card--pad { padding: 16px; }
.section { margin-top: 24px; }
.section__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.section__title { font-size: 13px; font-weight: 600; color: var(--ink-3); }

.list { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list > li + li, .list > a + a, .list > .row + .row { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 56px; width: 100%; text-align: left; }
button.row:hover, a.row:hover { background: var(--surface); }
.row__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row__title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__sub { font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__end { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: 13px; color: var(--ink-2); flex: none; }
.row__end b { color: var(--ink); font-weight: 600; font-size: 14px; }
.row--muted { opacity: .55; }

.kv { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); }
.kv > div { display: flex; justify-content: space-between; gap: 12px; padding: 11px 14px; font-size: 14px; }
.kv > div + div { border-top: 1px solid var(--line); }
.kv dt { color: var(--ink-2); }
.kv dd { text-align: right; font-weight: 500; }

.kpis { display: grid; grid-template-columns: repeat(2, 1fr); border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); overflow: hidden; }
.kpis > div { padding: 12px 14px; }
.kpis > div:nth-child(2n) { border-left: 1px solid var(--line); }
.kpis > div:nth-child(n+3) { border-top: 1px solid var(--line); }
.kpis dt { font-size: 12px; color: var(--ink-2); }
.kpis dd { font-family: var(--font-display); font-weight: 600; font-size: 18px; letter-spacing: -.01em; }
.kpis dd small { font-family: var(--font-body); font-size: 12px; font-weight: 500; color: var(--ink-3); margin-left: 4px; }
@media (min-width: 640px) {
  .kpis--4 { grid-template-columns: repeat(4, 1fr); }
  .kpis--4 > div:nth-child(n) { border-left: 1px solid var(--line); border-top: 0; }
  .kpis--4 > div:first-child { border-left: 0; }
}

.state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 48px 16px; text-align: center; color: var(--ink-2); }
.empty { padding: 32px 16px; text-align: center; color: var(--ink-3); font-size: 14px; }

.note-card { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius); background: var(--note-bg); border: 1px solid var(--note-line); }
.note-card .ic { color: var(--ink-3); margin-top: 2px; }
.note-card p { font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.note-card small { font-size: 12px; color: var(--ink-3); }
.note-card__del { margin-left: auto; align-self: flex-start; width: 32px; height: 32px; color: var(--ink-3); }

.menu-list { display: flex; flex-direction: column; }
.menu-item { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 48px; padding: 0 12px; border-radius: var(--radius-sm); text-align: left; }
.menu-item:hover { background: var(--surface); }
.menu-item__check { visibility: hidden; }
.menu-item.is-selected { font-weight: 600; }
.menu-item.is-selected .menu-item__check { visibility: visible; }

/* ---------- sheet / dialog ---------- */
.sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 100%; max-height: 92dvh;
  border-radius: 18px 18px 0 0; background: var(--bg); color: var(--ink);
  display: flex; flex-direction: column; box-shadow: var(--shadow-2);
  transform: translateY(24px); opacity: 0; transition: transform .22s var(--ease), opacity .18s;
}
.sheet:not([open]) { display: none; }
.sheet.is-open { transform: none; opacity: 1; }
.sheet.is-closing { transform: translateY(24px); opacity: 0; transition-duration: .15s; }
.sheet::backdrop { background: var(--backdrop); }
.sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 8px 4px 20px; }
.sheet__title { font-family: var(--font-display); font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.sheet__body { padding: 8px 20px 20px; overflow-y: auto; }
.sheet__foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--bg); }
.sheet__foot .btn { flex: 1; }
.sheet__foot .btn--quiet { flex: none; margin-right: auto; }
.sheet--small .sheet__body { padding-top: 20px; }
.welcome__art { aspect-ratio: 16 / 9; overflow: hidden; background: var(--surface); }
.welcome__art img { width: 100%; height: 100%; object-fit: cover; }
.sheet--welcome .sheet__body { display: flex; flex-direction: column; gap: 10px; padding-top: 18px; }
.welcome__kicker { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--accent-text); }
.welcome__title { font-family: var(--font-display); font-size: 24px; font-weight: 600; letter-spacing: -.02em; }
.welcome__tips { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; font-size: 14px; }
.welcome__tips li { display: flex; gap: 12px; align-items: flex-start; }
.welcome__n { display: grid; place-items: center; width: 24px; height: 24px; flex: none; border-radius: 99px; background: var(--accent-soft); color: var(--accent-text); font-size: 12px; font-weight: 700; }
.sheet form { display: contents; }
@media (min-width: 640px) {
  .sheet { margin: auto; width: 560px; border-radius: 16px; transform: translateY(8px) scale(.98); }
  .sheet.is-open { transform: none; }
  .sheet.is-closing { transform: scale(.98); }
  .sheet--small { width: 420px; }
  .sheet--welcome { width: 520px; overflow: hidden; }
  .sheet--wide { width: 720px; }
  .sheet__foot .btn { flex: none; min-width: 120px; }
}

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom)); z-index: var(--z-toast); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { max-width: 420px; padding: 12px 16px; border-radius: var(--radius); background: var(--ink); color: var(--bg); font-size: 14px; box-shadow: var(--shadow-2); transform: translateY(8px); opacity: 0; transition: .2s var(--ease); }
.toast--error { background: var(--bad); }
.toast--warn { box-shadow: inset 4px 0 0 var(--warn), var(--shadow-2); }
.toast.is-in { transform: none; opacity: 1; }
@media (min-width: 1024px) { .toasts { bottom: 24px; } }

/* ---------- charts (simple bars) ---------- */
.stack { display: flex; gap: 2px; height: 10px; border-radius: 3px; overflow: hidden; }
.stack__seg { width: var(--w); background: var(--c); min-width: 2px; }
.legend { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; font-size: 14px; }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend b { margin-left: auto; font-weight: 600; }
.legend small { color: var(--ink-3); min-width: 36px; text-align: right; }
.dot { width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; }

.bars li { display: grid; grid-template-columns: minmax(64px, 30%) 1fr auto; gap: 10px; align-items: center; padding: 7px 0; font-size: 14px; }
.bars__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars__track { height: 8px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.bars__fill { display: block; height: 100%; width: var(--v); background: var(--c, var(--ink)); border-radius: 0 4px 4px 0; }
.bars__val { text-align: right; font-weight: 600; min-width: 72px; }
.no-anim, .no-anim * { transition: none !important; }   /* initial values are set without the "switching" animation */
.btn--lg { min-height: 52px; padding: 0 22px; font-size: 16px; border-radius: var(--radius); }
