/* Админка TerraPOS. Цвета, шрифт, размеры — только переменные из /shared/ui/theme.css. */

body { font-size: 14px; line-height: 1.45; }
a { color: var(--c-warning-text); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- каркас ---------- */
.layout { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--c-ink); color: var(--c-on-ink-2); padding: 20px 12px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; height: 100dvh; overflow: auto; scrollbar-width: thin; scrollbar-color: var(--c-ink-2) transparent; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 12px; color: #fff; }
.brand .sign { width: 36px; height: 36px; border-radius: var(--r-btn); background: var(--c-accent); color: var(--c-on-accent); font-weight: 800; font-size: 18px; display: grid; place-items: center; flex-shrink: 0; }
.brand .names { display: flex; flex-direction: column; min-width: 0; }
.brand .logo { font-size: 17px; }
.brand .place { font-size: 12px; color: var(--c-faint); overflow-wrap: anywhere; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--c-faint); padding: 14px 10px 6px; }
.nav a { color: var(--c-on-ink-2); padding: 9px 10px; border-radius: var(--r-s); overflow-wrap: anywhere; line-height: 1.3; }
.nav a:hover { background: var(--c-ink-2); text-decoration: none; }
.nav a.active { background: var(--c-accent); color: var(--c-on-accent); font-weight: 600; }
.whoami { margin-top: auto; padding: 16px 10px 0; display: flex; flex-direction: column; gap: 4px; align-items: stretch; }
.whoami .name { color: #fff; font-weight: 600; }
.whoami .sub { color: var(--c-faint); }
.whoami .lang-select { background: var(--c-ink-2); border-color: var(--c-ink-2); color: var(--c-on-ink); margin: 8px 0 4px; width: 100%; }
.whoami button { background: var(--c-ink-2); border-color: var(--c-ink-2); color: var(--c-on-ink); justify-content: center; }
.whoami button:hover { background: var(--c-muted-strong); }
.mobile-head, .menu-shade { display: none; }

.main { padding: 28px 32px 56px; min-width: 0; max-width: 1360px; width: 100%; }

.login-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 16px; background: var(--c-ink); }
.login-card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 16px; border-radius: var(--r-modal); padding: 24px; }
.login-card h1 { margin: 0; font-size: 24px; font-weight: 700; }
.login-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.login-head .logo { font-size: 22px; }
.login-head .logo b { color: var(--c-warning-text); }
.login-head .lang-select { flex: 0 1 210px; min-width: 0; margin: 0; }
.login-card button { width: 100%; min-height: 48px; }

