/* magaza.one — design system. Built on tex.az's (docs/PORTED.md): Plus Jakarta Sans, graphite for
   actions, one brand colour as fill / marker (--brand, ours until the real brand exists), soft
   cards, a sidebar menu, work-desk pages (filters | list | the open item). Dark mode follows the system. */

/* ====== Font ====== */

@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url(fonts/plus-jakarta-sans-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url(fonts/plus-jakarta-sans-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

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

:root {
  --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --bg: #F4F4F2;
  --surface: #FFFFFF;
  --surface-2: #F1F1EE;
  --surface-3: #E7E7E3;
  --text: #17171A;
  --muted: #6B6C70;
  --faint: #9C9DA1;
  --line: #E4E4E0;
  --line-strong: #D3D3CE;
  --separator: rgba(23, 23, 26, 0.08);

  --primary: #17171A;
  --primary-hover: #2E2E33;
  --on-primary: #FFFFFF;
  --brand: #7C5CFF;
  --brand-strong: #6A48F5;
  --brand-soft: rgba(124, 92, 255, 0.12);
  --on-brand: #FFFFFF;

  --ok: #15803D;
  --ok-soft: rgba(22, 163, 74, 0.12);
  --warn: #C26A00;
  --warn-soft: rgba(234, 88, 12, 0.12);
  --err: #DC2626;
  --err-soft: rgba(220, 38, 38, 0.10);

  --shadow-sm: 0 1px 2px rgba(23, 23, 26, 0.05);
  --shadow: 0 1px 2px rgba(23, 23, 26, 0.04), 0 3px 12px rgba(23, 23, 26, 0.045);
  --shadow-pop: 0 2px 6px rgba(23, 23, 26, 0.06), 0 18px 48px rgba(23, 23, 26, 0.18);
  --focus-ring: 0 0 0 3px rgba(124, 92, 255, 0.35);
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar-w: 240px;
  --tabbar-h: 60px;
  color-scheme: light dark;
}

/* Dark tokens: on a dark device unless the firm fixed light (Ayarlar › Görünüş), or always when it
   fixed dark (Theme::htmlAttr). The accent colours are overridden by Theme::styleTag(). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111112;
    --surface: #1B1B1D;
    --surface-2: #242427;
    --surface-3: #2E2E32;
    --text: #F4F4F5;
    --muted: #A2A2A9;
    --faint: #707077;
    --line: #2B2B2F;
    --line-strong: #3B3B40;
    --separator: rgba(255, 255, 255, 0.08);

    --primary: #F4F4F5;
    --primary-hover: #FFFFFF;
    --on-primary: #17171A;
    --brand: #9A82FF;
    --brand-strong: #B3A1FF;
    --brand-soft: rgba(154, 130, 255, 0.18);

    --ok: #4ADE80;
    --ok-soft: rgba(74, 222, 128, 0.14);
    --warn: #FB923C;
    --warn-soft: rgba(251, 146, 60, 0.16);
    --err: #F87171;
    --err-soft: rgba(248, 113, 113, 0.16);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.03);
    --shadow-pop: 0 2px 6px rgba(0, 0, 0, 0.4), 0 20px 50px rgba(0, 0, 0, 0.6);
  }
}
:root[data-theme="dark"] {
  --bg: #111112;
  --surface: #1B1B1D;
  --surface-2: #242427;
  --surface-3: #2E2E32;
  --text: #F4F4F5;
  --muted: #A2A2A9;
  --faint: #707077;
  --line: #2B2B2F;
  --line-strong: #3B3B40;
  --separator: rgba(255, 255, 255, 0.08);

  --primary: #F4F4F5;
  --primary-hover: #FFFFFF;
  --on-primary: #17171A;
  --brand: #9A82FF;
  --brand-strong: #B3A1FF;
  --brand-soft: rgba(154, 130, 255, 0.18);

  --ok: #4ADE80;
  --ok-soft: rgba(74, 222, 128, 0.14);
  --warn: #FB923C;
  --warn-soft: rgba(251, 146, 60, 0.16);
  --err: #F87171;
  --err-soft: rgba(248, 113, 113, 0.16);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.03);
  --shadow-pop: 0 2px 6px rgba(0, 0, 0, 0.4), 0 20px 50px rgba(0, 0, 0, 0.6);
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body { padding-bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); }
button, input, select, textarea { font-family: inherit; }
::selection { background: var(--brand-soft); }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
h2 { font-size: 17px; font-weight: 750; letter-spacing: -0.015em; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

.env-badge {
  flex-shrink: 0;
  padding: 3px 7px;
  border-radius: 6px;
  background: #FDE68A;
  color: #78350F;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

/* The firm's mark: its own logo, or its first letter on the brand colour. */
.firm-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--brand);
  color: var(--on-brand);
  font-size: 16px;
  font-weight: 800;
  overflow: hidden;
}
.firm-mark.has-logo { background: #FFFFFF; border: 1px solid var(--line); }
.firm-mark img { width: 100%; height: 100%; object-fit: contain; padding: 3px; }

/* ====== Shell: sidebar (≥768px, an icon rail up to 1279px), phone top bar + tab bar ====== */

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.logout-form { display: inline-flex; margin: 0; }

.sidebar { display: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(9px + env(safe-area-inset-top)) 12px 9px 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 .firm-mark { width: 28px; height: 28px; border-radius: 8px; font-size: 14px; }
.topbar-title { flex: 1; min-width: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  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);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
.tab {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
}
.tab svg { width: 52px; height: 30px; padding: 4px 15px; border-radius: 999px; transition: background 0.2s ease; }
.tab.active { color: var(--text); }
.tab.active svg { background: var(--brand-soft); color: var(--brand-strong); }

.content { max-width: 1760px; margin: 0 auto; padding: 18px 16px 40px; }

@media (min-width: 768px) {
  body { padding-left: var(--sidebar-w); padding-bottom: 24px; }
  .topbar, .tabbar { display: none; }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 25;
    display: flex;
    flex-direction: column;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--line);
  }
  .sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px 16px 20px; }
  .sidebar-firm { flex: 1; min-width: 0; font-size: 15.5px; font-weight: 750; letter-spacing: -0.02em; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .sidebar-nav { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 12px 14px; }
  .nav-group + .nav-group { margin-top: 14px; }
  .nav-group-title { padding: 0 10px 5px; font-size: 11px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--faint); }
  .nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 7px 10px;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
    transition: background 0.12s ease;
  }
  .nav-link-label { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .nav-link svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--muted); }
  .nav-link:hover { background: var(--surface-2); }
  .nav-link.active { background: var(--brand-soft); font-weight: 650; }
  .nav-link.active svg { color: var(--brand-strong); }
  .nav-link.active::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 7px;
    bottom: 7px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--brand);
  }
  .sidebar-foot { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px 14px; border-top: 1px solid var(--line); }
  .sidebar-user { display: flex; align-items: center; gap: 10px; margin-top: 6px; padding: 6px 2px 0 6px; }
  .avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--surface-3);
    font-size: 12.5px;
    font-weight: 700;
  }
  .sidebar-user-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
  .sidebar-user-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sidebar-user-role { font-size: 12px; color: var(--muted); }

  .content { padding: 30px 32px 40px; }
}
@media (min-width: 768px) and (max-width: 1279px) {
  :root { --sidebar-w: 76px; }
  .sidebar-brand { justify-content: center; padding: 20px 0 14px; }
  .sidebar-firm, .sidebar-brand .env-badge, .nav-group-title, .nav-link-label, .sidebar-user-text { display: none; }
  .sidebar-nav { padding: 2px 10px 12px; }
  .nav-group + .nav-group { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--separator); }
  .nav-link { justify-content: center; padding: 9px 0; }
  .nav-link svg { width: 20px; height: 20px; }
  .nav-link.active::before { left: -10px; }
  .sidebar-foot { padding: 10px 10px 14px; }
  .sidebar-user { flex-direction: column; gap: 6px; margin-top: 4px; padding: 6px 0 0; }
  .content { padding: 26px 24px 40px; }
}
@media (min-width: 1500px) {
  .content { padding-left: 48px; padding-right: 48px; }
}

