/* GoStore — brand design system (iCloud GoStore/Brand/BRANDBOOK.md): Plus Jakarta Sans,
   GoStore blue #2457F5, graphite + ice white, dark mode from the system setting. */

/* ====== Tokens and base ====== */

:root {
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;

  --bg: #F5F5F7;
  --surface: #FFFFFF;
  --surface-2: #EEEEF1;
  --text: #141416;
  --muted: #6E6E73;
  --line: #D2D2D7;
  --separator: rgba(20, 20, 22, 0.08);
  --blue: #2457F5;
  --blue-hover: #1A47D8;
  --blue-soft: rgba(36, 87, 245, 0.10);
  --ok: #00A389;
  --ok-soft: rgba(0, 163, 137, 0.12);
  --warn: #B07C00;
  --warn-soft: rgba(255, 180, 0, 0.18);
  --err: #FF3B30;
  --err-soft: rgba(255, 59, 48, 0.10);
  --shadow: 0 1px 2px rgba(20, 20, 22, 0.04), 0 6px 20px rgba(20, 20, 22, 0.05);
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar-w: 248px;
  --tabbar-h: 58px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141416;
    --surface: #1C1C1F;
    --surface-2: #26262A;
    --text: #FFFFFF;
    --muted: #A1A1A6;
    --line: #2C2C30;
    --separator: rgba(255, 255, 255, 0.08);
    --blue-hover: #3A6AFF;
    --blue-soft: rgba(36, 87, 245, 0.22);
    --warn: #FFB400;
    --err-soft: rgba(255, 59, 48, 0.16);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }

/* Author rules that set `display` would otherwise beat the UA's [hidden] { display: none }. */
[hidden] { display: none !important; }

/* iOS enlarges text in wide scrolling blocks on its own; this keeps sizes as written. */
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
h1 { font-size: 30px; }
h2 { font-size: 18px; margin-bottom: 12px; }
p { margin: 0; }
a { color: var(--blue); text-decoration: none; }
svg { flex-shrink: 0; }

.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; margin-top: 6px; }
.text-center { text-align: center; }

/* ====== Shell: sidebar, topbar, content, tab bar ====== */

body.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100dvh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 22px 14px 16px;
  background: var(--surface);
  border-right: 1px solid var(--separator);
}

.sidebar-brand { display: block; padding: 4px 12px 22px; }
.sidebar-logo { display: block; height: 30px; width: auto; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 500;
}
.nav-link-icon { width: 20px; height: 20px; color: var(--muted); }
a.nav-link:hover { background: var(--surface-2); }
.nav-link.active { background: var(--blue-soft); color: var(--blue); font-weight: 600; }
.nav-link.active .nav-link-icon { color: var(--blue); }
.nav-link.is-soon { color: var(--muted); cursor: default; }
.nav-link.is-soon .nav-link-icon { opacity: 0.6; }

.soon-pill {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--separator);
}

.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 6px 4px 0 8px; }
.sidebar-user-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.sidebar-user-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-role { color: var(--muted); font-size: 12px; }

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--blue);
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar { display: none; }

.content {
  width: 100%;
  max-width: 1080px;
  padding: 36px 44px 56px;
}

.tabbar { display: none; }

@media (max-width: 899px) {
  body.app { display: block; }
  .sidebar { display: none; }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(10px + env(safe-area-inset-top)) 12px 10px 16px;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--separator);
  }
  .topbar-brand { display: block; }
  .topbar-logo { display: block; height: 26px; width: auto; }
  .topbar-actions { display: flex; align-items: center; gap: 2px; }

  .content { padding: 20px 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 28px); }

  .tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: grid;
    grid-auto-columns: 1fr;
    grid-auto-flow: column;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 86%, transparent);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: 1px solid var(--separator);
  }
  .tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 600;
  }
  .tab-icon { width: 24px; height: 24px; }
  .tab.active { color: var(--blue); }
  .tab.is-soon { opacity: 0.4; }
  .tab .soon-pill { display: none; }
}