/* ---------- заголовки и панели ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: 26px; font-weight: 700; line-height: 1.2; flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; }
.page-head .toolbar { margin: 0; }
.back { display: inline-flex; align-items: center; min-height: 32px; margin-bottom: 4px; color: var(--c-muted-strong); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .grow { flex: 1 1 220px; min-width: 0; }
.card { background: var(--c-surface); border-radius: var(--r-card); box-shadow: var(--shadow-card); padding: 20px; margin-bottom: 16px; min-width: 0; }
.card.inner { background: var(--c-surface-2); border: 1px solid var(--c-border); box-shadow: none; padding: 16px; }
.card h2 { margin: 0 0 16px; font-size: 16px; font-weight: 700; }
.section-title { font-size: 16px; font-weight: 700; margin: 20px 0 12px; }
.muted, .sub { color: var(--c-muted); }
.main p.muted, .page-head .muted, .toolbar > .muted { color: var(--c-muted-strong); }
.card .muted, .card p.muted { color: var(--c-muted); }
[data-field="lines"], .card.inner { overflow-x: auto; }
.sub { font-size: 13px; }
.notice { background: var(--c-warning-bg); color: var(--c-warning-text); border-radius: var(--r-card); padding: 14px 18px; margin-bottom: 16px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.error-box { background: var(--c-danger-bg); color: var(--c-danger-text); border-radius: var(--r-btn); padding: 12px 16px; margin-bottom: 16px; font-weight: 500; }
.login-card .error-box { margin: 0; }
.empty { text-align: center; padding: 48px 16px; color: var(--c-muted); }

/* ---------- кнопки и поля ---------- */
button, .btn { font: inherit; font-weight: 600; min-height: 42px; border: 1px solid var(--c-border-strong); background: var(--c-surface); color: var(--c-text-2); border-radius: var(--r-btn); padding: 6px 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; line-height: 1.2; text-align: center; max-width: 100%; }
button:hover, .btn:hover { background: var(--c-surface-2); text-decoration: none; }
button:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--c-ink); border-color: var(--c-ink); color: var(--c-on-ink); }
.btn-primary:hover { background: var(--c-ink-2); }
.btn-danger { color: var(--c-danger); }
.btn-danger-fill { background: var(--c-danger); border-color: var(--c-danger); color: #fff; }
.btn-danger-fill:hover { background: var(--c-danger); filter: brightness(.93); }
.btn-small { min-height: 36px; padding: 4px 12px; font-size: 13px; border-radius: var(--r-s); }
.btn-icon { min-height: 36px; width: 36px; padding: 0; border-radius: var(--r-s); flex-shrink: 0; }
.modal-close { padding: 0; min-height: 0; }

input[type=text], input[type=search], input[type=url], input[type=number], input[type=password], input[type=email], input[type=tel], input[type=date], input[type=datetime-local], input:not([type]), select {
  font: inherit; color: var(--c-text); background: var(--c-surface); border: 1px solid var(--c-border-strong); border-radius: var(--r-btn); padding: 8px 12px; min-height: 42px; width: 100%; min-width: 0;
}
select { text-overflow: ellipsis; }
input[type=file] { font: inherit; max-width: 100%; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--c-ink); flex-shrink: 0; margin: 0; }
input.invalid, select.invalid { border-color: var(--c-danger); }
input:disabled, select:disabled { background: var(--c-bg); color: var(--c-muted-strong); }
input.num { text-align: right; font-variant-numeric: tabular-nums; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid .wide { grid-column: 1 / -1; }
.field { min-width: 0; }
.field label { display: block; font-size: 13px; color: var(--c-muted); margin-bottom: 6px; }
.card > .field { margin-bottom: 16px; max-width: 560px; }
.card > .check { display: flex; margin-bottom: 8px; }
.field-error { color: var(--c-danger); font-size: 13px; margin-top: 4px; }
.checks { display: flex; gap: 4px 20px; flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 10px; min-height: 36px; cursor: pointer; }
.hint { font-size: 13px; color: var(--c-muted); margin-top: 4px; }
.color-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.color-row input:not([type=color]):not([type=checkbox]) { flex: 1 1 180px; }
.color-row input[type=color] { width: 52px; height: 42px; padding: 3px; border: 1px solid var(--c-border-strong); border-radius: var(--r-btn); background: var(--c-surface); }
.image-preview { width: 64px; height: 64px; border-radius: var(--r-btn); object-fit: cover; border: 1px solid var(--c-border); background: var(--c-bg); }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: space-between; }
.form-actions .left { display: flex; gap: 8px; flex-wrap: wrap; }
.perm-group { margin-bottom: 16px; }
.perm-group h3 { font-size: 14px; margin: 0 0 4px; }
.perm-group .check { margin-right: 20px; }
.status-fired, .status-blocked { color: var(--c-danger-text); }
.status-active { color: var(--c-success-text); }
.lang-select { width: auto; max-width: 100%; }
details.i18n { margin-top: 8px; font-size: 13px; }
details.i18n summary { cursor: pointer; color: var(--c-muted-strong); min-height: 28px; display: list-item; }
details.i18n .form-grid { margin-top: 8px; gap: 10px 16px; }

