/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: var(--touch); padding: 0.55rem 1.1rem; border-radius: var(--radius);
  border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 650; text-decoration: none; line-height: 1.2; transition: background 0.12s, border-color 0.12s, transform 0.06s;
}
.btn:hover { background: #f6f8fa; border-color: var(--ink-3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); border-color: var(--green-dark); }
.btn-tag { background: var(--tag); border-color: var(--tag); color: var(--tag-ink); }
.btn-tag:hover { background: #f5b920; border-color: #f5b920; }
.btn-danger { background: var(--surface); border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red-soft); border-color: var(--red); }
.btn-quiet { border-color: transparent; background: transparent; }
.btn-quiet:hover { background: rgb(24 34 46 / 0.06); border-color: transparent; }
.btn-sm { min-height: 36px; padding: 0.3rem 0.8rem; font-size: 0.92rem; border-radius: 10px; }
.btn-lg { min-height: 58px; font-size: 1.15rem; border-radius: 14px; }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; padding: 0; color: var(--blue); text-decoration: underline; text-underline-offset: 2px; font-weight: 600; }
.link-btn.danger { color: var(--red); }

/* Forms */
.field { display: grid; gap: 0.35rem; margin-bottom: 1.1rem; }
.field > label, .field-label { font-weight: 650; }
.hint { color: var(--ink-3); font-size: 0.9rem; }
.input, .select, .textarea {
  width: 100%; min-height: var(--touch); padding: 0.55rem 0.8rem; border: 1.5px solid var(--line-strong);
  border-radius: var(--radius); background: var(--surface); transition: border-color 0.12s, box-shadow 0.12s;
}
.textarea { min-height: 90px; resize: vertical; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.input[aria-invalid="true"], .field.has-error .input, .field.has-error .select { border-color: var(--red); }
.field-error { color: var(--red); font-size: 0.92rem; font-weight: 550; }
.input-group { position: relative; }
.input-prefix { position: absolute; left: 0.85rem; top: 50%; transform: translateY(-50%); color: var(--ink-3); font-weight: 600; pointer-events: none; }
.input-group .input { padding-left: 2rem; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0 1rem; align-items: start; }
.check { display: flex; align-items: flex-start; gap: 0.7rem; min-height: 40px; cursor: pointer; }
.check input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--green); flex: none; }
.check strong { display: block; font-weight: 650; }
.check span.hint { display: block; }
.form-actions { display: flex; gap: 0.7rem; flex-wrap: wrap; margin-top: 1.6rem; padding-top: 1.2rem; border-top: 1px solid var(--line); }
.search { position: relative; }
.search .icon { position: absolute; left: 0.9rem; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.search .input { padding-left: 2.7rem; }

/* Cards, tables */
.card { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); border: 1px solid var(--line); padding: 1.4rem; }
.card + .card { margin-top: 1.1rem; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.card-flush { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; }
.table th { text-align: left; font-weight: 600; font-size: 0.88rem; color: var(--ink-3); padding: 0.7rem 1rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 0.8rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #f8fafb; }
.table .right { text-align: right; }
.table .actions { white-space: nowrap; text-align: right; }
.row-off td { opacity: 0.55; }
.cell-product { display: flex; align-items: center; gap: 0.8rem; min-width: 220px; }
.cell-product small { display: block; color: var(--ink-3); }

/* Badges, pills, chips */
.badge { display: inline-block; padding: 0.1rem 0.55rem; border-radius: 999px; font-size: 0.82rem; font-weight: 650; background: #e8edf1; color: var(--ink-2); white-space: nowrap; }
.badge-ok { background: var(--green-soft); color: var(--green-dark); }
.badge-warn { background: var(--amber-soft); color: var(--amber); }
.badge-danger { background: var(--red-soft); color: var(--red); }
.badge-info { background: var(--blue-soft); color: var(--blue); }
.chips { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 0.4rem; min-height: 40px; padding: 0.3rem 0.95rem; border-radius: 999px;
  border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--ink); text-decoration: none; font-weight: 600; white-space: nowrap;
}
.chip:hover { border-color: var(--ink-3); text-decoration: none; }
.chip.active, .chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip .count { font-size: 0.85rem; opacity: 0.75; }

/* Thumbnails */
.thumb { border-radius: 10px; object-fit: cover; flex: none; background: #e8edf1; display: block; }
.thumb-sm { width: 40px; height: 40px; }
.thumb-md { width: 52px; height: 52px; }
.thumb-lg { width: 120px; height: 120px; border-radius: 14px; }
.thumb-letters {
  display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; letter-spacing: 0.02em;
  background: hsl(var(--hue) 70% 90%); color: hsl(var(--hue) 55% 28%);
}
.thumb-sm.thumb-letters { font-size: 0.85rem; }
.thumb-lg.thumb-letters { font-size: 2rem; }

/* Messages */
.toasts { position: fixed; z-index: 100; top: 1rem; left: 50%; transform: translateX(-50%); display: grid; gap: 0.5rem; width: min(92vw, 520px); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; gap: 0.7rem; align-items: center; padding: 0.8rem 1rem; border-radius: var(--radius);
  background: var(--ink); color: #fff; box-shadow: var(--shadow-lift); font-weight: 550;
  animation: toast-in 0.25s ease-out;
}
.toast-alert { background: var(--red); }
.toast .icon { flex: none; }
.toast button { margin-left: auto; background: none; border: 0; color: inherit; opacity: 0.8; padding: 0.2rem; display: grid; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.alert { padding: 0.9rem 1.1rem; border-radius: var(--radius); margin-bottom: 1.2rem; }
.alert ul { margin-top: 0.3rem; padding-left: 1.1rem; list-style: disc; }
.alert-danger { background: var(--red-soft); color: #7e1d17; }
.alert-info { background: var(--blue-soft); color: #153a96; }
.alert-warn { background: var(--amber-soft); color: var(--amber); }
.empty { text-align: center; padding: 3rem 1.5rem; color: var(--ink-2); }
.empty .icon { width: 2.4rem; height: 2.4rem; color: var(--ink-3); margin-bottom: 0.6rem; }
.empty h3 { color: var(--ink); margin-bottom: 0.3rem; }
.empty .btn { margin-top: 1rem; }

/* Pagination */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.9rem 1rem; border-top: 1px solid var(--line); color: var(--ink-2); flex-wrap: wrap; }

/* Dialog */
dialog { border: 0; border-radius: var(--radius-lg); padding: 0; box-shadow: var(--shadow-lift); width: min(94vw, 460px); color: var(--ink); }
dialog::backdrop { background: rgb(24 34 46 / 0.55); }
dialog[open] { animation: dialog-in 0.18s ease-out; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
.dialog-body { padding: 1.5rem; }
.dialog-foot { display: flex; gap: 0.6rem; justify-content: flex-end; padding: 0 1.5rem 1.5rem; flex-wrap: wrap; }

/* Stat tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; margin-bottom: 1.1rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1.1rem 1.2rem; }
.stat-label { color: var(--ink-2); font-weight: 550; }
.stat-value { font-family: var(--font-display); font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; margin: 0.15rem 0; line-height: 1.1; }
.stat-note { font-size: 0.9rem; color: var(--ink-3); }
.stat-main { background: var(--ink); border-color: var(--ink); color: #fff; }
.stat-main .stat-label, .stat-main .stat-note { color: #b9c6d2; }
.delta { font-weight: 650; font-size: 0.9rem; }
.delta-up { color: var(--green); }
.delta-down { color: var(--red); }
.delta-flat { color: var(--ink-3); }
.stat-main .delta-up { color: #6ee0b6; }
.stat-main .delta-down { color: #ff9d95; }

/* Segmented range picker */
.range-bar { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1.2rem; }
.range-custom { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.range-custom .input { width: auto; min-height: 40px; }

/* Bar chart: plain HTML so it prints and reads on any screen */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 190px; padding-top: 1.4rem; }
.bar { flex: 1 1 0; min-width: 6px; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; position: relative; }
.bar-fill { width: 100%; max-width: 46px; background: var(--green); border-radius: 6px 6px 2px 2px; min-height: 2px; transition: background 0.12s; }
.bar-empty .bar-fill { background: var(--line); }
.bar:hover .bar-fill { background: var(--tag); }
.bar-best .bar-fill { background: var(--tag); }
.bar-tip { position: absolute; bottom: calc(var(--h, 0%) + 6px); background: var(--ink); color: #fff; font-size: 0.82rem; font-weight: 600; padding: 0.2rem 0.5rem; border-radius: 6px; white-space: nowrap; display: none; z-index: 2; }
.bar:hover .bar-tip, .bar:focus-visible .bar-tip { display: block; }
.bar-labels { display: flex; gap: 4px; margin-top: 0.4rem; }
.bar-labels span { flex: 1 1 0; min-width: 6px; text-align: center; font-size: 0.78rem; color: var(--ink-3); overflow: hidden; white-space: nowrap; }
.hbar { display: grid; gap: 0.2rem; }
.hbar-track { height: 10px; background: #e8edf1; border-radius: 99px; overflow: hidden; }
.hbar-fill { height: 100%; background: var(--green); border-radius: 99px; }
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1.1rem; }
.split > .card { margin: 0; }

/* Roles & permissions */
.perm-list { display: grid; gap: 0.2rem; }
.role-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1rem; }
.role-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1.2rem; display: flex; flex-direction: column; gap: 0.8rem; }
.role-card ul { display: grid; gap: 0.25rem; color: var(--ink-2); }
.role-card li { display: flex; gap: 0.5rem; align-items: center; }
.role-card li .icon { color: var(--green); }
.role-editor { border: 1.5px solid var(--line-strong); border-radius: var(--radius-lg); padding: 1.1rem; margin-bottom: 1rem; background: var(--surface); }
.role-editor-head { display: flex; gap: 0.8rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 0.8rem; }
.role-editor-head .field { margin: 0; flex: 1 1 200px; }
.role-editor details summary { cursor: pointer; font-weight: 650; padding: 0.4rem 0; }
.owner-pick { display: inline-flex; gap: 0.5rem; align-items: center; font-weight: 600; min-height: 44px; }
.owner-pick input { width: 20px; height: 20px; accent-color: var(--green); }

.switch { display: inline-flex; align-items: center; gap: 0.6rem; cursor: pointer; font-weight: 600; }
.price-chip { display: inline-block; background: var(--tag); color: var(--tag-ink); font-family: var(--font-display); font-weight: 700; padding: 0.1rem 0.6rem; border-radius: 6px 6px 6px 2px; }

/* Number fields: no tiny spinner arrows, people type amounts */
.input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.input[type="number"]::-webkit-outer-spin-button, .input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Business logo */
.brand-logo {
  width: 42px; height: 42px; border-radius: 10px; background: #fff; display: block; flex: none; overflow: hidden; padding: 3px;
}
.brand-logo img { display: block; width: 100%; height: 100%; object-fit: contain; }
.logo-field { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.logo-preview { width: 96px; height: 96px; border-radius: 14px; background: #e8edf1; display: grid; place-items: center; color: var(--ink-3); overflow: hidden; padding: 6px; }
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-preview .icon { width: 2rem; height: 2rem; }
