:root {
  color-scheme: light;
  --bg: #eef4f5;
  --surface: #ffffff;
  --surface-2: #e7f0f2;
  --border: rgba(23, 55, 66, 0.1);
  --border-strong: rgba(23, 55, 66, 0.2);
  --accent: #2c6478;
  --accent-2: #4f96ab;
  --accent-rgb: 44, 100, 120;
  --accent-2-rgb: 79, 150, 171;
  --success: #16a34a;
  --danger: #dc2626;
  --text: #16323c;
  --muted: #5f7d87;
  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-sm: 11px;
  --shadow-lg: 0 24px 60px rgba(23, 55, 66, 0.14);
  --shadow-md: 0 8px 24px rgba(23, 55, 66, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  font-family: "Segoe UI", system-ui, -apple-system, Tahoma, Geneva, Verdana, sans-serif;
  background: radial-gradient(circle at 12% -10%, rgba(var(--accent-rgb), 0.1), transparent 40%),
    radial-gradient(circle at 100% 0%, rgba(var(--accent-2-rgb), 0.09), transparent 35%),
    linear-gradient(180deg, #eaf3f4 0%, #f6fafb 100%);
  background-attachment: fixed;
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
  border-radius: 8px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 6px;
}

/* ---------- Icon system (inline SVG, replaces emoji glyphs) ---------- */

.icon {
  width: 18px;
  height: 18px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-icon .icon {
  width: 17px;
  height: 17px;
}

.icon-btn .icon {
  width: 17px;
  height: 17px;
}

.item-icon-btn .icon {
  width: 15px;
  height: 15px;
}

.search-icon .icon {
  width: 15px;
  height: 15px;
}

.item-lead-icon .icon {
  width: 17px;
  height: 17px;
}

/* ---------- Login ---------- */

.login-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(238, 244, 245, 0.75);
  backdrop-filter: blur(14px);
  z-index: 10;
}

.login-card {
  width: min(100%, 400px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-mark {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  font-weight: 800;
  font-size: 1.25rem;
  box-shadow: 0 10px 24px rgba(var(--accent-rgb), 0.35);
}

.login-card h1 {
  font-size: 1.7rem;
  margin: 0 0 6px;
}

.login-card .subtitle {
  margin-bottom: 22px;
}

.login-form {
  display: grid;
  gap: 12px;
  margin-top: 4px;
}

.login-form input {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: rgba(23, 55, 66, 0.04);
  color: var(--text);
  padding: 13px 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.login-form input:focus-visible {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(var(--accent-2-rgb), 0.22);
  outline: none;
}

.login-form input::placeholder {
  color: var(--muted);
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 48px;
}

.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.password-toggle:hover {
  background: rgba(23, 55, 66, 0.06);
  color: var(--text);
}

.eye-icon {
  position: relative;
  width: 20px;
  height: 12px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.eye-icon::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.password-toggle[aria-pressed="true"] .eye-icon::before {
  content: "";
  position: absolute;
  left: -3px;
  top: 50%;
  width: 26px;
  height: 2px;
  background: currentColor;
  transform: rotate(-40deg);
}

.login-help {
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.92rem;
}

.login-error {
  min-height: 1.2rem;
  margin-top: 8px;
  color: var(--danger);
  font-weight: 600;
  font-size: 0.92rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- App shell ---------- */

.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

.balance-statement-dialog {
  width: min(100%, 500px);
  padding: 0;
  overflow: hidden;
}

.balance-statement-dialog .modal-header {
  margin: 0;
  padding: 18px 22px;
}

.balance-statement-print {
  background: var(--surface, #fff);
  margin: 0 18px 18px;
  border-radius: var(--radius-md);
  box-shadow: 0 0 0 1px var(--border), 0 0 0 6px rgba(var(--accent-rgb), 0.05);
  overflow: hidden;
}

.balance-statement-band {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 22px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  background-image: repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0 2px, transparent 2px 14px),
    linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #fff;
}

.balance-statement-mark {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.35);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: 1.15rem;
}

.balance-statement-band-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.balance-statement-company {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.balance-statement-band-sub {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  opacity: 0.85;
}

.balance-statement-date {
  margin-left: auto;
  flex: none;
  font-size: 0.8rem;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.balance-statement-body {
  padding: 24px 26px 22px;
}

.balance-statement-party {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 20px;
  padding-bottom: 18px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.balance-statement-party::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 64px;
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.balance-statement-party-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  font-weight: 700;
}

.balance-statement-name {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
}

.balance-statement-type {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(var(--accent-rgb), 0.08);
}

.balance-statement-rows {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.balance-statement-row {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 15px 18px 15px 22px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2, #f5f8f9);
  overflow: hidden;
}

.balance-statement-row::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
}

.balance-statement-row.owes-us {
  background: rgba(220, 38, 38, 0.05);
}

.balance-statement-row.owes-us::before {
  background: var(--danger);
}

.balance-statement-row.owes-them {
  background: rgba(22, 163, 74, 0.05);
}

.balance-statement-row.owes-them::before {
  background: var(--success);
}

.balance-statement-row-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.balance-statement-currency {
  font-size: 0.74rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.balance-statement-amount {
  font-size: 1.3rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.balance-statement-row.owes-us .balance-statement-amount {
  color: var(--danger);
}

.balance-statement-row.owes-them .balance-statement-amount {
  color: var(--success);
}

.balance-statement-badge {
  flex: none;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 6px 12px;
  border-radius: 999px;
  color: #fff;
  white-space: nowrap;
}

.balance-statement-row.owes-us .balance-statement-badge {
  background: var(--danger);
}

.balance-statement-row.owes-them .balance-statement-badge {
  background: var(--success);
}

.balance-statement-zero,
.balance-statement-loading,
.balance-statement-error {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 18px 0;
  list-style: none;
}

.balance-statement-signatures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 34px;
}

.balance-statement-sign {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.balance-statement-sign-line {
  width: 100%;
  border-bottom: 1px dashed var(--border-strong);
  height: 28px;
}

.balance-statement-sign-label {
  font-size: 0.76rem;
  color: var(--muted);
  letter-spacing: 0.03em;
}

@media print {
  body {
    background: #fff !important;
  }

  body * {
    visibility: hidden;
  }

  #balance-statement-print,
  #balance-statement-print * {
    visibility: visible;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    color-adjust: exact;
  }

  #balance-statement-print {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    margin: 0;
    box-shadow: none;
  }

  .no-print {
    display: none !important;
  }
}

.sidebar-overlay {
  display: none;
}

/* ---------- Topbar (always visible, spans the full width) ---------- */

.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-left {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
}

.menu-toggle {
  flex: none;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: transparent;
  display: grid;
  place-items: center;
  gap: 3px;
  transition: background 0.15s ease;
}

.menu-toggle:hover {
  background: rgba(23, 55, 66, 0.08);
}

.menu-toggle span {
  display: block;
  width: 13px;
  height: 1.5px;
  background: var(--text);
  border-radius: 2px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 9px;
}

.topbar-brand-text {
  font-weight: 800;
  font-size: 0.98rem;
  white-space: nowrap;
}

.brand-mark {
  flex: none;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  font-weight: 800;
  font-size: 0.9rem;
  box-shadow: 0 6px 16px rgba(var(--accent-rgb), 0.3);
}

.topbar-search {
  position: relative;
  flex: 1;
  max-width: 440px;
  margin: 0 auto;
}

.search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.8rem;
  color: var(--muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  padding: 10px 14px 10px 34px;
  font-size: 0.85rem;
}

.search-input::placeholder {
  color: var(--muted);
}

.search-input:focus-visible {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(var(--accent-2-rgb), 0.2);
  outline: none;
}

.topbar-icons {
  flex: none;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-rates {
  display: flex;
  align-items: center;
  gap: 6px;
}

.rate-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(23, 55, 66, 0.05);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.rate-chip .icon {
  width: 13px;
  height: 13px;
  color: var(--accent);
}

.icon-btn {
  position: relative;
  flex: none;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: rgba(23, 55, 66, 0.05);
  color: var(--muted);
  font-size: 0.9rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.icon-btn:hover {
  background: rgba(23, 55, 66, 0.09);
  color: var(--text);
}

.icon-btn.active {
  background: var(--accent);
  color: #fff;
}

.icon-btn.spinning .icon {
  animation: icon-spin 0.7s linear infinite;
}

@keyframes icon-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.icon-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: white;
  font-size: 0.62rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  line-height: 1;
}

.profile-menu {
  position: relative;
  flex: none;
}

.avatar-circle {
  flex: none;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: white;
  font-weight: 700;
  font-size: 0.8rem;
  transition: box-shadow 0.15s ease;
}

.avatar-circle:hover {
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.25);
}

.profile-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 230px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 12px;
  display: grid;
  gap: 10px;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 30;
}

.profile-dropdown.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.profile-user {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  white-space: nowrap;
}

.profile-user strong {
  color: var(--text);
}

.profile-details {
  list-style: none;
  margin: 0;
  padding: 10px 0 0;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 6px;
}

.profile-details li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.8rem;
}

.profile-detail-label {
  flex: none;
  color: var(--muted);
}

.profile-detail-value {
  color: var(--text);
  font-weight: 600;
  text-align: right;
}

.profile-dropdown .secondary-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

.btn-icon {
  flex: none;
  font-size: 1.05rem;
  line-height: 1;
}

/* ---------- Body: sidebar + main content, side by side ---------- */

.app-body {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  flex: none;
  width: 248px;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.22s ease, padding 0.22s ease;
}

/* Text/labels that fade and shrink away when the sidebar collapses to an
   icon rail. Kept as opacity+max-width (not display:none) so they animate
   in sync with the sidebar's width transition instead of vanishing mid-way. */
.sidebar-label {
  display: inline-block;
  overflow: hidden;
  white-space: nowrap;
  opacity: 1;
  max-width: 220px;
  transition: opacity 0.16s ease, max-width 0.22s ease;
}

.nav-menu {
  display: grid;
  gap: 5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  border: none;
  padding: 10px 12px;
  border-radius: 10px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-item.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #ffffff;
  box-shadow: 0 10px 20px rgba(var(--accent-rgb), 0.28);
}

.nav-icon {
  flex: none;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  font-size: 0.92rem;
  color: inherit;
}

.nav-item.active .nav-icon {
  color: #ffffff;
}

/* ---------- Collapsed sidebar (desktop only; mobile keeps the full drawer) ---------- */

@media (min-width: 901px) {
  .sidebar.collapsed {
    width: 72px;
    padding-left: 8px;
    padding-right: 8px;
  }

  .sidebar.collapsed .sidebar-label {
    opacity: 0;
    max-width: 0;
  }

  /* The label is already invisible (opacity/max-width 0 above); dropping the
     flex gap too removes the empty trailing space it would otherwise still
     reserve, without moving the icon (which stays the first flex item). */
  .sidebar.collapsed .nav-item {
    gap: 0;
  }
}

.main-panel {
  flex: 1;
  padding: 24px 28px;
  min-width: 0;
  overflow-y: auto;
}

.primary-btn,
.secondary-btn {
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.primary-btn:hover,
.secondary-btn:hover {
  transform: translateY(-1px);
}

.primary-btn {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(var(--accent-rgb), 0.25);
}

.primary-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.secondary-btn {
  color: var(--text);
  border: 1px solid var(--border-strong);
  background: rgba(23, 55, 66, 0.04);
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 0.92rem;
}

.view-panel {
  display: none;
  padding-bottom: 24px;
}

.view-panel.active {
  display: block;
  animation: fade-in 0.18s ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.content-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-md);
}

.content-card h2 {
  margin: 0 0 10px;
  font-size: 1.15rem;
}

.subtitle {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.6;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.panel-header span {
  color: var(--muted);
}

.balance-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 18px;
  padding: 16px 18px;
  margin-bottom: 18px;
  background: rgba(23, 55, 66, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 12px);
}

.balance-filters .form-field {
  flex: 1 1 200px;
  min-width: 180px;
  max-width: 280px;
}

.doc-filters .form-field {
  max-width: 220px;
}

.doc-filters-reset {
  flex: none;
  height: 42px;
}

.required-mark {
  color: var(--danger, #d64545);
}

.balance-fixed-value {
  height: 42px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(23, 55, 66, 0.06);
  color: var(--text);
  font-weight: 600;
  margin: 0;
}

.balance-select-company-hint {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-radius: var(--radius-md, 12px);
  background: rgba(var(--accent-2-rgb), 0.08);
  border: 1px dashed var(--accent-2);
  color: var(--text);
  text-align: left;
}

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

.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  flex-direction: row-reverse;
}

.stat-chip-icon {
  flex: none;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent);
}

.stat-chip--kirim .stat-chip-icon {
  background: rgba(22, 163, 74, 0.14);
  color: var(--success);
}

.stat-chip--chiqim .stat-chip-icon {
  background: rgba(231, 81, 90, 0.14);
  color: var(--danger);
}

.stat-chip-label {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.stat-chip-value {
  display: block;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text);
}

.dashboard-recent-card {
  margin-top: 16px;
}

.balance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.balance-card {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: linear-gradient(160deg, rgba(var(--accent-rgb), 0.06), rgba(var(--accent-2-rgb), 0.03));
}

.balance-card-name {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}

.balance-card-amount {
  display: block;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
}

.balance-card-currency {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
}

.usd-total-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}

.usd-total-card {
  display: block;
  width: 100%;
  text-align: left;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: linear-gradient(160deg, rgba(var(--accent-rgb), 0.08), rgba(var(--accent-2-rgb), 0.03));
  cursor: pointer;
  font: inherit;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.usd-total-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.usd-total-card.aktiv {
  border-color: rgba(22, 163, 74, 0.3);
}

.usd-total-card.passiv {
  border-color: rgba(220, 38, 38, 0.3);
}

.usd-total-label {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.usd-total-amount {
  display: block;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text);
}

.usd-total-card.aktiv .usd-total-amount {
  color: var(--success);
}

.usd-total-card.passiv .usd-total-amount {
  color: var(--danger);
}

.usd-total-hint {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.76rem;
}

.usd-total-card.kassa {
  margin-bottom: 16px;
}

.financial-balance-diff {
  margin: 0 0 14px;
  font-size: 0.82rem;
  color: var(--muted, #6b7280);
  text-align: center;
}

.financial-balance-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 720px) {
  .financial-balance-columns {
    grid-template-columns: 1fr;
  }
}

.financial-balance-col {
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 12px);
  padding: 14px 16px;
  min-width: 0;
}

.financial-balance-col-title {
  margin: 0 0 12px;
  font-size: 0.92rem;
  font-weight: 700;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
}

.financial-balance-col-title.aktiv {
  color: var(--success);
  border-bottom-color: rgba(22, 163, 74, 0.3);
}

.financial-balance-col-title.passiv {
  color: var(--danger);
  border-bottom-color: rgba(220, 38, 38, 0.3);
}

.compact-balance-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.compact-balance-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--border);
}

.compact-balance-row:last-child {
  border-bottom: none;
}

.compact-balance-row-label {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.compact-balance-row-amount {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  text-align: right;
  white-space: nowrap;
}

.compact-balance-row-currency {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.8rem;
}

.compact-balance-row-toggle {
  cursor: pointer;
}

.compact-balance-row-toggle:hover {
  background: var(--surface-hover, rgba(0, 0, 0, 0.03));
}

.compact-balance-sublist {
  padding-left: 14px;
  border-left: 2px solid var(--border);
  margin-bottom: 4px;
}

.compact-balance-row-sub {
  padding: 6px 2px;
}

.compact-balance-row-sub .compact-balance-row-label {
  font-size: 0.8rem;
}

.data-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.data-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(23, 55, 66, 0.02);
  transition: background 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.data-list li:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  box-shadow: 0 6px 18px rgba(23, 55, 66, 0.08);
}

#doc-list li {
  cursor: pointer;
}

.data-list .item-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.item-lead-icon {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(23, 55, 66, 0.06);
  color: var(--muted);
}

.item-lead-icon.kirim {
  background: rgba(22, 163, 74, 0.14);
  color: var(--success);
}

.item-lead-icon.chiqim {
  background: rgba(220, 38, 38, 0.12);
  color: var(--danger);
}

.data-list .item-title {
  font-weight: 600;
}

.doc-type-badge {
  display: inline-block;
  padding: 2px 9px;
  margin-right: 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  vertical-align: middle;
}

.doc-type-badge.kirim {
  background: rgba(22, 163, 74, 0.14);
  color: var(--success);
}

.doc-type-badge.chiqim {
  background: rgba(220, 38, 38, 0.12);
  color: var(--danger);
}

.doc-type-badge.invoice {
  background: rgba(23, 55, 66, 0.08);
  color: var(--muted);
}

.doc-amount.kirim {
  color: var(--success);
}

.doc-amount.chiqim {
  color: var(--danger);
}

.data-list .item-meta {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.data-list .item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.data-list .item-actions {
  flex: none;
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.item-icon-btn {
  flex: none;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 8px;
  background: rgba(23, 55, 66, 0.05);
  color: var(--muted);
  font-size: 0.9rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.item-icon-btn:hover {
  background: rgba(23, 55, 66, 0.1);
  color: var(--text);
}

.item-icon-btn.danger:hover {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
}

/* ---------- Hujjatlar: sidebar-style document-type navigation ---------- */

#view-documents.view-panel.active,
#view-data.view-panel.active,
#view-reports.view-panel.active {
  height: 100%;
  display: flex;
  flex-direction: column;
}

#view-documents .content-card,
#view-data .content-card {
  flex: 1;
  min-height: 0;
  display: flex;
}

/* Faqat tashqi o'ram (sidebar+main'ni birlashtiruvchi .content-card) - ichidagi
   "Boshqa hisobotlar"ning har bir alohida kartasi (.content-card) buzilib
   ketmasligi uchun ";" bu yerda descendant emas, to'g'ridan-to'g'ri bola
   (>) tanlagichi ishlatiladi. */
#view-reports.view-panel > .content-card {
  flex: 1;
  min-height: 0;
  display: flex;
}

/* Hujjatlar/Ma'lumotlar'da o'ng tomon ".data-list" o'zi scroll bo'ladi
   (flex:1; min-height:0; overflow-y:auto). Hisobotlar'ning o'ng tomonida
   ".data-list" yo'q - shu sababli bir xil scroll xatti-harakatini olish
   uchun shu ikki panelning o'ziga xuddi shunday qoida beriladi. */
#view-reports #reports-balance-panel,
#view-reports #reports-other-panel {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 10px;
}