/* ====== Page header, breadcrumb, flash ====== */

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.page-header .muted { margin-top: 6px; }
.page-header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.breadcrumb { display: flex; align-items: center; gap: 4px; margin-bottom: 10px; font-size: 14px; color: var(--muted); }
.breadcrumb-sep { width: 14px; height: 14px; }

.flash, .form-banner {
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 500;
}
.flash { margin: 20px 44px 0; max-width: 992px; transition: opacity 0.3s, transform 0.3s; }
.flash-leaving { opacity: 0; transform: translateY(-6px); }
.form-banner { margin-bottom: 18px; }
.flash-success { background: var(--ok-soft); color: var(--ok); }
.flash-error { background: var(--err-soft); color: var(--err); }

@media (max-width: 899px) {
  h1 { font-size: 26px; }
  .flash { margin: 14px 16px 0; }
}

/* ====== Buttons ====== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--blue); color: #FFFFFF; }
.btn-primary:hover { background: var(--blue-hover); }
.btn-secondary { background: var(--surface-2); color: var(--text); }
.btn-secondary:hover { background: var(--line); }
.btn:disabled { opacity: 0.45; cursor: default; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.active { color: var(--blue); }
.icon-btn-danger:hover { color: var(--err); background: var(--err-soft); }
.btn-danger { color: var(--err); }
.btn-danger:hover { background: var(--err-soft); }

/* ====== Cards, lists, tiles, badges ====== */

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 18px;
}

.group-title {
  margin: 22px 0 8px 16px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.group-title:first-of-type { margin-top: 0; }

.list {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.list-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  color: var(--text);
  position: relative;
}
.list-row + .list-row::before {
  content: '';
  position: absolute;
  top: 0;
  left: 64px;
  right: 0;
  border-top: 1px solid var(--separator);
}
a.list-row:hover { background: var(--surface-2); }
.list-row-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.list-row-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 600; }
.list-row-sub { color: var(--muted); font-size: 13px; }
.list-row-chevron { width: 18px; height: 18px; color: var(--muted); }
.list-row-actions { display: flex; align-items: center; gap: 2px; }
.list-row-actions form { display: contents; }

.app-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--c, var(--blue));
  color: #FFFFFF;
  flex-shrink: 0;
}
.app-icon svg { width: 19px; height: 19px; }

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 11.5px;
  font-weight: 600;
}
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-muted { background: var(--surface-2); color: var(--muted); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }

/* Chips: a one-of-many filter row (Məhsullar' stock states). */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.chip-count { color: var(--muted); font-weight: 500; }
.chip.active { background: var(--blue); color: #FFFFFF; }
.chip.active .chip-count { color: rgba(255, 255, 255, 0.75); }

@media (max-width: 899px) {
  /* One scrolling line instead of wrapping under each other. */
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px 14px; padding: 2px 16px 6px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex-shrink: 0; }
}

.empty-state { padding: 40px 16px; text-align: center; color: var(--muted); }

/* ====== Forms ====== */

.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; }

.field input:not([type="checkbox"]),
.field select {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field select {
  appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236E6E73' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}
.field select:disabled { opacity: 0.6; }
.field textarea {
  display: block;
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  resize: vertical;
}
.field textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.has-error input, .has-error select { border-color: var(--err); }
.field-error { margin-top: 6px; color: var(--err); font-size: 13px; }
.has-error .field textarea, .has-error textarea { border-color: var(--err); }

.field-row { display: flex; align-items: flex-end; gap: 12px; }
.field-row .field { flex: 1; margin-bottom: 0; }

/* A label over a control that isn't one input (a radio group). */
.field-label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; }

/* One-of-few choice as buttons (Satışın növü): radios inside labels. */
.segmented { display: inline-flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-2); flex-wrap: wrap; }
.segmented label { margin: 0; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 8px 18px; font-size: 14px; border-radius: 9px; font-weight: 600; color: var(--muted); }
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.segmented input:focus-visible + span { outline: 2px solid var(--blue); }

