:root {
  --bg: #eef0f4;
  --surface: #f6f7f9;
  --card: #ffffff;
  --text: #15192b;
  --muted: #7b8194;
  --border: #e6e8ee;
  --primary: #15803d;
  --primary-soft: #e6f4ea;
  --ok: #16a34a;
  --ok-soft: #e7f6ec;
  --warn: #d97706;
  --warn-soft: #fff4e0;
  --bad: #dc2626;
  --bad-soft: #fdecec;
  --info: #5b6bd6;
  --info-soft: #eef0fb;
  --c-blue: #15803d;
  --c-orange: #f5a524;
  --c-teal: #14b8a6;
  --c-pink: #ec4899;
  --c-sky: #22b8f0;
  --c-violet: #6d4bd8;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 16px rgba(16, 24, 40, 0.04);
  --sidebar-w: 248px;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
}
body {
  font-family:
    'Plus Jakarta Sans',
    system-ui,
    -apple-system,
    'Segoe UI',
    sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a {
  color: var(--primary);
}
h1,
h2,
h3 {
  margin: 0;
  letter-spacing: -0.01em;
}
code {
  background: var(--surface);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ================= layout ================= */

.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--surface);
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 18px;
  font-weight: 800;
  font-size: 20px;
}
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #fff;
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(0, 0, 0, 0.06);
}
.brand-mark img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}
.side-label {
  font-size: 12px;
  color: var(--muted);
  padding: 10px 10px 6px;
  font-weight: 500;
}
.side-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.side-nav button {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: #4b5167;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}
.side-nav button {
  width: 100%;
}
/* every icon the same size in one straight column, text lined up after it */
.side-nav button svg {
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  color: #9aa0b2;
}
.side-nav .side-text {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-nav button:hover {
  background: #eceef3;
}
.side-nav button.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 8px 20px rgba(21, 128, 61, 0.35);
}
.side-nav button.active svg {
  color: #fff;
}
.side-nav .count {
  margin-left: auto;
  background: var(--bad);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 7px;
}
.side-nav button.active .count {
  background: #fff;
  color: var(--primary);
}

.side-panel {
  background: var(--card);
  border-radius: 16px;
  padding: 12px;
  margin-top: 10px;
  box-shadow: var(--shadow);
}
.side-panel h4 {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  display: flex;
  justify-content: space-between;
}
.side-panel ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.side-panel li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.side-panel li:last-child {
  border-bottom: 0;
}
.side-panel li .meta {
  color: var(--muted);
  font-size: 11px;
  display: block;
}
.side-panel .empty-mini {
  color: var(--muted);
  font-size: 12px;
  padding: 6px 2px;
}

.main {
  flex: 1;
  min-width: 0;
  padding: 16px 22px 40px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 18px;
  margin-bottom: 18px;
}
.menu-btn {
  display: none;
}
.search {
  position: relative;
  flex: 1;
  max-width: 420px;
}
.search input {
  width: 100%;
  border: 0;
  background: var(--card);
  border-radius: 999px;
  padding: 11px 16px 11px 42px;
  font: inherit;
  box-shadow: var(--shadow);
}
.search input:focus {
  outline: 2px solid var(--primary-soft);
}
.search > svg {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  color: var(--muted);
}
.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--card);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(16, 24, 40, 0.15);
  padding: 6px;
  z-index: 30;
  max-height: 360px;
  overflow-y: auto;
}
.search-results button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: none;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  font: inherit;
}
.search-results button:hover {
  background: var(--surface);
}
.search-results .sub {
  color: var(--muted);
  font-size: 12px;
  display: block;
}

.top-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}
.icon-btn {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  background: var(--card);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  color: #4b5167;
}
.icon-btn svg {
  width: 19px;
  height: 19px;
}
.icon-btn .dot {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--bad);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.balance {
  padding: 0 16px;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.balance small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}
.balance b {
  font-size: 17px;
}
.balance b.neg {
  color: var(--bad);
}
.profile {
  position: relative;
}
.profile > button {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: none;
  cursor: pointer;
  font: inherit;
  padding: 0;
}
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #4caf50);
  flex: none;
  font-size: 14px;
  overflow: hidden;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar.sm {
  width: 30px;
  height: 30px;
  font-size: 11px;
}
.avatar.staff {
  background: linear-gradient(135deg, var(--c-teal), var(--c-sky));
}
.profile .who b {
  display: block;
  font-size: 13px;
}
.profile .who small {
  color: var(--muted);
  font-size: 11px;
  text-transform: capitalize;
}
.dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  background: var(--card);
  border-radius: 14px;
  min-width: 230px;
  box-shadow: 0 16px 40px rgba(16, 24, 40, 0.15);
  padding: 6px;
  z-index: 30;
}
.dropdown button {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
  border: 0;
  background: none;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  text-align: left;
}
.dropdown button:hover {
  background: var(--surface);
}
.dropdown button svg {
  width: 17px;
  color: var(--muted);
}
.dropdown .head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.dropdown .head small {
  display: block;
  color: var(--muted);
}
.notif-list {
  max-height: 360px;
  overflow-y: auto;
  min-width: 320px;
}
.notif-list .item {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  align-items: flex-start;
}
.notif-list .item:hover {
  background: var(--surface);
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin: 6px 4px 18px;
}
.page-head.dashboard-page-head {
  position: relative;
  overflow: hidden;
  min-height: 112px;
  padding: 22px 26px;
  margin: 4px 0 18px;
  border: 1px solid #1e5632;
  border-radius: 20px;
  background: #17472b;
  color: #fff;
  box-shadow: 0 10px 24px rgba(17, 61, 35, 0.12);
}
.page-head.dashboard-page-head h1 {
  font-size: clamp(26px, 3vw, 34px);
  letter-spacing: -0.035em;
}
.page-head.dashboard-page-head p {
  max-width: 62ch;
  color: #d3e6d9;
}
.page-head.dashboard-page-head .fab {
  background: #fff;
  color: #17472b;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}
.page-head.dashboard-page-head .fab:hover,
.page-head.dashboard-page-head .fab:focus-visible {
  background: #edf5ef;
  color: #17472b;
}
.page-head h1 {
  font-size: 24px;
  font-weight: 800;
}
.page-head p {
  margin: 4px 0 0;
  color: var(--muted);
}
.head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  position: relative;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 500;
  color: #3a4055;
  cursor: default;
}
.chip svg {
  width: 17px;
  color: var(--muted);
}
.fab {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 0;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 20px rgba(21, 128, 61, 0.4);
  transition:
    transform 0.2s ease,
    background-color 0.2s ease,
    color 0.2s ease,
    box-shadow 0.2s ease;
}
.fab svg {
  width: 22px;
}
.fab:hover,
.fab:focus-visible {
  background: #fff;
  color: var(--primary);
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 12px 24px rgba(21, 128, 61, 0.3);
}
.fab:active {
  transform: translateY(-1px) scale(0.97);
}
@media (prefers-reduced-motion: reduce) {
  .fab {
    transition: none;
  }
  .fab:hover,
  .fab:focus-visible,
  .fab:active {
    transform: none;
  }
}