.documents-layout {
  display: flex;
  align-items: stretch;
  gap: 20px;
  flex: 1;
  min-height: 0;
  width: 100%;
}

.doc-type-sidebar {
  flex: none;
  width: 240px;
  border-right: 1px solid var(--border);
  padding-right: 16px;
  overflow-y: auto;
}

.doc-type-sidebar-title {
  margin: 0 0 12px;
  font-size: 1rem;
  color: var(--text);
}

.doc-type-group {
  margin-bottom: 4px;
}

.doc-type-group summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  list-style: none;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text);
  transition: background 0.15s ease;
}

.doc-type-group summary::-webkit-details-marker {
  display: none;
}

.doc-type-group summary::after {
  content: '';
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}

.doc-type-group[open] summary::after {
  transform: rotate(45deg);
}

.doc-type-group summary:hover {
  background: rgba(23, 55, 66, 0.05);
}

.doc-type-group-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0 10px 10px;
}

.doc-type-card {
  display: flex;
  align-items: center;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 8px 10px;
  font-size: 0.86rem;
  font-weight: 600;
  text-align: left;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.doc-type-card:hover {
  background: rgba(23, 55, 66, 0.06);
  color: var(--text);
}

.doc-type-card.active {
  background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.28), rgba(var(--accent-2-rgb), 0.2));
  color: var(--text);
}

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