.check { display: inline-flex; align-items: center; gap: 10px; font-weight: 500; cursor: pointer; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--blue); cursor: pointer; }

.form-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.form-actions form { display: contents; }
.card > form > .form-actions { margin-top: 8px; }
/* Buttons laid out right-to-left: the markup can put the default (Enter) button first. */
.form-actions-rev { flex-direction: row-reverse; justify-content: flex-start; }
form > .form-actions:last-child { margin-bottom: 18px; }

/* An input with its unit inside the box: "₼", "ədəd". */
.input-unit { position: relative; }
.input-unit input:not([type="checkbox"]) { padding-right: 52px; }
.input-unit span {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 14px;
  pointer-events: none;
}

.search-field {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}
.search-field svg { position: absolute; left: 13px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search-field input {
  width: 100%;
  height: 44px;
  padding: 0 14px 0 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.search-field input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }

/* A photo on a form: preview + buttons (product_form.php). */
.photo-field { display: flex; align-items: center; gap: 18px; margin-bottom: 20px; }
.photo-field-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.photo-field-actions .hint { width: 100%; margin-top: 0; }

/* Read-only facts: label over value (a view-only person, an order's header). */
.info-list { margin: 0; display: flex; flex-direction: column; gap: 14px; }
.info-list dt { color: var(--muted); font-size: 12px; font-weight: 600; }
.info-list dd { margin: 2px 0 0; font-weight: 500; overflow-wrap: anywhere; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px 20px; }
.info-wide { grid-column: 1 / -1; }

/* Attached files (Şəxslər, Orderlər): rows + an upload form. */
.doc-list { border-top: 1px solid var(--separator); margin-bottom: 16px; }
.doc-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--separator); }
.doc-row form { display: contents; }
.doc-icon { width: 20px; height: 20px; color: var(--muted); }
.doc-name { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.doc-upload input[type="file"] { padding-top: 10px; }
.doc-empty { margin-bottom: 14px; }

@media (max-width: 899px) {
  /* 16px stops iOS zooming into a focused input. */
  .field input:not([type="checkbox"]), .field select { font-size: 16px; }
  .card { padding: 20px 16px; }
  .field-row { flex-direction: column; align-items: stretch; }
  .search-field input { font-size: 16px; }
}

/* ====== Tables ====== */

.table { width: 100%; border-collapse: collapse; }
.table th {
  padding: 8px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.table td { padding: 11px 10px; border-bottom: 1px solid var(--separator); }
.table tr:last-child td { border-bottom: 0; }
.table th.text-center { text-align: center; }

.table-scroll { overflow-x: auto; margin: 0 -8px; padding: 0 8px; }

/* ====== Page: Ana səhifə ====== */

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}
.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
  transition: transform 0.15s, box-shadow 0.15s;
}
a.tile:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(20, 20, 22, 0.05), 0 12px 28px rgba(20, 20, 22, 0.08); }
.tile-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--blue-soft);
  color: var(--blue);
}
.tile-icon svg { width: 22px; height: 22px; }
.tile-text { display: flex; flex-direction: column; gap: 2px; }
.tile-title { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.tile-sub { color: var(--muted); font-size: 13px; }
.tile .soon-pill { position: absolute; top: 18px; right: 18px; }
.tile.is-soon .tile-icon { background: var(--surface-2); color: var(--muted); }
.tile-settings .tile-icon { background: var(--surface-2); color: var(--text); }

@media (max-width: 899px) {
  .tile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .tile { padding: 16px; gap: 12px; }
  .tile-sub { display: none; }
  .tile .soon-pill { top: 14px; right: 12px; }
}

/* ====== Page: İstifadəçilər ====== */

.perm-table td:first-child { font-weight: 500; }
.perm-costs { margin-top: 18px; }

/* ====== Page: Məhsullar ====== */

.product-toolbar { display: flex; gap: 10px; margin-bottom: 14px; }
.product-toolbar .field { margin-bottom: 0; }
.product-toolbar-select { flex: 0 0 210px; }

.product-row { cursor: pointer; }
.product-list .list-row + .list-row::before { left: 78px; }
.product-row:hover, .product-row:focus-visible { background: var(--surface-2); outline: none; }

.product-thumb {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  display: grid;
  place-items: center;
  overflow: hidden;
  flex-shrink: 0;
}
.product-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.product-thumb svg { width: 22px; height: 22px; }
.product-thumb-lg { width: 88px; height: 88px; border-radius: 14px; }
.product-thumb-lg svg { width: 30px; height: 30px; }

.product-row .list-row-title { display: block; }
.star-mark { display: none; width: 15px; height: 15px; margin: 0 6px -2px 0; color: var(--warn); fill: currentColor; }
.product-row[data-starred="1"] .star-mark { display: inline-block; }
.star-toggle.is-starred { color: var(--warn); }
.star-toggle.is-starred svg { fill: currentColor; }

.product-stats { display: flex; gap: 6px; }
.product-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  width: 96px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.product-stat-qty { width: 84px; }
.product-stat-label { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.product-stat-hint { color: var(--muted); font-size: 12px; font-weight: 500; }
.product-stat-hint.to-buy { color: var(--blue); }
.qty-warning { color: var(--warn); }
.qty-danger { color: var(--err); }

/* Baxış: a centered sheet on desktop, a bottom sheet on a phone. */
.sheet {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  padding: 24px;
  border: 0;
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}
.sheet::backdrop { background: rgba(20, 20, 22, 0.4); backdrop-filter: blur(2px); }
.sheet-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.sheet-title { flex: 1; min-width: 0; padding-top: 4px; }
.sheet-title h2 { margin-bottom: 4px; }
.sheet .form-actions { margin-top: 20px; }

.pv-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.pv-stat, .stat-strip > div { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); }
.pv-label { color: var(--muted); font-size: 12px; font-weight: 600; }
.pv-value { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }

.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-top: 18px; }