/* переключатель периода */
.seg { display: inline-flex; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-btn); padding: 3px; gap: 2px; max-width: 100%; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; min-height: 36px; padding: 4px 14px; border-radius: var(--r-s); font-weight: 400; }
.seg button.on { background: var(--c-ink); color: var(--c-on-ink); font-weight: 600; }
.period-custom { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.period-custom input { width: auto; }

/* ---------- таблицы ---------- */
.table-wrap { overflow-x: auto; background: var(--c-surface); border-radius: var(--r-card); box-shadow: var(--shadow-card); padding: 4px 12px; margin-bottom: 16px; }
.card .table-wrap { box-shadow: none; padding: 0; margin-bottom: 0; border-radius: 0; }
.card { overflow-wrap: break-word; }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 8px; border-bottom: 1px solid var(--c-bg); text-align: left; vertical-align: middle; }
th { font-size: 13px; font-weight: 600; color: var(--c-muted); border-bottom-color: var(--c-border); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover td { background: var(--c-surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
th.num .sort-btn { justify-content: flex-end; }
td.actions { text-align: right; white-space: nowrap; }
tfoot th { color: var(--c-text); border-top: 1px solid var(--c-border); border-bottom: 0; }
.sort-btn, .sort-btn:hover { border: 0; background: transparent; padding: 0; min-height: 28px; color: inherit; font-weight: 600; border-radius: 4px; }
.sort-btn:hover { text-decoration: underline; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--c-border); vertical-align: -2px; margin-right: 8px; }
.indent { display: inline-block; }
.badge { display: inline-block; font-size: 12px; font-weight: 500; padding: 2px 9px; border-radius: 12px; background: var(--c-bg); color: var(--c-muted-strong); margin-left: 6px; }
.badge.low { background: var(--c-danger-bg); color: var(--c-danger-text); }
.variants { min-width: 560px; }
.variants td { padding: 8px 6px; }
.variants th { padding: 8px 6px; }
.variants .col-money { width: 130px; min-width: 104px; }
.variants .col-markup { width: 110px; min-width: 92px; }

/* ---------- отчёты ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 16px; }
.stat { margin: 0; padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; }
.stat .muted { font-size: 13px; font-weight: 500; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 16px; margin-bottom: 16px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; margin-bottom: 16px; }
.grid-2 > .card, .grid-main > .card { margin-bottom: 0; }
.chart { margin: 0; position: relative; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px 16px; margin-bottom: 16px; flex-wrap: wrap; }
.chart-head figcaption { font-weight: 700; font-size: 16px; }
.chart-head .muted { font-size: 13px; }
.chart-plot { display: flex; align-items: flex-end; gap: 6px; border-bottom: 1px solid var(--c-border); }
.chart-col { flex: 1; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; min-width: 2px; cursor: default; }
.chart-val { font-size: 11px; color: var(--c-muted); white-space: nowrap; }
.chart-bar { width: 100%; max-width: 36px; background: var(--c-accent); border-radius: 6px 6px 0 0; flex-shrink: 0; }
.chart-col:hover .chart-bar, .chart-col:focus .chart-bar { filter: brightness(.9); }
.chart-axis { display: flex; gap: 6px; font-size: 11px; color: var(--c-muted); margin-top: 6px; }
.chart-axis span { flex: 1; text-align: center; min-width: 2px; white-space: nowrap; }
.chart-axis.dense, .chart-plot.dense { gap: 2px; }
.chart-tip { position: absolute; right: 0; top: 0; background: var(--c-ink); color: var(--c-on-ink); font-size: 13px; padding: 6px 12px; border-radius: var(--r-s); pointer-events: none; z-index: 1; }
.pays { display: flex; flex-direction: column; gap: 14px; }
.pay-row { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.pay-row b { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pay-bar { height: 10px; background: var(--c-bg); border-radius: 5px; overflow: hidden; }
.pay-bar div { height: 10px; background: var(--c-ink); border-radius: 5px; }
pre { font-family: var(--mono); white-space: pre-wrap; overflow-x: auto; }

/* ---------- уведомления ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 40; max-width: calc(100vw - 32px); }
.toast { background: var(--c-ink); color: var(--c-on-ink); padding: 14px 20px; border-radius: var(--r-btn-l); font-weight: 600; max-width: 400px; }
.toast.error { background: var(--c-danger); color: #fff; }
.toast.success { background: var(--c-success-text); color: #fff; }

/* ---------- узкие экраны ---------- */
@media (max-width: 1100px) { .grid-main { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .mobile-head { display: flex; align-items: center; gap: 12px; background: var(--c-ink); color: #fff; padding: 10px 16px; position: sticky; top: 0; z-index: 5; }
  .mobile-head .place { color: var(--c-faint); font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; text-align: right; }
  .menu-btn, .menu-btn:hover { background: var(--c-ink-2); border: 0; color: #fff; width: var(--tap); height: var(--tap); padding: 0; flex-shrink: 0; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 84vw); z-index: 11; transform: translateX(-100%); transition: transform .18s ease; visibility: hidden; }
  .layout.menu-open .sidebar { transform: none; visibility: visible; }
  .layout.menu-open .menu-shade { display: block; position: fixed; inset: 0; background: var(--c-overlay); z-index: 10; }
  .nav a { padding: 12px 10px; }
  .main { padding: 20px 16px 40px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  button, .btn { min-height: 44px; }
  .btn-small { min-height: 40px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 14px; }
  .stat-value { font-size: 20px; }
  .page-head h1 { font-size: 24px; flex-basis: 100%; }
  .page-head > .seg, .seg { width: 100%; }
  .seg button { flex: 1 1 auto; padding: 4px 8px; min-height: 40px; }
  .toolbar > select { flex: 1 1 45%; width: auto !important; }
  .form-actions, .form-actions .left { width: 100%; }
  .form-actions .left > * { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }
@media print { .sidebar, .mobile-head, .toolbar, .seg, .period-custom, button { display: none !important; } .layout { display: block; } body { background: #fff; } }
.card:has(> table) { overflow-x: auto; }