.documents-main-header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.documents-main .data-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  align-content: start;
}

.documents-main .empty-state {
  flex: none;
}

.documents-main-header .section-subtitle {
  margin: 0;
}

.documents-main-actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- Ma'lumotlar: sidebar-style resource navigation ---------- */

.section-subtitle {
  margin: 0 0 14px;
  font-size: 1.05rem;
}

#view-reports .content-card + .content-card {
  margin-top: 16px;
}

.report-region-group + .report-region-group {
  margin-top: 18px;
}

.report-region-title {
  margin: 0 0 8px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--muted);
}

.region-balance-figures {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: flex-end;
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
}

.region-balance-figure.total {
  color: var(--text);
  font-size: 0.95rem;
}

.region-balance-figure.kirim {
  color: var(--success);
}

.region-balance-figure.chiqim {
  color: var(--danger);
}

/* ---------- Hisobotlar: Mahsulot sverkasi (davr bo'yicha operatsiyalar ro'yxati) ---------- */

.report-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
}

.report-table th,
.report-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.report-table th {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: var(--surface-2);
}

.report-table td.report-table-kirim,
.report-table td.report-table-chiqim {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.report-table td.report-table-kirim {
  color: var(--success);
}

.report-table td.report-table-chiqim {
  color: var(--danger);
}

.report-table tr.report-table-balance-row td {
  background: rgba(23, 55, 66, 0.04);
  font-weight: 700;
  text-align: right;
}

.report-table tr.report-table-balance-row td:first-child {
  text-align: left;
}

.report-table tr.report-table-total-row td {
  font-weight: 700;
  text-align: right;
}

.report-table tr.report-table-total-row td:first-child {
  text-align: left;
}

.report-table-link {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.report-table-link:hover {
  color: var(--accent-2);
}

.cashflow-chart {
  display: flex;
  align-items: flex-end;
  gap: 18px;
  overflow-x: auto;
  padding: 16px 4px 4px;
  min-height: 200px;
}

.cashflow-chart-empty {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 12px 0;
}

.cashflow-bar-group {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 56px;
}

.cashflow-bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 160px;
}

.cashflow-bar {
  width: 16px;
  border-radius: 4px 4px 0 0;
  min-height: 2px;
}

.cashflow-bar.kirim {
  background: var(--success);
}

.cashflow-bar.chiqim {
  background: var(--danger);
}

.cashflow-bar-label {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

.data-list li.stock-group {
  display: block;
  padding: 0;
}

.debt-group {
  margin-bottom: 18px;
}

.debt-group:last-child {
  margin-bottom: 0;
}

.debt-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.debt-group-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
}

.debt-group-list {
  margin: 0;
}

.debt-subgroup {
  margin: 0 0 14px 12px;
  padding-left: 10px;
  border-left: 2px solid var(--border);
}

.debt-subgroup:last-child {
  margin-bottom: 0;
}

.debt-subgroup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 6px;
  margin-bottom: 6px;
}