/* Stok düzəlişi on the product's page. */
.adjust-direction { flex: 0 0 150px !important; }
.adjust-qty { flex: 0 0 140px !important; }
.adjust-history { margin-top: 18px; border-top: 1px solid var(--separator); }
.adjust-row { display: flex; align-items: baseline; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--separator); }
.adjust-row:last-child { border-bottom: 0; }
.adjust-change { width: 44px; font-weight: 700; font-variant-numeric: tabular-nums; }
.adjust-change.is-plus { color: var(--ok); }
.adjust-change.is-minus { color: var(--err); }
.adjust-note { flex: 1; min-width: 0; }
.adjust-meta { font-size: 13px; white-space: nowrap; }

/* Toplu əlavə et. */
.bulk-card { padding: 16px; }
.bulk-table { min-width: 820px; }
.bulk-table th, .bulk-table td { padding: 6px 4px; border-bottom: 0; }
.bulk-table input, .bulk-table select {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
.bulk-table input:focus, .bulk-table select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.bulk-table .cell-error { border-color: var(--err); background: var(--err-soft); }
.bulk-num { width: 28px; text-align: center; }
.bulk-sku { width: 130px; }
.bulk-name { width: 28%; }

/* Müştəri rejimi: a screen turned to a customer — no maya, rezerv, low-stock or edit controls. */
.customer-mode .cost,
.customer-mode .staff-only { display: none !important; }
.customer-mode .qty-warning, .customer-mode .qty-danger { color: inherit; }
.customer-mode-off { display: none; }
.customer-mode .customer-mode-on { display: none; }
.customer-mode .customer-mode-off { display: inline; }
.customer-mode #customer-mode-btn { background: var(--blue); color: #FFFFFF; }

@media (max-width: 899px) {
  .product-toolbar { flex-wrap: wrap; }
  .product-toolbar .search-field { flex-basis: 100%; }
  .product-toolbar-select { flex: 1 1 0; min-width: 0; }
  .product-row { gap: 12px; padding: 12px 14px; }
  .product-list .list-row + .list-row::before { left: 74px; }
  .product-stats .cost, .product-stat-label, .product-edit-link { display: none; }
  .product-stats { flex-direction: column; align-items: flex-end; gap: 0; }
  .product-stat, .product-stat-qty { width: auto; flex-direction: row; gap: 6px; align-items: baseline; }
  .product-stat-qty .qty::after { content: ' ədəd'; color: var(--muted); font-weight: 500; font-size: 13px; }
  .product-stat-hint { font-size: 11.5px; }
  .product-row .list-row-actions { margin-right: -8px; }

  .sheet {
    width: 100vw;
    max-width: 100vw;
    margin: auto 0 0;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
    border-radius: 20px 20px 0 0;
  }
  .pv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sheet .form-actions .btn { flex: 1; }

  .adjust-direction, .adjust-qty { flex: 1 1 auto !important; }
  .adjust-row { flex-wrap: wrap; row-gap: 2px; }
  .adjust-meta { width: 100%; padding-left: 58px; }
  .page-header-actions { width: 100%; }
  .page-header-actions .btn { flex: 1; padding: 0 12px; }
  /* A desktop job: the wide grid doesn't fit a phone. */
  .bulk-link { display: none; }
}

/* ====== Page: Kateqoriyalar ====== */

.cargo-tariff-field { flex: 0 0 160px !important; }
@media (max-width: 899px) {
  .cargo-tariff-field { flex: 1 1 auto !important; }
}

.category-edit-row .field { margin-bottom: 0; }
.category-edit-row input {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--blue);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  box-shadow: 0 0 0 3px var(--blue-soft);
}
.category-edit-row .list-row-actions { gap: 8px; }