/* ====== Page header ====== */

.page-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-header h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.15; margin: 0; }
.page-header-count { font-size: 0.6em; font-weight: 600; color: var(--muted); letter-spacing: normal; }
.page-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.page-lead { margin: -12px 0 20px; color: var(--muted); }
.breadcrumb { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 10px; font-size: 13px; font-weight: 600; color: var(--muted); }
.breadcrumb svg { width: 15px; height: 15px; }
.breadcrumb:hover { color: var(--text); }

/* ====== Flash: a toast top-right (app.js hides it) ====== */

.flash {
  position: fixed;
  top: calc(64px + env(safe-area-inset-top));
  right: 16px;
  z-index: 60;
  max-width: min(380px, calc(100vw - 32px));
  padding: 13px 18px 13px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  border-left: 4px solid currentColor;
  background: var(--surface);
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-pop);
  animation: flash-in 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@media (min-width: 768px) { .flash { top: 22px; right: 24px; } }
.flash.flash-leaving { animation: flash-out 0.3s ease forwards; }
@keyframes flash-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes flash-out { to { opacity: 0; transform: translateX(24px); } }
.flash-success { color: var(--ok); }
.flash-error { color: var(--err); }
/* In-page banners (form errors) stay until fixed. */
.banner { margin-bottom: 16px; padding: 12px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; }
.banner-error { background: var(--err-soft); color: var(--err); }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 8px 17px;
  font-size: 14.5px;
  font-weight: 650;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.btn svg { width: 17px; height: 17px; flex-shrink: 0; }
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-ghost.danger:hover { background: var(--err-soft); color: var(--err); }
.btn-sm { min-height: 32px; padding: 5px 12px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }

/* ====== Cards, lists ====== */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 20px; margin-bottom: 20px; }
.card-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.card-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--separator); }
.card-row:last-child { border-bottom: 0; }
.card-row-main { flex: 1; min-width: 0; }
.card-row-title { font-size: 14.5px; font-weight: 650; line-height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-row-sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-row.is-off .card-row-title { color: var(--muted); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); font-size: 12px; font-weight: 650; white-space: nowrap; }
.pill-off { color: var(--muted); }

.empty-state { padding: 52px 20px; text-align: center; color: var(--muted); }
.empty-state > svg { width: 36px; height: 36px; color: var(--faint); margin-bottom: 10px; }
.empty-state p { margin: 0 0 16px; font-size: 15px; font-weight: 500; }

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

.search-bar { position: relative; flex: 1 1 auto; min-width: 0; }
.search-bar input {
  width: 100%;
  height: 42px;
  padding: 0 14px 0 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239C9DA1' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") 13px center / 17px no-repeat;
  font-size: 15px;
  color: var(--text);
}
.search-bar input:focus { outline: none; border-color: var(--text); box-shadow: var(--focus-ring); }
.search-bar input::placeholder { color: var(--faint); }