.content {
  background: var(--surface);
  border-radius: 24px;
  padding: 18px;
}

/* ================= cards ================= */

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.card-title h3 {
  font-size: 16px;
  font-weight: 700;
}
.card-title .sub {
  color: var(--muted);
  font-size: 12px;
}

.grid {
  display: grid;
  gap: 16px;
}
.kpis {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-bottom: 16px;
}
.row-main {
  grid-template-columns: minmax(0, 2.1fr) minmax(280px, 1fr);
  margin-bottom: 16px;
}
.row-3 {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.kpi {
  padding: 16px 16px 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.kpi .top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.kpi .label {
  color: #4b5167;
  font-size: 13px;
  font-weight: 500;
}
.kpi .value {
  font-size: 22px;
  font-weight: 800;
  margin-top: 4px;
}
.kpi .note {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}
.kpi .spark {
  height: 64px;
  margin: 6px -16px 0;
}
.spark svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ok);
}
.trend.down {
  color: var(--bad);
}
.trend svg {
  width: 15px;
}

.chart-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.chart-head h3 {
  font-size: 16px;
}
.legend-stats {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
}
.legend-stats .ls small {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}
.legend-stats .ls b {
  font-size: 22px;
  font-weight: 800;
}
.swatch {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  flex: none;
}

.donut-wrap {
  position: relative;
  height: 210px;
}
.donut-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  pointer-events: none;
}
.donut-center b {
  font-size: 24px;
  display: block;
}
.donut-center small {
  color: var(--muted);
}
.legend {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
  display: grid;
  gap: 8px;
}
.legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.legend li b {
  margin-left: auto;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.list li:last-child {
  border-bottom: 0;
}
.list .grow {
  flex: 1;
  min-width: 0;
}
.list .grow b {
  display: block;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list .grow small {
  color: var(--muted);
  font-size: 12px;
}
.list .amt {
  font-weight: 700;
  white-space: nowrap;
}
.ico {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex: none;
}
.ico svg {
  width: 17px;
}
.ico.stock {
  background: var(--primary-soft);
  color: var(--primary);
}
.ico.loans {
  background: var(--warn-soft);
  color: var(--warn);
}
.ico.credits {
  background: #fde7f3;
  color: var(--c-pink);
}
.ico.bad {
  background: var(--bad-soft);
  color: var(--bad);
}

.tooltip-box {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(16, 24, 40, 0.15);
  padding: 10px 12px;
  font-size: 12px;
}
.tooltip-box .t {
  font-weight: 600;
  margin-bottom: 4px;
}
.tooltip-box div {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ================= controls ================= */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
  align-items: center;
}
.toolbar .search-inline {
  flex: 1;
  min-width: 200px;
  position: relative;
}
.toolbar .search-inline svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  color: var(--muted);
}
.toolbar .search-inline input {
  padding-left: 36px;
}
input,
select,
textarea {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  width: 100%;
  color: var(--text);
}
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--primary-soft);
  border-color: var(--primary);
}
.toolbar select,
.row input,
.toolbar input[type='date'] {
  width: auto;
}
button {
  font: inherit;
  padding: 9px 16px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 500;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
}
button:hover {
  border-color: #c9cede;
}
button svg {
  width: 16px;
  height: 16px;
}
button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(21, 128, 61, 0.25);
}
button.primary:hover {
  background: #116b32;
}
button.small {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 9px;
}
button.danger {
  color: var(--bad);
}
button.ghost {
  border-color: transparent;
  background: transparent;
}
button:disabled {
  opacity: 0.6;
  cursor: default;
}

.segmented {
  display: inline-flex;
  background: var(--card);
  border-radius: 12px;
  padding: 4px;
  box-shadow: var(--shadow);
  gap: 2px;
}
.segmented button {
  border: 0;
  background: none;
  padding: 7px 14px;
  border-radius: 9px;
  color: var(--muted);
}
.segmented button.on {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 10px rgba(21, 128, 61, 0.3);
}

.period-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--card);
  border-radius: 12px;
  padding: 4px;
  box-shadow: var(--shadow);
}
.period-nav button {
  border: 0;
  padding: 7px 9px;
}
.period-nav span {
  font-weight: 600;
  padding: 0 8px;
  white-space: nowrap;
}