/* ====== Page: Orderlər, Şəxslər ====== */

.order-row .list-row-title { align-items: center; }
.order-flags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.order-flag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px 2px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.order-flag svg { width: 13px; height: 13px; }
.order-flag.is-on { background: var(--ok-soft); color: var(--ok); }
dd.order-flags { margin-top: 4px; }
.order-total {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.order-receive-hint { margin: -12px 0 18px; text-align: right; }
.order-estimate { font-size: 14px; background: var(--surface-2); color: var(--muted); margin-bottom: 12px; }
.order-line-cancelled td { color: var(--muted); }
.order-line-cancelled .order-item-name { text-decoration: line-through; }
.order-items th.num, .order-items td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.order-items tfoot td { border-top: 1px solid var(--line); border-bottom: 0; font-weight: 600; }
.order-item { display: flex; align-items: center; gap: 12px; min-width: 170px; }
.order-items th, .order-items td { padding-left: 8px; padding-right: 8px; }
.order-item-name { display: block; font-weight: 600; }
.order-item-sku { display: block; font-size: 13px; }
.product-thumb-sm { width: 40px; height: 40px; border-radius: 9px; }
.order-edit-actions { justify-content: space-between; }

/* Ödənişlər (see_costs): the order's payments and refunds, and the Təhvil al window's figures. */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.card-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.order-payments { margin: 0 -8px; box-shadow: none; }
.order-paid { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--separator); }
.receive-summary { margin: 0 0 12px; }

/* The Karqo window. */
.cargo-checks { display: flex; flex-direction: column; gap: 12px; margin: 4px 0 18px; }
.cargo-weights { border-top: 1px solid var(--separator); padding-top: 14px; }
.cargo-weights-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; font-size: 13px; font-weight: 600; }
.cargo-weight-row { display: flex; align-items: center; gap: 12px; padding: 4px 0; }
.cargo-weight-name { flex: 1; min-width: 0; font-weight: 500; }
.cargo-weight-row .field { flex: 0 0 130px; margin-bottom: 0; }