.form-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 20px 20px 6px; margin-bottom: 20px; }
.form-card h2 { margin-top: 18px; }
.form-card h2:first-of-type { margin-top: 2px; }
.form-card .form-actions { padding-bottom: 14px; }
.field { padding: 0 0 14px; min-width: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; column-gap: 12px; }
.field-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.field label { display: block; font-size: 13px; font-weight: 650; margin-bottom: 6px; }
.field-hint { font-weight: 500; color: var(--faint); }
.field :where(input:not([type="checkbox"], [type="radio"], [type="file"], [type="hidden"]), select, textarea) {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background-color: var(--surface);
  font-size: 15px;
  color: var(--text);
  padding: 0 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field :where(textarea) { padding: 10px 12px; line-height: 1.45; resize: vertical; }
.field :where(select), select.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B6C70' 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 11px center;
  background-size: 15px;
}
select.select { min-height: 42px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background-color: var(--surface); color: var(--text); font-size: 14.5px; padding-left: 12px; }
.field :where(input, select, textarea):focus, select.select:focus { outline: none; border-color: var(--text); box-shadow: var(--focus-ring); }
.field :where(input, textarea)::placeholder { color: var(--faint); }
.field.has-error :where(input, select, textarea) { border-color: var(--err); }
.field-error { margin-top: 5px; font-size: 12.5px; font-weight: 600; color: var(--err); }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 34px !important; }
.input-suffix span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; pointer-events: none; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 560px) { .field-row, .field-row-3 { grid-template-columns: 1fr; } }

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

.table-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; margin-bottom: 20px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--separator); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table th { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }
.table td.actions { text-align: right; white-space: nowrap; }
.table tr.is-off td { color: var(--muted); }
.cell-person { display: flex; align-items: center; gap: 10px; font-weight: 650; }
.cell-person .avatar { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; background: var(--surface-3); font-size: 12px; font-weight: 700; flex-shrink: 0; }
@media (max-width: 640px) { .table .hide-sm { display: none; } .table th, .table td { padding: 10px 12px; } }

/* ====== Work desk: filter column | list | the open item (Məhsullar) ====== */

.desk-side, .desk-panel { display: none; }
.desk-main { min-width: 0; }
.desk-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.desk-toolbar .search-bar { flex: 1 1 260px; }
.desk-toolbar .select { flex: 1 1 150px; max-width: 240px; }
/* An open item on a narrow screen: the panel alone, with its own back link. */
.desk.has-open .desk-main, .desk.has-open .page-header-desk { display: none; }
.desk.has-open .desk-panel { display: block; }
.panel-back { display: inline-flex; }

@media (min-width: 1000px) {
  .desk { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }
  .desk.has-open .desk-main { display: block; }
  .desk-panel { display: block; position: sticky; top: 24px; }
  .panel-back { display: none; }
}
@media (min-width: 1180px) and (max-width: 1279px), (min-width: 1400px) {
  .desk { grid-template-columns: 200px minmax(0, 1fr) 340px; }
  .desk-side { display: flex; }
  .desk-toolbar .select { display: none; }
}