/* ================= tables ================= */

.table-wrap {
  overflow-x: auto;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
table {
  width: 100%;
  border-collapse: collapse;
}
th,
td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
th {
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: #fbfbfd;
}
tbody tr:hover {
  background: #fafbff;
}
tr:last-child td {
  border-bottom: 0;
}
.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
td.actions {
  text-align: right;
}
td.actions button {
  margin-left: 4px;
}
td .sub {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.empty {
  text-align: center;
  color: var(--muted);
  padding: 30px;
}
tfoot td {
  font-weight: 700;
  background: #fbfbfd;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.ok,
.badge.paid,
.badge.active {
  background: var(--ok-soft);
  color: var(--ok);
}
.badge.low,
.badge.partial,
.badge.pending {
  background: var(--warn-soft);
  color: var(--warn);
}
.badge.out,
.badge.overdue {
  background: var(--bad-soft);
  color: var(--bad);
}
.badge.unpaid {
  background: var(--info-soft);
  color: var(--info);
}
.badge.disabled,
.badge.deleted {
  background: #eceff1;
  color: var(--muted);
}
.badge.admin {
  background: var(--primary-soft);
  color: var(--primary);
}
.badge.staff {
  background: #e0f7f4;
  color: #0f8f80;
}
.badge.in_stock,
.badge.resolved,
.badge.active_w {
  background: var(--ok-soft);
  color: var(--ok);
}
.badge.sold {
  background: var(--info-soft);
  color: var(--info);
}
.badge.removed,
.badge.voided,
.badge.expired {
  background: #eceff1;
  color: var(--muted);
}
.badge.credit,
.badge.open {
  background: var(--warn-soft);
  color: var(--warn);
}
.badge.rejected {
  background: var(--bad-soft);
  color: var(--bad);
}
.perm {
  display: inline-block;
  font-size: 12px;
  margin-right: 8px;
  color: var(--muted);
}
.perm b {
  color: var(--text);
  font-weight: 600;
}
.perm.none b {
  color: #b0b8c1;
  text-decoration: line-through;
}
.pos {
  color: var(--ok);
}
.neg {
  color: var(--bad);
}

.hint {
  color: var(--muted);
  margin: 0 0 14px;
}
.pending-banner {
  background: var(--warn-soft);
  color: var(--warn);
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 600;
}
.panel {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px;
  max-width: 600px;
  box-shadow: var(--shadow);
}
.panel h2 {
  font-size: 18px;
  margin-bottom: 6px;
}
label {
  display: block;
  margin: 12px 0;
  font-size: 13px;
  color: #4b5167;
  font-weight: 500;
}
label input,
label select,
label textarea {
  margin-top: 6px;
}
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.row.end {
  justify-content: flex-end;
}
.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 14px;
}
label.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  color: var(--text);
  cursor: pointer;
}
label.check input {
  width: auto;
  margin: 3px 0 0;
}
label.check small,
label small.help {
  display: block;
  color: var(--muted);
  font-weight: 400;
  margin-top: 2px;
}
.error {
  color: var(--bad);
  min-height: 1em;
  margin: 6px 0 0;
  font-size: 13px;
}

/* ================= modal & toast ================= */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(21, 25, 43, 0.45);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
  overflow-y: auto;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--card);
  border-radius: 20px;
  padding: 24px;
  width: min(580px, 100%);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.25);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}
.modal.wide {
  width: min(800px, 100%);
}
.modal h2 {
  font-size: 19px;
  margin-bottom: 12px;
}
.modal .table-wrap {
  box-shadow: none;
  border: 1px solid var(--border);
  margin-top: 8px;
}

#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: #fff;
  padding: 12px 20px;
  border-radius: 12px;
  opacity: 0;
  transition: 0.2s;
  pointer-events: none;
  z-index: 60;
  font-weight: 500;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%);
}
.loading {
  padding: 60px;
  text-align: center;
  color: var(--muted);
}

/* ================= login ================= */

.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  background: var(--card);
}
.auth-art {
  position: relative;
  overflow: hidden;
  color: #fff;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: radial-gradient(circle at 20% 15%, #4caf50 0, transparent 45%),
    linear-gradient(150deg, #15803d 0%, #166534 55%, #0f3d22 100%);
  transition: background 0.3s;
}
.auth-art.admin {
  background: radial-gradient(circle at 20% 15%, #3a3f63 0, transparent 45%),
    linear-gradient(150deg, #1d2140 0%, #121530 60%, #080a1c 100%);
}
.auth-art .brand {
  color: #fff;
  padding: 0;
}
.auth-art .brand-mark {
  background: #fff;
  color: var(--primary);
  box-shadow: none;
}
.auth-art.admin .brand-mark {
  color: #121530;
}
.auth-art h2 {
  font-size: 34px;
  font-weight: 800;
  line-height: 1.2;
  max-width: 440px;
}
.auth-art p {
  color: rgba(255, 255, 255, 0.75);
  max-width: 420px;
  line-height: 1.6;
}
.auth-art ul {
  list-style: none;
  padding: 0;
  margin: 24px 0 0;
  display: grid;
  gap: 12px;
}
.auth-art li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
}
.auth-art li span {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.14);
  display: grid;
  place-items: center;
}
.auth-art li svg {
  width: 18px;
}
.auth-art .glass {
  position: absolute;
  right: -60px;
  bottom: -60px;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.auth-side {
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background: var(--surface);
}
.auth-card {
  width: min(420px, 100%);
  background: var(--card);
  border-radius: 24px;
  padding: 30px;
  box-shadow: 0 20px 50px rgba(16, 24, 40, 0.08);
}
.portal-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--surface);
  border-radius: 14px;
  padding: 4px;
  margin-bottom: 22px;
}
.portal-switch button {
  border: 0;
  background: none;
  border-radius: 11px;
  padding: 10px;
  color: var(--muted);
  font-weight: 600;
}
.portal-switch button.on.staff {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(21, 128, 61, 0.3);
}
.portal-switch button.on.admin {
  background: #15192b;
  color: #fff;
  box-shadow: 0 4px 12px rgba(21, 25, 43, 0.3);
}
.portal-badge {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
}
.portal-badge.staff {
  background: var(--primary-soft);
  color: var(--primary);
}
.portal-badge.admin {
  background: #15192b;
  color: #fff;
}
.portal-badge svg {
  width: 26px;
  height: 26px;
}
.auth-card h1 {
  font-size: 22px;
  font-weight: 800;
}
.auth-card .hint {
  margin-top: 6px;
}
.auth-card form button.wide {
  width: 100%;
  padding: 12px;
  margin-top: 8px;
}
.auth-card.admin form button.wide {
  background: #15192b;
  border-color: #15192b;
  box-shadow: 0 4px 12px rgba(21, 25, 43, 0.3);
}
.switch {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  margin-top: 16px;
}
.notice {
  background: var(--ok-soft);
  color: var(--ok);
  padding: 16px;
  border-radius: 14px;
  line-height: 1.5;
}
.setup-note {
  background: var(--primary-soft);
  color: var(--primary);
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  margin-bottom: 8px;
}