/* Goods rows of a form (Yeni order, Yeni satış): cart-form.js. */
.cart-head, .cart-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px 128px 88px 38px;
  gap: 10px;
  align-items: center;
}
.cart-head { padding-bottom: 6px; color: var(--muted); font-size: 12px; font-weight: 600; }
.cart-line { margin-bottom: 10px; }
.cart-line .field { margin-bottom: 0; }
.cart-line-total { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cart-total { margin-top: 16px; font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.card.has-error { box-shadow: 0 0 0 2px var(--err-soft), var(--shadow); }

/* Məhsullar: rows picked for an order, and the bar that opens it. */
.order-pick { display: grid; place-items: center; width: 22px; flex-shrink: 0; }
.select-bar {
  position: sticky;
  bottom: 16px;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 10px 10px 10px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
}
.select-bar span { flex: 1; font-weight: 600; }

/* A product's open orders (product_form.php). */
.incoming-orders { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.incoming-order { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; background: var(--surface-2); color: var(--text); font-weight: 500; }
.incoming-order svg { width: 18px; height: 18px; color: var(--blue); }
.incoming-order span:first-of-type { flex: 1; min-width: 0; }
.incoming-order:hover { background: var(--line); }

.receiving-cost { width: 150px; }

@media (max-width: 899px) {
  .order-total { display: none; }
  .info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
  .order-receive-hint { text-align: left; margin-top: -8px; }
  .cart-head { display: none; }
  .cart-line {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 38px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--separator);
  }
  .cart-line-product { grid-column: 1 / -1; }
  .cart-line-total { grid-column: 1 / -1; text-align: left; }
  .cart-line-remove { grid-row: 2; grid-column: 3; }
  .cart-line-total:empty { display: none; }
  .order-edit-actions .btn { flex: 1; }
  .card-head-actions { width: 100%; }
  .card-head-actions .btn { flex: 1; }
  .select-bar { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 10px); }
  .select-bar .btn { padding: 0 12px; }
  .cargo-weight-row .field { flex-basis: 110px; }
  .receiving-cost { display: none !important; }
}

/* ====== Page: Satış ====== */

.sale-summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 8px; }
.sale-summary .pv-stat { background: var(--surface); box-shadow: var(--shadow); }
.group-title-split { display: flex; justify-content: space-between; padding-right: 16px; }
.sale-amount {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.money-minus { color: var(--err); }
/* A long goods summary: two lines at most. */
.line-clamp { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.reservation-actions { gap: 8px; }
.sale-date-field { flex: 0 0 200px !important; }

/* The talon window: one block per sale line. */
.warranty-line { padding: 12px 0; border-top: 1px solid var(--separator); }
.warranty-line .check { margin-bottom: 8px; font-weight: 600; }
.warranty-line .field { margin-bottom: 0; }
.warranty-months { flex: 0 0 110px !important; }

@media (max-width: 899px) {
  .sale-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .reservation-row { flex-wrap: wrap; }
  .reservation-actions { width: 100%; padding-left: 48px; }
  .reservation-actions .btn { flex: 1; }
  .sale-date-field { flex: 1 1 auto !important; }
  .warranty-line .field-row { flex-direction: row; }
  .form-actions-rev .btn { flex: 1; }
}

/* ====== Page: Müştərilər ====== */

/* The row is a link plus the star beside it (a button can't sit inside a link). */
.customer-row { padding: 0 10px 0 0; gap: 4px; }
.customer-link { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; padding: 14px 6px 14px 16px; color: var(--text); }
.customer-row:hover { background: var(--surface-2); }
span.star-toggle { cursor: default; }
.customer-edit { margin-top: 22px; }

/* ====== Page: Maliyyə ====== */

.finance-balance-link { margin-bottom: 14px; }
.finance-hint { margin: 0 0 8px 16px; }
.finance-entry-form .field-row { margin-bottom: 16px; }
.finance-amount-field { flex: 0 0 220px !important; }
.finance-subcategory { padding-left: 44px; }
.finance-account-form .field:nth-child(2) { flex: 0 0 180px; }
.finance-account-form .field:nth-child(3) { flex: 0 0 200px; }
/* An order payment's orders (and each one's part), a refund's order / product / cancellation. */
.finance-orders, .finance-refund { margin-bottom: 16px; }
.finance-order-row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.finance-order-row select { flex: 1; min-width: 0; }
.finance-order-amount { flex: 0 0 150px; }
.finance-order-row .field-error, .finance-orders > .field-error { margin-top: 0; }
.finance-order-add { margin-top: 2px; }
.finance-refund-cancel { display: flex; flex-direction: column; gap: 12px; }
.finance-refund-cancel .field { max-width: 220px; margin: 0; }
.finance-refund-cancel .hint { margin: 0; }
/* The account picker beside "Sat" on a pending reservation. */
.reservation-confirm .field { margin: 0; }
.reservation-confirm select { height: 40px; width: auto; min-width: 170px; }

@media (max-width: 899px) {
  .finance-amount-field, .finance-account-form .field { flex: 1 1 auto !important; }
  .finance-subcategory { padding-left: 32px; }
  /* Four types: a tidy 2 × 2 instead of 3 + 1. */
  .finance-entry-form .segmented { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .finance-entry-form .segmented span { text-align: center; }
  .finance-order-row { flex-wrap: wrap; }
  .finance-order-row select { flex: 1 1 100%; }
  .finance-order-amount { flex: 1; }
  /* The picker takes its own line above Ləğv et / Sat. */
  .reservation-actions:has(.reservation-confirm .field) { flex-wrap: wrap; }
  .reservation-confirm .field { flex: 1 1 100%; order: -1; }
  .reservation-confirm select { width: 100%; min-width: 0; height: 44px; }
}

/* Hesabat (finance_report.php): month-by-month tables, share bars, Dinamika charts. */
.pv-sub { color: var(--muted); font-size: 12px; }
.rpt-month { display: flex; align-items: center; gap: 6px; margin-bottom: 14px; }
.rpt-month b { min-width: 170px; text-align: center; }
.rpt-month .is-off { opacity: 0.3; pointer-events: none; }
.rpt-back { transform: rotate(180deg); }
.rpt-card h2 { margin-bottom: 14px; }
/* No scroll padding: the sticky label column must sit at the very edge, or the months show beside it. */
.rpt-card .table-scroll, .rpt-data .table-scroll { margin: 0; padding: 0; }
.rpt-card .hint { margin-top: 14px; }
.rpt-num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rpt-quiet { color: var(--muted); }
.rpt-warn { color: var(--warn); }
.rpt-table th, .rpt-table td { padding: 9px 10px; font-size: 14px; }
.rpt-table thead th a { color: var(--muted); }
.rpt-table tbody th { text-align: left; font-weight: 500; white-space: nowrap; }
/* The label column stays put while the months scroll under it. */
.rpt-table tbody th, .rpt-table thead th:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); }
.rpt-table .is-cur { background: var(--blue-soft); }
.rpt-table thead th.is-cur a { color: var(--blue); }
.rpt-table .rpt-year { font-weight: 600; border-left: 1px solid var(--separator); }
.rpt-minor th { color: var(--muted); }
.rpt-key th, .rpt-key td, .rpt-group th, .rpt-group td { font-weight: 700; }
.rpt-total th, .rpt-total td { border-top: 1px solid var(--line); }
.rpt-sub th { padding-left: 30px; color: var(--muted); }
.rpt-sub td { color: var(--muted); }
.rpt-ref td, .rpt-ref th { border-bottom: 1px solid var(--line); }
.rpt-gap td { padding: 6px; border: 0; }
.rpt-toggle { display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.rpt-toggle svg { width: 14px; height: 14px; color: var(--muted); transition: transform 0.15s; }
.rpt-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }
.rpt-sku { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.rpt-sortable thead button { padding: 0; border: 0; background: none; font: inherit; color: inherit; cursor: pointer; }
.rpt-sortable thead button[aria-sort]::after { content: ' ↓'; }
.rpt-sortable thead button[aria-sort="ascending"]::after { content: ' ↑'; }
.rpt-abc { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.rpt-abc.is-a { background: var(--blue); color: #FFFFFF; }
.rpt-abc.is-b { background: var(--blue-soft); color: var(--blue); }
.rpt-share + .rpt-share { margin-top: 16px; }
.rpt-share-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.rpt-share-head .muted { font-size: 13px; }
.rpt-bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.rpt-bar span { display: block; height: 100%; border-radius: 4px; background: var(--blue); }
.rpt-two { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.rpt-two .group-title:first-of-type { margin-top: 0; }
.rpt-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.rpt-chart-card { padding: 20px; margin-bottom: 0; }
.rpt-chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.rpt-chart-head h2 { margin-bottom: 2px; }
.rpt-chart-head .muted { font-size: 12.5px; }
.rpt-chart-value { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rpt-chart { position: relative; height: 190px; touch-action: pan-y; }
.rpt-svg { display: block; overflow: visible; }
.rpt-grid { stroke: var(--separator); }
.rpt-axis { stroke: var(--line); }
.rpt-tick { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.rpt-bar-pos { fill: var(--blue); }
.rpt-bar-neg { fill: var(--err); }
.rpt-line { fill: none; stroke: var(--blue); stroke-width: 2; stroke-linejoin: round; }
.rpt-dot { fill: var(--blue); stroke: var(--surface); stroke-width: 2; }
.rpt-hover { fill: var(--surface-2); }
.rpt-tip {
  position: absolute;
  top: -6px;
  display: flex;
  flex-direction: column;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow), 0 0 0 1px var(--separator);
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
}
.rpt-tip span { color: var(--muted); }
.rpt-tip b { font-size: 14px; font-variant-numeric: tabular-nums; }
.rpt-data { margin-top: 18px; }
.rpt-data summary { cursor: pointer; font-weight: 600; }
.rpt-data .table-scroll { margin-top: 12px; }

@media (max-width: 899px) {
  .rpt-two, .rpt-charts { grid-template-columns: 1fr; }
  .rpt-chart-card { padding: 16px; }
  .rpt-month b { min-width: 0; flex: 1; }
  /* A narrow label column leaves room for the months. */
  .rpt-table tbody th { white-space: normal; min-width: 104px; max-width: 124px; }
  .rpt-table th, .rpt-table td { padding: 8px 7px; font-size: 13px; }
}

/* ====== Login and error pages ====== */

.auth-body {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 40px 36px 32px;
  background: var(--surface);
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.auth-brand { display: flex; justify-content: center; margin-bottom: 30px; }
.auth-logo { height: 38px; width: auto; display: block; }
.auth-title { font-size: 24px; margin-bottom: 20px; }
.auth-actions .btn { width: 100%; }
.auth-link { display: block; margin-top: 18px; text-align: center; font-size: 14px; font-weight: 500; }

.error-page { text-align: center; }
.error-page-code { font-size: 64px; font-weight: 800; color: var(--blue); letter-spacing: -0.04em; line-height: 1; margin-bottom: 14px; }
.error-page .auth-title { margin-bottom: 10px; }
.error-page-ref { margin-top: 14px; color: var(--muted); font-size: 13px; }
.error-page-actions { display: flex; justify-content: center; gap: 10px; margin-top: 26px; }

@media (max-width: 480px) {
  .auth-card { padding: 32px 22px 26px; }
}

/* ====== Permissions: a section the user may see but not change (partials/header.php) ====== */

.page-view-only .content form[method="post"],
.page-view-only .content .edit-only { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