.desk-side {
  position: sticky;
  top: 24px;
  flex-direction: column;
  gap: 22px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 2px 4px 6px 0;
}
.side-title { padding: 0 10px 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--faint); }
.side-list { display: flex; flex-direction: column; gap: 1px; }
.side-item { display: flex; align-items: center; gap: 9px; padding: 6px 10px; border-radius: 9px; font-size: 13.5px; font-weight: 500; line-height: 20px; transition: background 0.12s ease; }
.side-item:hover { background: var(--surface-2); }
.side-item.active { background: var(--brand-soft); font-weight: 650; }
.side-item svg { width: 17px; height: 17px; flex-shrink: 0; color: var(--muted); }
.side-item.state-in svg { color: var(--ok); }
.side-item.state-out svg { color: var(--err); }
.side-item-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-item-count { font-size: 12px; font-weight: 600; color: var(--faint); font-variant-numeric: tabular-nums; }
.side-item.active .side-item-count { color: var(--text); }
.side-dot { width: 8px; height: 8px; margin: 0 4px 0 5px; border-radius: 3px; background: var(--surface-3); flex-shrink: 0; }
.side-item.active .side-dot { background: var(--brand); }
.side-link { display: block; padding: 6px 10px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.side-link:hover { color: var(--text); }

/* Product rows: thumb, name + code · category, then Alış | Satış | Say. */
.plist-head, .product-row { display: grid; grid-template-columns: minmax(0, 1fr) 88px 88px 56px; align-items: center; column-gap: 12px; padding: 10px 16px; }
.plist-head { position: sticky; top: 0; z-index: 2; min-height: 40px; background: var(--surface); border-bottom: 1px solid var(--line); font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }
.plist-head .plh-main { padding-left: 56px; }
.plist.no-cost .plist-head, .plist.no-cost .product-row { grid-template-columns: minmax(0, 1fr) 88px 56px; }
.product-row { border-bottom: 1px solid var(--separator); transition: background 0.12s ease; }
.product-row:last-child { border-bottom: 0; }
.product-row:hover { background: color-mix(in srgb, var(--surface-2) 70%, var(--surface)); }
.product-row.active { background: var(--brand-soft); }
.product-row.is-off .pr-title { color: var(--muted); text-decoration: line-through; }
.pr-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.pr-thumb {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--faint);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.pr-text { min-width: 0; }
.pr-title { font-size: 14px; font-weight: 600; line-height: 20px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pr-sub { display: block; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.num-col { text-align: right; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.num-col.cost { color: var(--muted); font-weight: 500; }
.num-col.qty-out { color: var(--err); }
.cur { font-size: 0.85em; margin-left: 1px; }
.pager { display: flex; gap: 12px; justify-content: center; align-items: center; margin-top: 16px; font-size: 14px; }

@media (max-width: 767px) {
  .plist-head { display: none; }
  .product-row, .plist.no-cost .product-row { grid-template-columns: minmax(0, 1fr) auto; row-gap: 2px; padding: 12px 14px; }
  .product-row .num-col.cost { display: none; }
  .product-row .num-col.price { grid-row: 1; grid-column: 2; }
  .product-row .num-col.qty { grid-row: 2; grid-column: 2; font-size: 12.5px; color: var(--muted); }
  .product-row .num-col.qty::after { content: ' əd.'; }
  .product-row .num-col.qty-out { color: var(--err); }
  .product-row .pr-main { grid-row: 1 / 3; }
  .pr-thumb { width: 40px; height: 40px; }
}

/* The right panel: the open product (or a new one), else the totals. */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.panel-head { display: flex; align-items: flex-start; gap: 10px; padding: 16px 14px 6px 18px; }
.panel-head h2 { flex: 1; min-width: 0; margin: 0; font-size: 18px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.25; }
.panel-head .icon-btn { margin: -6px -4px 0 0; }
.panel-sub { padding: 0 18px 12px; font-size: 13px; color: var(--muted); }
.panel-body { padding: 8px 18px 4px; }
.panel-foot { display: flex; align-items: center; gap: 8px; padding: 4px 18px 16px; }
.panel-foot form { margin: 0; }
.panel-note { padding: 0 18px 16px; font-size: 12.5px; color: var(--muted); }
.panel-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--separator); border-top: 1px solid var(--separator); border-bottom: 1px solid var(--separator); }
.panel-stat { padding: 12px 18px; background: var(--surface); }
.panel-stat-label { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.panel-stat-value { font-size: 18px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.panel-stat-value.margin-ok { color: var(--ok); }
.panel-empty { padding: 30px 22px 26px; text-align: center; color: var(--muted); }
.panel-empty > svg { width: 34px; height: 34px; color: var(--faint); margin-bottom: 8px; }
.panel-empty-title { margin: 0 0 4px; font-size: 14px; font-weight: 700; color: var(--text); }
.panel-empty p { margin: 0 0 16px; font-size: 12.5px; }
.panel .field label { font-size: 12.5px; }
.panel .field { padding-bottom: 12px; }
.panel .field-row { column-gap: 10px; }

/* ====== Ayarlar › Firma: logo ====== */

.logo-row { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; padding-bottom: 14px; }
.logo-box { width: 160px; height: 100px; border: 1px dashed var(--line-strong); border-radius: 12px; display: flex; align-items: center; justify-content: center; background: var(--surface-2); color: var(--faint); font-size: 13px; }
.logo-box img { max-width: 140px; max-height: 80px; object-fit: contain; }
.logo-actions { display: flex; flex-direction: column; gap: 8px; }
.logo-actions form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }
.logo-actions input[type=file] { font-size: 13px; }

/* ====== Login ====== */

.auth-body { min-height: 100vh; padding: 0; }
.auth-shell { display: flex; min-height: 100vh; min-height: 100dvh; }
.auth-side { display: none; }
.auth-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 30px; }
.auth-brand .firm-mark { width: 44px; height: 44px; font-size: 20px; border-radius: 12px; }
.auth-brand-text { display: flex; flex-direction: column; gap: 2px; font-size: 17px; font-weight: 750; }
.auth-brand-text span { font-size: 13px; font-weight: 500; color: var(--muted); }
.auth-brand .env-badge { margin-left: auto; align-self: flex-start; }
.auth-title { margin: 0 0 22px; font-size: 28px; font-weight: 800; letter-spacing: -0.03em; }
.auth-card .field input { min-height: 46px; }
.auth-card .btn { width: 100%; min-height: 46px; margin-top: 8px; }
@media (min-width: 768px) {
  .auth-body { padding-left: 0; }
  .auth-side {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex: 0 0 min(44%, 560px);
    padding: 44px 48px;
    overflow: hidden;
    background: #17171A;
    color: #F4F4F5;
  }
  .auth-side::after {
    content: '';
    position: absolute;
    right: -120px;
    bottom: -120px;
    width: 420px;
    height: 420px;
    border-radius: 96px;
    background: var(--brand);
    opacity: 0.16;
    transform: rotate(18deg);
  }
  .auth-side-brand { display: flex; align-items: center; gap: 12px; font-size: 22px; font-weight: 800; letter-spacing: -0.03em; }
  .auth-side-title { max-width: 380px; margin: 0 0 22px; font-size: 32px; font-weight: 800; letter-spacing: -0.035em; line-height: 1.15; }
  .auth-side-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 12px; font-size: 15px; color: #C9C9CE; }
  .auth-side-list li { display: flex; align-items: center; gap: 12px; }
  .auth-side-list li::before { content: ''; flex-shrink: 0; width: 8px; height: 8px; border-radius: 2px; background: var(--brand); }
  .auth-side-foot { font-size: 13px; color: #8E8E93; }
}

/* ====== Ana səhifə ====== */

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.tile { display: flex; flex-direction: column; gap: 6px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); transition: box-shadow 0.15s ease, transform 0.15s ease; }
a.tile:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.tile svg { width: 22px; height: 22px; color: var(--brand-strong); }
.tile-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.tile-value { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  .flash, .flash.flash-leaving { animation: none; }
}
.panel-stats + .panel-note { padding-top: 12px; }
.form-hint { margin: -6px 0 14px; font-size: 13px; color: var(--muted); }
.narrow { max-width: 760px; }
.add-row { display: flex; gap: 8px; margin-bottom: 14px; }
.add-row .field { flex: 1; padding: 0; }
.cat-row { padding: 8px 10px 8px 16px; }
.cat-icon svg { width: 18px; height: 18px; color: var(--muted); display: block; }
.cat-edit { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; margin: 0; }
.cat-edit input { flex: 1; min-width: 0; min-height: 36px; padding: 0 10px; border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--text); font-size: 14.5px; font-weight: 600; }
.cat-edit input:hover { border-color: var(--line); }
.cat-edit input:focus { outline: none; border-color: var(--text); background: var(--surface); box-shadow: var(--focus-ring); }
.cat-edit .btn { visibility: hidden; }
.cat-edit:focus-within .btn { visibility: visible; }
.cat-row > form:last-child { margin: 0; }
.cat-row > form { margin: 0; }
.cat-row.is-off .cat-edit input { color: var(--muted); }
.table td.actions form { margin: 0; display: inline-flex; }
@media (min-width: 768px) { .auth-brand .firm-mark, .auth-brand-text { display: none; } .auth-brand { margin-bottom: 18px; } .auth-side .firm-mark { width: 40px; height: 40px; font-size: 18px; } }

/* ====== Ayarlar: tabs, Görünüş ====== */

.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--surface-3); }
.seg-btn { display: inline-flex; align-items: center; height: 34px; padding: 0 14px; border-radius: 9px; color: var(--muted); font-size: 13.5px; font-weight: 650; white-space: nowrap; }
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.settings-tabs { margin: -6px 0 18px; }
.settings-tabs + .page-lead { margin-top: 0; }