/* ================= reports ================= */

.report-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}
.report-controls .spacer {
  flex: 1;
}
.report-title {
  display: none;
}
.kpi-plain .value {
  font-size: 22px;
  font-weight: 800;
  margin: 6px 0 2px;
}
.kpi-plain .label {
  color: #4b5167;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}
.kpi-plain .note {
  color: var(--muted);
  font-size: 12px;
}
.section-title {
  font-size: 16px;
  font-weight: 700;
  margin: 22px 4px 10px;
}

/* ================= settings: feature switches ================= */

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
}
.feature {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  transition: 0.15s;
}
.feature.on {
  border-color: #c9d4ff;
  background: #f7f9ff;
}
.feature .grow {
  flex: 1;
  min-width: 0;
}
.feature b {
  display: block;
}
.feature p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.feature .needs {
  display: block;
  margin-top: 6px;
  color: var(--warn);
  font-size: 12px;
}
.switch-btn {
  flex: none;
  width: 46px;
  height: 26px;
  border-radius: 999px;
  border: 0;
  padding: 3px;
  background: #d5d9e4;
  justify-content: flex-start;
  transition: 0.15s;
}
.switch-btn span {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: 0.15s;
}
.switch-btn.on {
  background: var(--primary);
}
.switch-btn.on span {
  transform: translateX(20px);
}

/* ================= POS ================= */

.pos {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(330px, 1fr);
  gap: 16px;
  align-items: start;
}
.products {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 12px;
}
.product {
  background: var(--card);
  border-radius: 16px;
  padding: 10px;
  box-shadow: var(--shadow);
  cursor: pointer;
  border: 2px solid transparent;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font: inherit;
  color: inherit;
  transition: 0.12s;
}
.product:hover {
  border-color: var(--primary-soft);
  transform: translateY(-1px);
}
.product[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}
.product .thumb {
  height: 96px;
  border-radius: 12px;
  background: var(--surface);
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #b2b8c8;
}
.product .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.product .thumb svg {
  width: 34px;
  height: 34px;
}
.product b {
  font-size: 13px;
  line-height: 1.3;
}
.product .meta {
  color: var(--muted);
  font-size: 12px;
}
.product .price {
  font-weight: 800;
  color: var(--primary);
}
.cart {
  position: sticky;
  top: 16px;
}
.cart-line {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.cart-line .ctl {
  display: flex;
  gap: 6px;
  align-items: center;
  grid-column: 1 / -1;
}
.cart-line .ctl input {
  width: 90px;
  padding: 6px 8px;
}
.cart-line .ctl input.price {
  width: 130px;
}
.sum-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  color: #4b5167;
}
.sum-row.total {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  margin-top: 6px;
}
.tag {
  display: inline-block;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--surface);
  color: #4b5167;
  margin-right: 4px;
}
.serial-pick {
  max-height: 300px;
  overflow-y: auto;
  display: grid;
  gap: 6px;
}
.serial-pick label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
}
.serial-pick input {
  width: auto;
  margin: 0;
}
.tabs-line {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}
.item-thumb {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  object-fit: cover;
  vertical-align: middle;
  margin-right: 10px;
  background: var(--surface);
}
.photo-field {
  display: flex;
  align-items: center;
  gap: 12px;
}
.photo-field img {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  object-fit: cover;
}
.invoice-settings .photo-field img {
  width: auto;
  max-width: 140px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--border);
}

/* ================= receipt ================= */

/* Inside the print frame (any media, so the page can be measured and fitted before printing) */
body.print-frame {
  margin: 0;
  background: #fff;
}
body.print-frame .invoice {
  page: invoice;
  width: auto;
  max-width: none;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  box-shadow: none;
}

/* A4 invoice (210 × 297 mm). On screen it is a white sheet preview inside the modal. */
.invoice-scroll {
  overflow-x: auto;
  margin-bottom: 14px;
  background: #eef0f4;
  border-radius: 12px;
  padding: 12px;
}
/* The preview keeps the real A4 layout; SheetPreview scales it down (zoom) to fit the screen. */
.invoice-scroll.fit {
  overflow-x: hidden;
}
.invoice-fit > .receipt.invoice {
  width: 210mm;
  min-width: 210mm;
  max-width: none;
}
.invoice-fit > .receipt.agreement {
  max-width: none;
}
.sheet-zoom {
  position: sticky;
  left: 0;
  display: inline-flex;
  margin-bottom: 10px;
  background: #fff;
}