.debt-subgroup-title {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted, var(--text));
}

.stock-group-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: none;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.stock-toggle-icon {
  flex: none;
  color: var(--muted);
  font-size: 0.8rem;
  transition: transform 0.15s ease;
}

.stock-group.expanded .stock-toggle-icon {
  transform: rotate(90deg);
}

.stock-lots {
  list-style: none;
  margin: 0;
  padding: 0 14px 12px;
  display: grid;
  gap: 6px;
}

.stock-lots li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(23, 55, 66, 0.03);
  color: var(--muted);
  font-size: 0.84rem;
}

.stock-lots li.total-row {
  border-color: var(--danger);
  color: var(--danger);
  font-weight: 700;
}

.stock-lots li.animal-cost-row {
  border-color: var(--accent);
  color: var(--accent);
}

.stock-lots li.feed-cost-row {
  border-color: var(--success);
  color: var(--success);
}

.stock-lots li.expense-cost-row {
  border-color: #b45309;
  color: #b45309;
}

.data-form {
  display: grid;
  gap: 14px;
}

/* ---------- Modal (add/edit dialog) ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 6, 12, 0.7);
  backdrop-filter: blur(6px);
  z-index: 50;
}

.modal-dialog {
  width: min(100%, 520px);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-lg);
}

.modal-overlay.fullscreen {
  padding: 0;
}

.modal-dialog.wide {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  border-radius: 0;
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-dialog.wide .data-form {
  gap: 8px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.modal-dialog.wide .form-grid {
  gap: 8px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.modal-dialog.wide .modal-header {
  margin-bottom: 8px;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
}

.modal-close-btn {
  flex: none;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 8px;
  background: rgba(23, 55, 66, 0.05);
  color: var(--muted);
  font-size: 0.9rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.modal-close-btn:hover {
  background: rgba(23, 55, 66, 0.1);
  color: var(--text);
}

.confirm-dialog {
  width: min(100%, 420px);
}

.confirm-modal-message {
  margin: 0 0 18px;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.5;
}

.danger-btn {
  background: var(--danger);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-weight: 700;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.danger-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(220, 38, 38, 0.25);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-row > .form-field:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.form-section {
  display: grid;
  gap: 12px;
}

.form-field-full {
  grid-column: 1 / -1;
}

.form-section + .form-section {
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px dashed var(--border-color, #d0d5dd);
}

@media (max-width: 520px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

.gr-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  flex: 1;
  min-height: 0;
}

.gr-header-col {
  flex: 0 0 320px;
  width: 320px;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.gr-actions {
  display: flex;
  gap: 10px;
  margin-top: auto;
  padding-top: 12px;
}

.gr-items-col {
  flex: 1;
  min-width: 0;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.gr-items-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: rgba(23, 55, 66, 0.04);
  padding: 12px;
}

.gr-items-panel > label {
  font-size: 0.84rem;
  color: var(--muted);
}

.gr-items-panel > .secondary-btn {
  align-self: flex-start;
}

@media (max-width: 900px) {
  .gr-layout {
    flex-direction: column;
  }

  .gr-header-col {
    width: 100%;
    flex: 1 1 auto;
  }

  .gr-items-col {
    min-height: 320px;
  }
}

.gr-header-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: rgba(23, 55, 66, 0.04);
  padding: 12px;
}

.gr-full-row {
  grid-column: 1 / -1;
}

.gr-header-grid .form-field {
  gap: 3px;
}

.gr-header-grid .form-field label {
  font-size: 0.72rem;
}

.gr-header-grid .form-field input,
.gr-header-grid .form-field select {
  padding: 6px 8px;
  font-size: 0.86rem;
}

.gr-org-box {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: rgba(23, 55, 66, 0.04);
  padding: 10px;
}

.gr-currency-rate {
  grid-column: 1 / -1;
  display: flex;
  gap: 6px;
  min-width: 0;
}

.gr-currency-rate .form-field {
  flex: 1;
  min-width: 0;
}

@media (max-width: 420px) {
  .gr-header-grid {
    grid-template-columns: 1fr;
  }
}

.form-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.form-field label {
  font-size: 0.84rem;
  color: var(--muted);
}

.form-field input,
.form-field select {
  width: 100%;
  height: 42px;
  box-sizing: border-box;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: rgba(23, 55, 66, 0.04);
  color: var(--text);
  font: inherit;
  line-height: 1.2;
  padding: 10px 12px;
}

.form-field input:focus-visible,
.form-field select:focus-visible {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(var(--accent-2-rgb), 0.2);
  outline: none;
}

.form-field select[multiple] {
  height: auto;
  padding: 6px;
}

.form-field input[readonly] {
  background: rgba(23, 55, 66, 0.08);
  color: var(--text-muted, var(--text));
  cursor: not-allowed;
}

.ss-wrap {
  position: relative;
  width: 100%;
}

.ss-wrap select.ss-native {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ss-display {
  width: 100%;
  height: 42px;
  box-sizing: border-box;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: rgba(23, 55, 66, 0.04);
  color: var(--text);
  font: inherit;
  line-height: 1.2;
  padding: 10px 30px 10px 12px;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  position: relative;
}

.ss-display::after {
  content: '▾';
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.6;
  font-size: 0.8rem;
}

.ss-display.ss-placeholder {
  color: var(--muted);
}

.ss-display.ss-open {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(var(--accent-2-rgb), 0.2);
}

.ss-display.ss-disabled,
.ss-display:disabled {
  background: rgba(23, 55, 66, 0.08);
  color: var(--text-muted, var(--text));
  cursor: not-allowed;
}

.ss-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--bg, #fff);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  max-height: 260px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ss-panel[hidden] {
  display: none;
}

.ss-search {
  width: 100%;
  box-sizing: border-box;
  border: none;
  border-bottom: 1px solid var(--border-strong);
  padding: 10px 12px;
  font: inherit;
  background: transparent;
  color: var(--text);
  outline: none;
}

.ss-list {
  overflow-y: auto;
  flex: 1;
}

.ss-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.9rem;
}

.ss-item:hover {
  background: rgba(var(--accent-2-rgb), 0.15);
}

.ss-item-active {
  font-weight: 600;
  background: rgba(var(--accent-2-rgb), 0.1);
}

.ss-item-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ss-item-empty {
  opacity: 0.6;
  cursor: default;
}

.ss-item-empty:hover {
  background: transparent;
}

.checkbox-list {
  display: grid;
  gap: 2px;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: rgba(23, 55, 66, 0.04);
  padding: 6px;
}

.table-scroll {
  overflow: auto;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  flex: 1;
  min-height: 160px;
}

.items-table {
  width: 100%;
  min-width: 940px;
  border-collapse: collapse;
}

.items-table th,
.items-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.items-table th {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: var(--surface-2);
}

.items-table .gr-item-index {
  width: 32px;
  min-width: 32px;
  text-align: center;
  color: var(--muted);
  font-size: 0.86rem;
}

.items-table input,
.items-table select {
  width: 100%;
  min-width: 100px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: rgba(23, 55, 66, 0.04);
  color: var(--text);
  padding: 6px 8px;
  font-size: 0.86rem;
}

.items-table input {
  text-align: right;
}

.items-table input[disabled] {
  background: rgba(23, 55, 66, 0.08);
  color: var(--text);
}

.items-table .gr-item-product {
  min-width: 380px;
}

.items-table .gr-item-qty,
.items-table .gr-item-markup {
  min-width: 60px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.checkbox-item:hover {
  background: rgba(23, 55, 66, 0.06);
}

.checkbox-item input[type='checkbox'] {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
  flex: none;
  cursor: pointer;
}

.checkbox-item span {
  font-size: 0.92rem;
  color: var(--text);
  flex: 1;
}

.tg-account-picker-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.tg-account-picker-row select {
  flex: 1;
}

.form-hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.form-actions {
  display: flex;
  justify-content: flex-start;
  gap: 10px;
}

.form-error {
  min-height: 1.1rem;
  margin: 0;
  color: var(--danger);
  font-size: 0.86rem;
  font-weight: 600;
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .topbar {
    padding: 10px 16px;
    gap: 12px;
  }

  .sidebar {
    position: fixed;
    top: 55px;
    left: 0;
    bottom: 0;
    width: min(84vw, 300px);
    z-index: 9;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    top: 55px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(4, 6, 12, 0.6);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 8;
  }

  .sidebar-overlay.visible {
    opacity: 1;
    pointer-events: auto;
  }

  .main-panel {
    padding: 20px;
  }
}

@media (max-width: 640px) {
  .topbar-search {
    display: none;
  }

  .topbar-rates {
    display: none;
  }
}