.btn-brand { background: var(--brand); color: var(--on-brand); }
.btn-brand:hover { background: var(--brand-strong); }

.appearance-grid { display: grid; gap: 0 20px; }
@media (min-width: 1000px) { .appearance-grid { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; } .preview { position: sticky; top: 24px; } }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; padding-bottom: 16px; }
.swatch { position: relative; display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 12px 6px 10px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; transition: border-color 0.15s ease, background 0.15s ease; }
.swatch:hover { background: var(--surface-2); }
.swatch input[type=radio] { position: absolute; opacity: 0; pointer-events: none; }
.swatch-dot { width: 32px; height: 32px; border-radius: 50%; background: var(--swatch); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08); }
.swatch-label { font-size: 12px; font-weight: 600; color: var(--muted); text-align: center; }
.swatch:has(input[type=radio]:checked) { border-color: var(--text); box-shadow: 0 0 0 1px var(--text); }
.swatch:has(input[type=radio]:checked) .swatch-label { color: var(--text); }
.swatch:has(input[type=radio]:focus-visible) { box-shadow: var(--focus-ring); }
.swatch-custom input[type=color] { width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; }
.swatch-custom input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
.swatch-custom input[type=color]::-webkit-color-swatch { border: 0; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08); }

.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mode-card { position: relative; display: flex; flex-direction: column; gap: 8px; padding: 8px 8px 10px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.mode-card input { position: absolute; opacity: 0; pointer-events: none; }
.mode-card:has(input:checked) { border-color: var(--text); box-shadow: 0 0 0 1px var(--text); }
.mode-card:has(input:focus-visible) { box-shadow: var(--focus-ring); }
.mode-label { font-size: 13px; font-weight: 650; text-align: center; }
.mode-thumb { display: flex; gap: 5px; height: 58px; padding: 7px; border-radius: 8px; border: 1px solid var(--line); }
.mode-thumb span:first-child { width: 28%; border-radius: 4px; }
.mode-thumb span:last-child { flex: 1; border-radius: 4px; }
.mode-thumb-light { background: #F4F4F2; }
.mode-thumb-light span { background: #FFFFFF; }
.mode-thumb-dark { background: #111112; border-color: #2B2B2F; }
.mode-thumb-dark span { background: #242427; }
.mode-thumb-system { background: linear-gradient(135deg, #F4F4F2 50%, #111112 50%); }
.mode-thumb-system span:first-child { background: #FFFFFF; }
.mode-thumb-system span:last-child { background: linear-gradient(135deg, #FFFFFF 42%, #242427 42%); }
.mode-hint { margin: 12px 0 14px; }

.preview { padding-bottom: 20px; }
.preview-nav { display: flex; flex-direction: column; gap: 2px; padding: 8px; margin-bottom: 14px; border: 1px solid var(--line); border-radius: 12px; }
.preview-link { position: relative; display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 9px; font-size: 14px; font-weight: 500; }
.preview-link svg { width: 18px; height: 18px; color: var(--muted); }
.preview-link.active { background: var(--brand-soft); font-weight: 650; }
.preview-link.active svg { color: var(--brand-strong); }
.preview-link.active::before { content: ''; position: absolute; left: -8px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand); }
.preview-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-bottom: 14px; border-radius: 12px; background: var(--brand-soft); }
.preview-badge { margin-left: auto; padding: 2px 9px; border-radius: 999px; background: var(--brand); color: var(--on-brand); font-size: 12px; font-weight: 700; }
.preview-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.preview-actions .btn { pointer-events: none; }
.appearance-actions { margin-bottom: 20px; }

/* ====== Product photo ====== */

.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
.pr-thumb.has-photo { background: #FFFFFF; border: 1px solid var(--line); overflow: hidden; }
.pr-thumb img { width: 100%; height: 100%; object-fit: cover; }
.panel-photo { display: block; height: 230px; background: #FFFFFF; border-bottom: 1px solid var(--line); cursor: zoom-in; }
.panel-photo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.photo-field { display: flex; align-items: center; gap: 12px; }
.photo-box { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 64px; height: 64px; border-radius: 12px; border: 1px dashed var(--line-strong); background: var(--surface-2); color: var(--faint); overflow: hidden; }
.photo-box svg { width: 24px; height: 24px; }
.photo-box img { width: 100%; height: 100%; object-fit: cover; background: #FFFFFF; }
.photo-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.photo-actions .btn { margin: 0; }
.field .photo-actions label.btn { display: inline-flex; font-size: 13px; margin-bottom: 0; }
[data-photo-name] { max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-foot-quiet { flex-wrap: wrap; gap: 4px; padding-top: 0; margin-left: -10px; }

/* ====== Müştərilər / Təchizatçılar (the Məhsullar desk, a phone column instead of prices) ====== */
.clist .plist-head, .clist .product-row { grid-template-columns: minmax(0, 1fr) 150px; }
.contact-avatar { border-radius: 50%; color: var(--muted); }
.contact-phone { font-size: 13.5px; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--muted); }
.contact-call { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--text); }
.contact-call svg { width: 15px; height: 15px; color: var(--muted); }
.contact-call + .pill { margin-left: 8px; }
@media (min-width: 561px) { .contact-phone-row { grid-template-columns: 3fr 2fr; } }
/* The phone tab bar has one tab for both lists; this switch leads to the other. */
.contact-tabs, .page-tabs { margin-bottom: 14px; }
@media (min-width: 768px) { .contact-tabs, .page-tabs { display: none; } }
@media (max-width: 767px) {
  .clist .product-row { grid-template-columns: minmax(0, 1fr) auto; }
  .clist .product-row .pr-main { grid-row: auto; }
  .contact-phone { font-size: 12.5px; }
}

/* ====== Maliyyə ====== */

/* Account balances above the list; a click shows that account's entries only. */
.fin-accounts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 14px; }
.fin-account { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto; column-gap: 10px; align-items: center; padding: 11px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-sm); transition: border-color 0.12s ease, background 0.12s ease; }
a.fin-account:hover { border-color: var(--line-strong); }
.fin-account.active { border-color: var(--brand); background: var(--brand-soft); }
.fin-account .fin-account-icon { grid-row: 1 / 3; }
.fin-account-name { font-size: 12.5px; font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fin-account-balance { font-size: 17px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fin-account-balance.is-neg { color: var(--err); }
.fin-account-total { background: var(--surface-2); box-shadow: none; grid-template-columns: minmax(0, 1fr); }
.fin-account-icon { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 10px; background: var(--surface-2); color: var(--muted); flex-shrink: 0; }
.fin-account-icon svg { width: 18px; height: 18px; }

.fin-sum { display: flex; gap: 18px; margin: -4px 0 12px; font-size: 13px; color: var(--muted); }
.fin-sum b { font-variant-numeric: tabular-nums; }
@media (min-width: 1000px) { .fin-sum { display: none; } } /* the panel shows these there */
.fin-in { color: var(--ok); }
.fin-out { color: var(--err); }

/* Entries, grouped by day: type icon, category + note · account · who, the signed amount. */
.flist .product-row { grid-template-columns: minmax(0, 1fr) auto; }
.flist .product-row .pr-main { grid-row: auto; }
.fin-day { position: sticky; top: 0; z-index: 1; padding: 8px 16px 6px; background: var(--surface-2); border-bottom: 1px solid var(--separator); font-size: 11.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.fin-icon svg { width: 20px; height: 20px; }
.fin-income .fin-icon { background: var(--ok-soft); color: var(--ok); }
.fin-expense .fin-icon { background: var(--err-soft); color: var(--err); }
.fin-transfer .fin-icon { background: var(--brand-soft); color: var(--brand-strong); }
.fin-supplier .fin-icon { background: var(--warn-soft); color: var(--warn); }
.fin-customer .fin-icon { background: var(--ok-soft); color: var(--ok); }
.fin-customer .fin-amount { color: var(--ok); }
.fin-income .fin-amount { color: var(--ok); }
.fin-transfer .fin-amount { color: var(--muted); }
.side-item.fin-type-income svg { color: var(--ok); }
.side-item.fin-type-expense svg { color: var(--err); }
.side-item.fin-type-supplier svg { color: var(--warn); }
.side-item.fin-type-customer svg { color: var(--ok); }

.fin-type-switch { padding-bottom: 0; }
.fin-type-switch .seg { display: flex; }
.fin-type-switch .seg-btn { flex: 1; justify-content: center; }
.fin-audit { display: flex; flex-direction: column; gap: 2px; font-size: 12.5px; }
.fin-stat-text { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fin-detail { margin: 0; font-size: 14px; }
@media (max-width: 767px) {
  .fin-btn-transfer { display: none; } /* a phone has it in the new-entry switch */
  .fin-accounts { grid-template-columns: 1fr 1fr; }
  .fin-account { padding: 10px 12px; }
  .fin-account .fin-account-icon { display: none; }
  .fin-account, .fin-account-total { grid-template-columns: minmax(0, 1fr); }
  .fin-account-balance { font-size: 16px; }
}

/* Hesablar, Kateqoriyalar */
.fin-account-row.active { background: var(--brand-soft); }
.fin-account-row form { margin: 0; }
.fin-account-row .fin-account-balance { font-size: 15px; }
.fin-note { margin-top: 12px; }
.fin-cat-grid { display: grid; gap: 22px; }
@media (min-width: 900px) { .fin-cat-grid { grid-template-columns: 1fr 1fr; align-items: start; } }
.fin-cat-title { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 16px; }
.fin-cat-title svg { width: 18px; height: 18px; color: var(--muted); }

/* ====== Panel sections: stock history, a purchase's lines, a supplier's purchases / payments ====== */
.panel-stat-wide { grid-column: 1 / -1; }
.panel-note a, .link { color: var(--brand-strong); font-weight: 650; }
.panel-section { padding: 12px 18px 10px; border-top: 1px solid var(--separator); }
.panel-stats + .panel-section { border-top: 0; }
.panel-section-title { padding-bottom: 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--faint); }
.move-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--separator); }
.move-row:last-of-type { border-bottom: 0; }
.move-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.move-what { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.move-what a:hover { color: var(--brand-strong); }
.move-meta { font-size: 12px; color: var(--muted); }
.move-qty, .move-sum { font-size: 13.5px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.move-qty.is-up { color: var(--ok); }
.move-qty.is-down { color: var(--err); }
.move-after { min-width: 28px; text-align: right; font-size: 12.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.move-foot { padding-top: 6px; font-size: 12px; color: var(--faint); }

/* ====== Alışlar ====== */
.pur-row .fin-icon { background: var(--warn-soft); color: var(--warn); }
.pur-amount { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.pur-state { font-size: 11px; padding: 1px 8px; background: var(--warn-soft); color: var(--warn); }
.pur-state.pill-off { background: var(--surface-2); color: var(--muted); }
.pur-audit { padding: 0; }
.pur-card-actions { padding-top: 12px; flex-wrap: wrap; }
.tile-value.tile-action { font-size: 18px; color: var(--brand-strong); }

/* A new purchase: lines in the middle, supplier + payment on the right; both stay on a phone. */
.desk.is-doc .desk-main { display: block; }
.desk.is-doc .panel-back { display: none; }
.desk.is-doc .desk-panel { margin-top: 16px; }
@media (min-width: 1000px) {
  .desk.is-doc { grid-template-columns: minmax(0, 1fr) 360px; }
  .desk.is-doc .desk-side { display: none; }
  .desk.is-doc .desk-panel { margin-top: 0; }
}
.pur-editor { overflow: visible; }
.pur-pick { position: relative; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.pur-results { position: absolute; z-index: 20; left: 14px; right: 14px; top: calc(100% - 6px); max-height: 340px; overflow-y: auto; padding: 4px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow-pop); }
.pur-result { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 8px; border: 0; border-radius: 9px; background: none; color: var(--text); text-align: left; cursor: pointer; }
.pur-result.active, .pur-result:hover { background: var(--brand-soft); }
.pur-result .pr-thumb { width: 34px; height: 34px; font-size: 12px; }
.pur-result-name { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pur-result-sub { font-size: 12px; color: var(--muted); white-space: nowrap; }
.pur-result-none { padding: 10px; font-size: 13.5px; color: var(--muted); }
.pur-head, .pur-line { display: grid; grid-template-columns: minmax(0, 1fr) 76px 112px 104px 36px; align-items: center; column-gap: 10px; padding: 8px 10px 8px 16px; }
.pur-head { position: static; min-height: 36px; }
.pur-head .plh-main { padding-left: 56px; }
.pur-line { border-bottom: 1px solid var(--separator); }
.pur-line:last-child { border-bottom: 0; }
.pur-input { width: 100%; min-height: 38px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); color: var(--text); font-size: 14.5px; text-align: right; font-variant-numeric: tabular-nums; }
.pur-input:focus { outline: none; border-color: var(--text); box-shadow: var(--focus-ring); }
.pur-input.has-error { border-color: var(--err); }
.pur-sum { font-weight: 700; }
.pur-line .icon-btn { width: 32px; height: 32px; }
.pur-line .icon-btn svg { width: 17px; height: 17px; }
.pur-line-error { grid-column: 1 / -1; padding-top: 4px; font-size: 12.5px; font-weight: 600; color: var(--err); }
.pur-empty { padding: 34px 20px; text-align: center; color: var(--muted); }
.pur-empty > svg { width: 30px; height: 30px; color: var(--faint); margin-bottom: 6px; }
.pur-empty p { max-width: 420px; margin: 0 auto; font-size: 13.5px; }
.pur-hint { margin: 10px 2px 0; font-size: 12.5px; color: var(--muted); }
.pur-hint a { color: var(--brand-strong); font-weight: 650; }
.pur-quick { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 14px; }
.pur-debt { margin: -2px 0 12px; padding: 9px 12px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 13px; font-weight: 600; }
.pur-debt b { font-variant-numeric: tabular-nums; }

/* ====== Satışlar (the same document as Alış; green, and stock / cost warnings) ====== */
.sale-row .fin-icon { background: var(--ok-soft); color: var(--ok); }
.pur-result.is-out { opacity: 0.5; cursor: not-allowed; }
.pur-result.is-out.active, .pur-result.is-out:hover { background: var(--surface-2); }
.pur-input.is-below { border-color: var(--warn); background: var(--warn-soft); }
.pur-line-error[hidden] { display: none; }
@media (max-width: 767px) {
  /* The column names stay, over the boxes (count · price · sum) of each line. */
  .pur-head, .pur-line { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 76px 32px; padding: 10px 12px; }
  .plist-head.pur-head { display: grid; min-height: 0; padding-top: 8px; padding-bottom: 6px; }
  .pur-head .plh-main { display: none; }
  .pur-line { row-gap: 8px; }
  .pur-line .pr-main { grid-column: 1 / -1; }
  .pur-line .pr-thumb { width: 36px; height: 36px; }
}

/* ====== Hesabatlar ====== */

.rp-tabs { margin: -6px 0 18px; }
.rp-period { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 18px; }
.rp-period .seg { flex-wrap: wrap; }
.rp-dates { display: flex; align-items: center; gap: 8px; margin: 0; }
.rp-dates input { min-height: 36px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); color: var(--text); font-size: 14px; }
.rp-dates input:focus { outline: none; border-color: var(--text); box-shadow: var(--focus-ring); }
.rp-range { font-size: 13px; font-weight: 600; color: var(--muted); }
.rp-lead { margin-top: 0; }
.rp-kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 20px; }
.tile-value.is-neg, .is-neg { color: var(--err); }
.rp-grid { display: grid; gap: 0 20px; }
@media (min-width: 1100px) {
  .rp-grid { grid-template-columns: minmax(0, 1.7fr) minmax(320px, 1fr); align-items: start; }
  .rp-grid-even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
.rp-card h2 { margin-bottom: 16px; }
.rp-note { margin: 14px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.table-card + .rp-note { margin: -8px 0 20px; }

/* The bar chart: one series (turnover), a round top line, hover / focus shows the numbers. */
.rp-chart { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; }
.rp-axis { display: flex; flex-direction: column; justify-content: space-between; height: 220px; margin-top: -7px; margin-bottom: -7px; font-size: 11px; font-weight: 600; color: var(--faint); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rp-plot { min-width: 0; }
.rp-bars {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 220px;
  border-bottom: 1px solid var(--line-strong);
  background: linear-gradient(var(--separator), var(--separator)) 0 0 / 100% 1px no-repeat,
              linear-gradient(var(--separator), var(--separator)) 0 50% / 100% 1px no-repeat;
}
.rp-col { position: relative; flex: 1 1 0; min-width: 0; height: 100%; display: flex; align-items: flex-end; justify-content: center; border-radius: 4px 4px 0 0; outline: none; }
.rp-col:hover, .rp-col:focus-visible { background: var(--surface-2); }
.rp-bar { display: block; width: 100%; max-width: 28px; min-height: 2px; border-radius: 4px 4px 0 0; background: var(--brand); }
.rp-col:hover .rp-bar, .rp-col:focus-visible .rp-bar { background: var(--brand-strong); }
.rp-tip {
  position: absolute;
  bottom: calc(100% - 8px);
  left: 50%;
  z-index: 3;
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
}
.rp-tip b { color: var(--text); font-variant-numeric: tabular-nums; }
.rp-col:hover .rp-tip, .rp-col:focus-visible .rp-tip { display: flex; }
.rp-col:first-child .rp-tip, .rp-col:nth-child(2) .rp-tip { left: 0; transform: none; }
.rp-col:last-child .rp-tip, .rp-col:nth-last-child(2) .rp-tip { left: auto; right: 0; transform: none; }
.rp-xlabels { display: flex; gap: 2px; margin-top: 6px; }
.rp-xlabels span { flex: 1 1 0; min-width: 0; overflow: visible; font-size: 11px; font-weight: 600; color: var(--faint); text-align: center; white-space: nowrap; }

/* Mənfəət hesabı: label | amount rows, subtotals in bold. */
.rp-pl { display: flex; flex-direction: column; }
.rp-pl-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--separator); font-size: 14px; font-variant-numeric: tabular-nums; }
.rp-pl-row.is-minor { padding: 5px 0 5px 12px; font-size: 13px; color: var(--muted); border-bottom: 0; }
.rp-pl-row.is-sub { font-weight: 700; }
.rp-pl-row.is-sub + .rp-pl-row.is-minor { padding-top: 10px; }
.rp-pl-row.is-total { margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--line-strong); border-bottom: 0; font-size: 16px; font-weight: 800; }

.rp-table th.r, .rp-table td.r { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rp-table td { font-size: 14px; }
.rp-table .pr-main:hover .pr-title, .rp-person:hover .rp-name { text-decoration: underline; }
.rp-name { font-weight: 650; }
.rp-person { display: flex; flex-direction: column; min-width: 0; }
.rp-table-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 16px 16px 4px; }
.rp-table-head h2 { margin: 0; }
@media (max-width: 640px) {
  .rp-bars, .rp-axis { height: 170px; }
  .rp-table .pr-thumb { display: none; }
  .rp-kpis .tile-value { font-size: 19px; white-space: nowrap; }
}

/* ====== Abunəlik / Super-admin (admin.<domain>) ====== */

.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-err { background: var(--err-soft); color: var(--err); }
.banner-warn { background: var(--warn-soft); color: var(--warn); }
/* A checkbox with its label to the right (the browser's own box, in the brand colour). */
.check { display: flex; align-items: flex-start; gap: 9px; padding: 2px 0 12px; font-size: 13.5px; font-weight: 600; line-height: 1.4; cursor: pointer; }
.check input { flex-shrink: 0; width: 17px; height: 17px; margin: 1px 0 0; accent-color: var(--brand); }
.check .field-hint { font-weight: 500; }

.sidebar-sa { display: block; font-size: 12px; font-weight: 600; letter-spacing: 0; color: var(--muted); }
.sa-list .plist-head, .sa-list .product-row { grid-template-columns: minmax(0, 1fr) auto; }
.sa-mark { color: var(--brand-strong); background: var(--brand-soft); border-radius: 10px; font-weight: 800; }
.sa-state { text-align: right; }
.sa-panel-sub { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.sa-panel-sub a { font-weight: 600; color: var(--text); }
.sa-panel-sub a:hover { text-decoration: underline; }
/* An input with something glued to its right: ".localhost", the "Yarat" button. */
.sa-slug { display: flex; align-items: center; gap: 8px; }
.sa-slug input { flex: 1; min-width: 0; }
.sa-slug > span { font-size: 13.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.sa-sub { padding-top: 6px; }
.sa-pad { padding: 14px 18px 0; border-top: 1px solid var(--separator); }
.sa-flush { padding: 4px 0 6px; }
.sa-del { margin: 0 0 0 4px; }
.sa-del .icon-btn { width: 30px; height: 30px; }
.sa-del .icon-btn svg { width: 15px; height: 15px; }
.move-row.is-off .move-what, .move-row.is-off .move-qty { color: var(--faint); text-decoration: line-through; }
.sa-list .product-row.is-off .pr-title { text-decoration: none; }

/* ====== Tap.az, Birmarket (modullar) ====== */
.mk-setup { max-width: 640px; }
.mk-setup p { margin: 0 0 14px; font-size: 14px; line-height: 1.55; }
.mk-setup-foot { padding: 0 0 14px; }
.mk-shop { display: flex; flex-direction: column; gap: 4px; padding: 0 10px; font-size: 12.5px; color: var(--muted); }
.mk-shop .side-title { padding-left: 0; }
.mk-shop-name { font-size: 13.5px; font-weight: 700; color: var(--text); }
.mk-shop-name:hover { text-decoration: underline; }
.mk-shop-error { padding: 6px 8px; border-radius: 8px; background: var(--err-soft); color: var(--err); font-weight: 600; line-height: 1.4; }
.mk-shop form { margin-top: 6px; }
.mk-shop-hint { font-size: 11.5px; color: var(--faint); line-height: 1.4; }
.pr-sub.mk-unlinked { color: var(--warn); font-weight: 600; }
.mk-stat-small { font-size: 14px; padding-top: 4px; }
.mk-panel-actions { padding-top: 14px; flex-wrap: wrap; }
.mk-linked { padding-bottom: 8px; font-size: 14px; }
.mk-unlink { margin-left: -10px; }
.mk-link-form { padding-bottom: 6px; }
.mk-field-status { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
/* Above the list while the filter column is hidden (its breakpoints: .desk-side). */
.mk-shop-bar { margin-bottom: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.mk-shop-bar .side-title { display: none; }
.mk-shop-bar form { margin-top: 4px; }
@media (min-width: 1180px) and (max-width: 1279px), (min-width: 1400px) { .mk-shop-bar { display: none; } }