/* Phones / tablets: the separate print page (see printInvoice). */
@media screen {
  body.print-page {
    background: #e5e7eb;
    padding: 0 16px 24px;
  }
  body.print-page .print-page-sheet {
    margin: 0 auto;
    background: #fff;
    box-shadow: 0 2px 14px rgba(0, 0, 0, 0.15);
  }
  .print-page-bar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    gap: 12px;
    justify-content: center;
    padding: 14px 0;
    background: #e5e7eb;
  }
  .print-page-bar button {
    font: 600 22px system-ui, sans-serif;
    padding: 16px 28px;
    border-radius: 12px;
    border: 0;
    background: #15803d;
    color: #fff;
  }
  .print-page-bar button.ghost {
    background: #fff;
    color: #111;
  }
}
@media print {
  .print-page-bar {
    display: none !important;
  }
}
.invoice {
  --inv: #16a34a;
  font-family: 'Times New Roman', Times, serif;
  font-size: 15px;
  line-height: 1.45;
  color: #000;
  background: #fff;
  width: 100%;
  min-width: 640px;
  max-width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  padding: 14mm 14mm 12mm;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}
.invoice .inv-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.invoice .inv-logo {
  max-height: 110px;
  max-width: 200px;
  object-fit: contain;
  margin-left: 12mm;
}
.invoice .inv-title {
  align-self: center;
  color: var(--inv);
  font-family: inherit;
  font-size: 19px;
  font-weight: 700;
  margin: 6px 0 20px;
  letter-spacing: 0;
}
.invoice .inv-shop {
  color: var(--inv);
}
.invoice .inv-dots {
  border-top: 3px dotted #5b8fd6;
  width: 380px;
  max-width: 100%;
  margin: 4px 0 6px;
}
.invoice .inv-client {
  margin-bottom: 18px;
}
.invoice table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  margin: 0;
}
.invoice th,
.invoice td {
  border: 1px solid #000;
  padding: 4px 7px;
  vertical-align: top;
  white-space: normal;
  background: none;
  color: #000;
  text-transform: none;
  letter-spacing: 0;
  font-size: inherit;
  text-align: left;
}
.invoice th {
  font-weight: 700;
  white-space: nowrap;
}
.invoice .n {
  width: 1%;
  text-align: center;
  white-space: nowrap;
}
.invoice .q {
  width: 1%;
  text-align: center;
}
.invoice .m {
  width: 17%;
  text-align: right;
  white-space: nowrap;
}
.invoice th.m {
  text-align: left;
}
.invoice .inv-sub {
  font-size: 12.5px;
  color: #333;
}
.invoice .inv-totals .lbl {
  text-align: right;
}
.invoice .inv-totals tr.strong td {
  font-weight: 700;
}
.invoice .inv-meta {
  font-size: 12.5px;
  color: #444;
  margin: 8px 0 22px;
}
.invoice .inv-terms {
  margin-bottom: 14px;
  font-size: 12.5px;
  line-height: 1.3;
}
.invoice .inv-terms th,
.invoice .inv-terms td {
  padding: 2px 6px;
}
.invoice .inv-terms .c {
  text-align: center;
}
.invoice .inv-sign {
  display: flex;
  align-items: flex-start;
  gap: 0;
  margin-top: 6px;
  break-inside: avoid;
}
.invoice .inv-sign-title {
  font-weight: 700;
  text-decoration: underline;
  margin-bottom: 6px;
}
.invoice .inv-stamp {
  width: 46mm;
  height: auto;
  margin: -12mm 0 0 -8mm;
  mix-blend-mode: multiply;
}
.invoice .inv-footer {
  margin-top: auto;
  padding-top: 18px;
  text-align: center;
  color: var(--inv);
  font-style: italic;
}
.void-stamp {
  color: var(--bad);
  border: 2px solid var(--bad);
  text-align: center;
  font-weight: 800;
  padding: 4px;
  margin: 6px 0;
  letter-spacing: 0.2em;
}

/* ================= responsive ================= */

.scrim {
  display: none;
}
@media (max-width: 1100px) {
  .row-main,
  .pos {
    grid-template-columns: 1fr;
  }
  .cart {
    position: static;
  }
  .balance {
    display: none;
  }
}
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    z-index: 40;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform 0.2s;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.2);
  }
  .sidebar.open {
    transform: none;
  }
  .scrim.show {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(21, 25, 43, 0.35);
    z-index: 35;
  }
  .menu-btn {
    display: grid;
  }
  .main {
    padding: 12px 16px 40px;
  }
  .profile .who {
    display: none;
  }
  .auth {
    grid-template-columns: 1fr;
  }
  .auth-art {
    display: none;
  }
}
@media (max-width: 600px) {
  .grid2 {
    grid-template-columns: 1fr;
  }
  .content {
    padding: 12px;
    border-radius: 18px;
  }
  .search {
    max-width: none;
  }
  .top-right {
    gap: 8px;
  }
}

/* ================= print (reports → PDF) ================= */

@media print {
  body {
    background: #fff;
  }
  /* A4 invoice, printed from its own frame (see printReceipt) */
  @page invoice {
    size: A4;
    margin: 12mm 14mm;
  }
  body.print-frame {
    margin: 0;
    padding: 0;
    background: #fff !important;
  }
  body.print-frame .inv-table tr,
  body.print-frame .inv-terms tr {
    break-inside: avoid;
  }
  body.print-frame,
  body.print-frame * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .sidebar,
  .topbar,
  .page-head,
  .report-controls,
  .no-print,
  #toast {
    display: none !important;
  }
  .main,
  .content {
    padding: 0;
    background: #fff;
  }
  .card,
  .table-wrap {
    box-shadow: none;
    border: 1px solid #ddd;
    break-inside: avoid;
  }
  .report-title {
    display: block;
    margin-bottom: 14px;
  }
  .report-title h1 {
    font-size: 20px;
  }
  .report-title p {
    margin: 4px 0 0;
    color: #555;
  }
}

/* ================= proforma form ================= */

.grid3 {
  display: grid;
  grid-template-columns: 2fr 1.2fr 1fr;
  gap: 0 14px;
}
.form-section {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 14px 0 6px;
}
.form-section:first-child {
  margin-top: 0;
}
.pf-lines {
  display: grid;
  gap: 6px;
}
.pf-line {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 90px 120px 110px 34px;
  gap: 8px;
  align-items: center;
}
.pf-line input {
  margin: 0;
}
.pf-line.head {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pf-no {
  text-align: center;
  color: var(--muted);
  font-weight: 700;
}
.pf-total {
  text-align: right;
  font-weight: 700;
}
.invoice .inv-blank td {
  height: 26px;
}
.invoice .inv-blank td,
.invoice .inv-table tbody:first-of-type tr:not(:last-child) td {
  border-bottom-color: transparent;
}
.invoice .inv-table tbody:first-of-type tr:not(:first-child) td {
  border-top-color: transparent;
}
.invoice .inv-conditions {
  font-size: 13.5px;
  margin-bottom: 14px;
  padding-left: 12mm;
}
.invoice .inv-conditions ul {
  list-style: square;
  margin: 6px 0 0;
  padding-left: 18px;
}
.invoice .inv-conditions li {
  margin: 1px 0;
}
@media (max-width: 700px) {
  .grid3 {
    grid-template-columns: 1fr;
  }
  .pf-line {
    grid-template-columns: 22px minmax(0, 1fr) 64px 34px;
  }
  .pf-line > :nth-child(4),
  .pf-line > :nth-child(5) {
    grid-column: 2 / span 1;
  }
  .pf-line.head {
    display: none;
  }
}
.pf-banner {
  background: var(--primary-soft);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 10px;
  font-size: 13px;
}
.pf-banner svg {
  vertical-align: -3px;
  color: var(--primary);
}
.pf-banner-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.pf-banner ul {
  margin: 6px 0 0;
  padding-left: 18px;
  color: var(--warn);
}
.pf-banner.done {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pf-banner.done button {
  margin-left: auto;
}

/* ================= team chat ================= */

.chat {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 16px;
  height: calc(100vh - 210px);
  min-height: 420px;
}
.chat-list {
  overflow-y: auto;
  padding: 12px;
}
.chat-list h3 {
  margin: 4px 6px 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.chat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 8px;
  border: 0;
  background: none;
  border-radius: 12px;
  text-align: left;
  cursor: pointer;
  color: var(--text);
}
.chat-item:hover {
  background: var(--surface);
}
.chat-item.on {
  background: var(--primary-soft);
}
.chat-item .avatar {
  flex: none;
}
.avatar.team {
  background: linear-gradient(135deg, var(--primary), var(--c-teal));
}
.chat-item-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.chat-item-text small {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-item .count {
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
}

.chat-convo {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
.chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.chat-head > svg {
  color: var(--primary);
}
.chat-head small {
  display: block;
  color: var(--muted);
}
.chat-back {
  display: none;
}
.chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface);
}
.chat-older {
  align-self: center;
  margin-bottom: 10px;
}
.chat-empty {
  margin: auto;
}
.msg {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-top: 10px;
}
.msg.grouped {
  margin-top: 2px;
}
.msg.mine {
  align-items: flex-end;
}
.msg-who {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 3px 4px;
}
.msg-row {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: min(75%, 560px);
}
.msg.mine .msg-row {
  flex-direction: row-reverse;
}
.bubble {
  background: var(--card);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 16px 16px 16px 4px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.45;
}
.msg.mine .bubble {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  border-radius: 16px 16px 4px 16px;
}
.bubble.deleted {
  font-style: italic;
  color: var(--muted);
  background: transparent;
}
.msg.mine .bubble.deleted {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}
.msg-time {
  display: inline-block;
  margin-left: 8px;
  font-size: 10px;
  opacity: 0.65;
  vertical-align: bottom;
}
.msg-del {
  opacity: 0;
  border: 0;
  background: none;
  color: var(--muted);
  padding: 4px;
  cursor: pointer;
}
.msg-row:hover .msg-del,
.msg-del:focus {
  opacity: 1;
}
.chat-input {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
  align-items: flex-end;
}
.chat-input textarea {
  flex: 1;
  margin: 0;
  resize: none;
  min-height: 42px;
  max-height: 140px;
  field-sizing: content;
}
.chat-input button {
  height: 42px;
  padding: 0 16px;
}

@media (max-width: 800px) {
  .chat {
    grid-template-columns: 1fr;
    height: calc(100vh - 180px);
  }
  .chat.list-open .chat-convo,
  .chat.convo-open .chat-list {
    display: none;
  }
  .chat-back {
    display: inline-flex;
    padding: 4px;
  }
  .msg-row {
    max-width: 88%;
  }
  .msg-del {
    opacity: 1;
  }
}

/* chat: files, photos, sound */
.chat-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chat-list-head h3 {
  margin-bottom: 10px;
}
.msg-img {
  display: block;
  margin: -2px -6px 4px;
}
.msg-img img {
  display: block;
  max-width: min(320px, 100%);
  max-height: 320px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--border);
}
.msg-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  color: inherit;
  text-decoration: none;
  min-width: 200px;
}
.msg-file span {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.msg-file b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-file small {
  opacity: 0.7;
}
.msg-text {
  white-space: pre-wrap;
}
.chat-pending {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 0;
}
.chat-pending img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 10px;
}
.chat-pending span {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.chat-pending small {
  color: var(--muted);
}
.chat-convo.dragging {
  outline: 3px dashed var(--primary);
  outline-offset: -6px;
}
.chat-input .ghost {
  height: 42px;
  padding: 0 10px;
}

/* chat: emoji (WhatsApp style) */
.chat-input {
  position: relative;
}
.emoji-toggle.on {
  color: var(--primary);
}
.emoji-picker {
  position: absolute;
  left: 8px;
  bottom: calc(100% + 6px);
  z-index: 20;
  width: min(352px, calc(100vw - 32px));
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 30px rgba(16, 24, 40, 0.16);
  overflow: hidden;
}
.emoji-tabs {
  display: flex;
  gap: 2px;
  padding: 6px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.emoji-tabs button {
  flex: none;
  border: 0;
  background: none;
  font-size: 18px;
  padding: 4px 6px;
  border-radius: 8px;
  cursor: pointer;
  opacity: 0.55;
  border-bottom: 2px solid transparent;
}
.emoji-tabs button.on {
  opacity: 1;
  border-bottom-color: var(--primary);
  border-radius: 8px 8px 0 0;
}
.emoji-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 8px 10px 2px;
}
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  max-height: 240px;
  overflow-y: auto;
  padding: 4px 6px 8px;
}
.emoji-grid button {
  border: 0;
  background: none;
  font-size: 24px;
  line-height: 1;
  padding: 6px 0;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif;
}
.emoji-grid button:hover,
.emoji-grid button:focus-visible {
  background: var(--surface);
}
.msg-text.big-emoji {
  font-size: 40px;
  line-height: 1.15;
}
.bubble:has(> .big-emoji:only-of-type) {
  background: transparent !important;
  border-color: transparent !important;
  padding: 0 4px;
}
.msg.mine .bubble:has(> .big-emoji) .msg-time {
  color: var(--muted);
}

/* chat: reactions */
.msg-row {
  position: relative;
}
.react-bar {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  z-index: 15;
  display: flex;
  gap: 2px;
  padding: 4px 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(16, 24, 40, 0.15);
  animation: react-pop 0.12s ease-out;
}
.msg.mine .react-bar {
  left: auto;
  right: 0;
}
.react-bar button {
  border: 0;
  background: none;
  font-size: 24px;
  line-height: 1;
  padding: 4px;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.1s;
}
.react-bar button:hover {
  transform: scale(1.25);
}
.react-bar button.on {
  background: var(--primary-soft);
}
.react-bar .react-more {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--muted);
  font-size: 16px;
}
.react-picker {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  z-index: 16;
}
.msg.mine .react-picker {
  left: auto;
  right: 0;
}
.react-picker .emoji-picker {
  position: static;
}
.reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: -6px 10px 0;
  position: relative;
  z-index: 1;
}
.reaction {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 14px;
  line-height: 1.5;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.reaction span {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}
.reaction.mine {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.msg-row:hover .msg-react {
  opacity: 1;
}
@keyframes react-pop {
  from {
    transform: scale(0.85);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}
@media (pointer: coarse) {
  .msg-react {
    display: none;
  }
  .bubble {
    -webkit-user-select: none;
    user-select: none;
  }
}

/* Categories page */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.cat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.cat-card-img {
  aspect-ratio: 4 / 3;
  background: var(--surface);
  display: grid;
  place-items: center;
}
.cat-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cat-card-img span {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}
.cat-card-body {
  padding: 10px 12px 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cat-card-body small {
  color: var(--muted);
  font-size: 12px;
}
.cat-card-actions {
  display: flex;
  gap: 6px;
  padding: 8px 12px 12px;
  margin-top: auto;
}
.cat-card-actions button:first-child {
  flex: 1;
}

/* Brands page: logos sit on white, uncropped; brands without a logo show their name */
.brand-grid {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.cat-card-img.brand-logo {
  aspect-ratio: auto;
  height: 160px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 18px;
}
.cat-card-img.brand-logo img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
}
.brand-word {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #334155;
  text-align: center;
}

/* In-app confirm / alert (dialog.jsx): above any open form */
.overlay.dialog-overlay {
  z-index: 1000;
  backdrop-filter: blur(3px);
  animation: dlg-fade 0.18s ease-out both;
}
.modal.dialog {
  max-width: 420px;
  width: 100%;
  text-align: center;
  border-radius: 18px;
  animation: dlg-pop 0.26s cubic-bezier(0.2, 0.9, 0.3, 1.25) both;
}
.modal.dialog .row.end {
  justify-content: center;
}
.modal.dialog .row.end button {
  min-width: 120px;
}
.dialog-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 10px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font: 700 26px/1 system-ui, sans-serif;
  color: #fff;
  background: #3b82f6;
  animation: dlg-icon 0.5s 0.08s ease-out both;
}
.modal.dialog.is-danger .dialog-icon {
  background: #ef4444;
}
.overlay.dialog-overlay.leaving {
  animation: dlg-fade-out 0.16s ease-in both;
}
.overlay.dialog-overlay.leaving .modal.dialog {
  animation: dlg-pop-out 0.16s ease-in both;
}
@keyframes dlg-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes dlg-fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}
@keyframes dlg-pop {
  from { opacity: 0; transform: translateY(18px) scale(0.9); }
  to { opacity: 1; transform: none; }
}
@keyframes dlg-pop-out {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateY(10px) scale(0.95); }
}
@keyframes dlg-icon {
  0% { transform: scale(0.4); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .overlay.dialog-overlay,
  .modal.dialog,
  .dialog-icon {
    animation: none !important;
  }
}

/* Dashboard › Cash book */
.cash-in {
  color: var(--ok);
}
.cash-out {
  color: #dc2626;
}
.cash-diff.ok {
  color: var(--ok);
}
.cash-diff.over {
  color: var(--warn);
}
.cash-diff.short {
  color: #dc2626;
}
.cash-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.link-btn {
  background: none;
  border: 0;
  padding: 0;
  color: var(--primary);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  display: inline;
}

/* "how it's calculated" line under a KPI card's number */
.kpi .calc {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
}
.kpi .calc b {
  color: inherit;
  font-weight: 600;
}
.kpi .calc .eq {
  font-weight: 700;
}

/* ================= dashboard ================= */

.dashboard {
  --dash-ink: #173b27;
  --dash-accent: #21834a;
  --dash-line: #dce8df;
  min-width: 0;
  color: var(--dash-ink);
}
.dashboard .report-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px;
  margin-bottom: 18px;
  border: 1px solid var(--dash-line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 3px 12px rgba(21, 64, 37, 0.045);
}
.dashboard-refresh {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  margin: -8px 0 14px;
  border: 1px solid #dce8df;
  border-radius: 10px;
  background: #f3f8f4;
  color: #315d3e;
  font-size: 12px;
}
.dashboard-refresh.is-error {
  border-color: #f0d7c6;
  background: #fff8f1;
  color: #8d4a19;
}
.dashboard .period-nav {
  border: 1px solid var(--dash-line);
  box-shadow: none;
}
.dashboard .period-nav button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  padding: 0;
  border-radius: 9px;
  color: var(--dash-ink);
  transition: background-color 140ms ease, color 140ms ease;
}
.dashboard .period-nav button:hover:not(:disabled) {
  background: #edf5ef;
  color: var(--dash-accent);
}
.dashboard .period-nav button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}
.dashboard .period-nav span {
  min-width: 86px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.dashboard-date {
  animation: dashboard-date-change 180ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
.dashboard .kpis {
  gap: 14px;
  margin-bottom: 18px;
}
.dashboard .kpi {
  padding: 18px 18px 0;
  border: 1px solid #e4ebe5;
  border-radius: 16px;
  box-shadow: 0 4px 14px rgba(21, 64, 37, 0.045);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.dashboard .kpi:hover {
  border-color: #c4d9ca;
  box-shadow: 0 8px 22px rgba(21, 64, 37, 0.09);
}
.dashboard .kpi .label {
  color: #53675a;
  font-weight: 600;
}
.dashboard .kpi .value,
.dashboard .legend-stats .ls b,
.dashboard .amt {
  font-variant-numeric: tabular-nums;
}
.dashboard .row-main > .card,
.dashboard .row-3 > .card,
.dashboard > .card {
  border: 1px solid #e4ebe5;
  box-shadow: 0 4px 14px rgba(21, 64, 37, 0.045);
}
.dashboard .chart-head {
  border: 1px solid #e3ebe5;
  background: #f5f8f5;
}
.dashboard .chart-head h3,
.dashboard .card-title h3 {
  color: var(--dash-ink);
  letter-spacing: -0.02em;
}
.dashboard .segmented {
  border: 1px solid var(--dash-line);
  box-shadow: none;
}
.dashboard .segmented button {
  transition: background-color 150ms ease, color 150ms ease, box-shadow 150ms ease;
}
.dashboard .list li {
  border-radius: 10px;
  transition: background-color 140ms ease;
}
.dashboard .list li.dashboard-clickable:hover {
  background: #f2f7f3;
}
.dashboard-clickable {
  cursor: pointer;
}
.dashboard-clickable:focus-visible {
  outline: 3px solid rgba(33, 131, 74, 0.4);
  outline-offset: 2px;
}
.dashboard-loading,
.dashboard-load-error {
  min-height: 250px;
  padding: 20px;
  border: 1px solid var(--dash-line);
  border-radius: 18px;
  background: #fff;
}
.dashboard-skeleton {
  display: grid;
  gap: 14px;
}
.dashboard-skeleton-kpis {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 14px;
}
.dashboard-skeleton span,
.dashboard-skeleton-chart {
  min-height: 112px;
  border: 1px solid #e5ece6;
  border-radius: 14px;
  background: #f2f6f2;
}
.dashboard-skeleton-chart {
  min-height: 260px;
}
.dashboard-load-error p {
  max-width: 65ch;
  color: #53675a;
  overflow-wrap: anywhere;
}
.dashboard-load-error button {
  margin-top: 6px;
}
.dashboard-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
@keyframes dashboard-date-change {
  from {
    opacity: 0.55;
    filter: blur(2px);
  }
  to {
    opacity: 1;
    filter: blur(0);
  }
}
@media (max-width: 600px) {
  .page-head.dashboard-page-head {
    min-height: 96px;
    padding: 18px;
    border-radius: 16px;
  }
  .dashboard .report-controls {
    gap: 8px;
    padding: 8px;
  }
  .dashboard .report-controls > .segmented {
    margin-left: 0 !important;
    width: 100%;
    justify-content: center;
  }
  .dashboard-skeleton-kpis {
    grid-template-columns: 1fr;
  }
  .dashboard-skeleton-kpis span:nth-child(n + 2) {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .dashboard-date {
    animation: none;
  }
  .dashboard .period-nav button,
  .dashboard .kpi,
  .dashboard .segmented button,
  .dashboard .list li {
    transition: none;
  }
}
