* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --sidebar-width: 224px;
  --bg: #f4f4f1;
  --sidebar-bg: #1e2130;
  --sidebar-text: #c8cde4;
  --sidebar-active: #4f8ef7;
  --accent: #1a5fd4;
  --accent-soft: rgba(26,95,212,.10);
  --danger: #c0392b;
  --danger-soft: rgba(192,57,43,.08);
  --warning: #a36809;
  --warning-soft: rgba(163,104,9,.08);
  --success: #1a7a3c;
  --success-soft: rgba(26,122,60,.08);
  --card-bg: #fff;
  --border: #e8eaef;
  --text: #1e2130;
  --text-muted: #647287;
  --radius: 10px;
}

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  min-height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-logo {
  padding: 22px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 11px;
}

.sidebar-logo-mark {
  width: 30px;
  height: 30px;
  background: var(--accent);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
  flex-shrink: 0;
  color: #fff;
}

.sidebar-logo-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar-logo-text strong {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 15px;
  font-weight: 400;
  color: #fff;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.sidebar-logo-text span {
  font-size: 10px;
  font-weight: 500;
  color: var(--sidebar-text);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.7;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  border-left: 3px solid transparent;
  letter-spacing: 0.01em;
}

.sidebar-nav a:hover {
  background: rgba(255,255,255,0.07);
  color: #fff;
}

.sidebar-nav a.active {
  background: rgba(26, 95, 212, 0.18);
  color: #fff;
  border-left-color: var(--accent);
}

.sidebar-nav .nav-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 8px 16px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-footer form button {
  background: none;
  border: none;
  color: var(--sidebar-text);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
}

.sidebar-footer form button:hover {
  color: #fff;
}

/* ── Main ── */
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar h1 {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 22px;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--text);
}

.topbar .user-info {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.content {
  padding: 28px;
  flex: 1;
}

/* ── Flash messages ── */
.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 14px;
}

.flash.success {
  background: #d6f0de;
  color: #1a7a3c;
  border: 1px solid #aadbc0;
}

.flash.error {
  background: #fde8e6;
  color: #c0392b;
  border: 1px solid #f5bcb6;
}

.flash.info {
  background: #dbeeff;
  color: #1a5fd4;
  border: 1px solid #b3d4f7;
}

/* ── Cards ── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  margin-bottom: 20px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

/* ── Stat cards ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px 24px;
  position: relative;
}

.stat-card .label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.stat-card .value {
  font-size: 36px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stat-card.ok {
  border-left: 4px solid var(--success);
}
.stat-card.warning {
  border-left: 4px solid var(--warning);
}
.stat-card.critical {
  border-left: 4px solid var(--danger);
}

.stat-card.ok .value { color: var(--success); }
.stat-card.warning .value { color: var(--warning); }
.stat-card.critical .value { color: var(--danger); }

/* ── Mini-stat cards (home page top row) ── */
.mini-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.mini-stat {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: box-shadow .2s;
}

.mini-stat:hover { box-shadow: 0 4px 16px rgba(0,0,0,.06); }

.mini-stat-left .ms-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.mini-stat-left .ms-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}

.mini-stat-right {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.ms-total .ms-value           { color: var(--text); }
.ms-total .mini-stat-right    { background: #edeef2; }

.ms-ok                        { border-left: 3px solid var(--success); }
.ms-ok .ms-value              { color: var(--success); }
.ms-ok .mini-stat-right       { background: var(--success-soft); }

.ms-warn                      { border-left: 3px solid var(--warning); }
.ms-warn .ms-value            { color: var(--warning); }
.ms-warn .mini-stat-right     { background: var(--warning-soft); }

.ms-crit                      { border-left: 3px solid var(--danger); }
.ms-crit .ms-value            { color: var(--danger); }
.ms-crit .mini-stat-right     { background: var(--danger-soft); }

@media (max-width: 768px) {
  .mini-stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .mini-stat-left .ms-value { font-size: 24px; }
}

/* ── Table ── */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead tr {
  border-bottom: 2px solid var(--border);
}

th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  white-space: nowrap;
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:hover {
  background: #f5f5f2;
}

tbody tr:last-child td {
  border-bottom: none;
}

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.badge.ok { background: #d6f0de; color: #1a7a3c; }
.badge.warning { background: #fef3cd; color: #a36809; }
.badge.critical { background: #fde8e6; color: #c0392b; }
.badge.active { background: #d6f0de; color: #1a7a3c; }
.badge.inactive { background: #e8eaef; color: #3d4a5c; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 7px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.1s;
  letter-spacing: 0.01em;
}

.btn:hover { opacity: 0.88; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--accent); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ── Filters ── */
.filters {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filters select,
.filters input[type="text"],
.filters input[type="date"],
.filters input[type="search"] {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  color: var(--text);
  outline: none;
}

.filters select:focus,
.filters input:focus {
  border-color: var(--accent);
}

/* ── Filter tabs (radio-based) ── */
.filter-tabs {
  display: flex;
  gap: 4px;
  align-items: center;
  background: #edeef2;
  border-radius: 9px;
  padding: 4px;
}

.filter-tabs input[type="radio"] {
  display: none;
}

.filter-tabs label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  user-select: none;
}

.filter-tabs label:hover {
  color: var(--text);
  background: rgba(255,255,255,0.6);
}

.filter-tabs input[type="radio"]:checked + label {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.filter-tabs input[type="radio"]:checked + label.critical { color: var(--danger); }
.filter-tabs input[type="radio"]:checked + label.warning  { color: var(--warning); }
.filter-tabs input[type="radio"]:checked + label.ok       { color: var(--success); }

.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 5px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  background: currentColor;
  opacity: 0.15;
  color: inherit;
}

.filter-tabs input[type="radio"]:checked + label .tab-count {
  opacity: 1;
  background: currentColor;
  color: #fff;
}

.tab-count {
  background: rgba(0,0,0,0.12);
  color: inherit;
}

.filter-tabs input[type="radio"]:checked + label.critical .tab-count { background: var(--danger); color: #fff; }
.filter-tabs input[type="radio"]:checked + label.warning  .tab-count { background: var(--warning); color: #fff; }
.filter-tabs input[type="radio"]:checked + label.ok       .tab-count { background: var(--success); color: #fff; }

/* ── Table row status coloring ── */
tr.row-critical td:first-child {
  border-left: 3px solid var(--danger);
}

tr.row-warning td:first-child {
  border-left: 3px solid var(--warning);
}

tr.row-ok td:first-child {
  border-left: 3px solid transparent;
}

tr.row-critical {
  background: #fff9f8;
}

tr.row-warning {
  background: #fffdf2;
}

/* ── Forms ── */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
}

.form-group textarea {
  min-height: 120px;
  resize: vertical;
  font-family: monospace;
  font-size: 13px;
}

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

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}

.tab {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Login (redesigned) ── */
body.login-body {
  display: block;
  background: #0f1120;
}

.login-split {
  display: grid;
  grid-template-columns: 400px 1fr;
  min-height: 100vh;
}

.login-panel {
  background: var(--sidebar-bg);
  position: relative;
  overflow: hidden;
  padding: 48px 40px;
  display: flex;
  flex-direction: column;
}

.login-panel-inner {
  position: relative;
  z-index: 2;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 80px;
}

.login-brand-mark {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
}

.login-brand-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--sidebar-text);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.login-panel-headline {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 48px;
  line-height: 1.1;
  color: #fff;
  margin-bottom: 16px;
  letter-spacing: -0.02em;
  font-weight: 400;
}

.login-panel-tagline {
  font-size: 14px;
  color: rgba(200, 205, 228, 0.55);
  margin-bottom: auto;
  padding-bottom: 48px;
  line-height: 1.6;
}

.login-panel-stats {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  z-index: 2;
}

.login-stat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: rgba(200, 205, 228, 0.65);
}

.login-stat-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  opacity: 0.8;
}

/* Decorative grid overlay */
.login-panel-grid {
  position: absolute;
  inset: 0;
  z-index: 1;
  background-image:
    linear-gradient(rgba(79, 142, 247, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(79, 142, 247, 0.07) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(ellipse at 80% 20%, rgba(0,0,0,0.4) 0%, transparent 70%);
  mask-image: radial-gradient(ellipse at 80% 20%, rgba(0,0,0,0.4) 0%, transparent 70%);
}

/* Right panel */
.login-form-panel {
  background: #f7f7f5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 40px;
}

.login-form-inner {
  width: 100%;
  max-width: 360px;
}

.login-form-header {
  margin-bottom: 40px;
}

.login-form-title {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 30px;
  font-weight: 400;
  color: var(--sidebar-bg);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.login-form-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
}

.login-form-inner .form-group label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
}

.login-form-inner .form-group input {
  background: #fff;
  border-color: #dde1e9;
  font-size: 15px;
  padding: 11px 14px;
  color: var(--sidebar-bg);
}

.login-form-inner .form-group input:focus {
  border-color: var(--sidebar-bg);
  box-shadow: 0 0 0 3px rgba(30, 33, 48, 0.08);
}

.login-submit {
  width: 100%;
  justify-content: center;
  margin-top: 8px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  background: var(--sidebar-bg);
  color: #fff;
  border-radius: 8px;
  letter-spacing: 0.03em;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
}

.login-submit:hover {
  opacity: 1;
  background: #2d3448;
  transform: translateY(-1px);
}

.login-submit:active {
  transform: translateY(0);
}

@media (max-width: 700px) {
  .login-split {
    grid-template-columns: 1fr;
  }

  .login-panel {
    padding: 32px 28px 36px;
    min-height: 200px;
  }

  .login-panel-headline {
    font-size: 34px;
  }

  .login-brand {
    margin-bottom: 32px;
  }

  .login-panel-tagline,
  .login-panel-stats {
    display: none;
  }

  .login-form-panel {
    padding: 36px 24px;
    align-items: flex-start;
  }
}

/* ── Misc ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-header h2 {
  font-size: 20px;
  font-weight: 600;
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.inline-save {
  display: flex;
  gap: 8px;
  align-items: center;
}

.threshold-input {
  width: 72px !important;
  text-align: center;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 28px;
  max-width: 480px;
  width: 90%;
}

.modal-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 16px;
}

code {
  background: #f1f3f5;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 13px;
}

.key-display {
  font-family: monospace;
  background: #f8f9fa;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  word-break: break-all;
  font-size: 13px;
  margin-bottom: 12px;
}

/* ── Credentials display ── */

/* Legacy — kept for any other uses */
.creds {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.cred-item {
  display: inline-flex;
  flex-direction: column;
  gap: 1px;
}

.cred-item code {
  background: #f1f3f5;
  padding: 3px 8px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 13px;
  color: var(--text);
}

.cred-sep {
  color: var(--text-muted);
  font-size: 16px;
  margin-top: 10px;
  opacity: 0.4;
}

.creds-raw {
  font-size: 11px;
  color: var(--text-muted);
  word-break: break-all;
}

/* ── Credentials grid (aligned) ── */
.creds-grid {
  display: inline-grid;
  grid-template-columns: max-content 1fr;
  gap: 5px 12px;
  align-items: center;
}

.cred-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  white-space: nowrap;
  line-height: 1;
}

.cred-val-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cred-val-wrap code {
  background: #f1f3f5;
  padding: 3px 8px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 13px;
  color: var(--text);
  word-break: break-all;
}

.cred-copy {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 1px 6px;
  line-height: 1.4;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, border-color 0.15s;
}

.acc-row:hover .cred-copy {
  opacity: 1;
}

.cred-copy:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.cred-copy.copied {
  color: var(--success);
  border-color: var(--success);
  opacity: 1;
}

/* ── Accounts: product selector row ── */
.acc-product-row {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-end;
  gap: 16px;
}

.acc-product-select-wrap {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 260px;
}

.acc-product-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

.acc-product-select-wrap select {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
  outline: none;
  cursor: pointer;
}

.acc-product-select-wrap select:focus {
  border-color: var(--accent);
}

/* ── Accounts: tabs row ── */
.acc-tabs-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.acc-total {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── Accounts: tab container ── */
.acc-tabs {
  display: flex;
  gap: 6px;
  align-items: center;
}

.acc-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 16px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: none;
  border: 1.5px solid var(--border);
  background: #fff;
  transition: border-color 0.15s, color 0.15s, background 0.15s, box-shadow 0.15s;
  user-select: none;
  letter-spacing: 0.01em;
}

.acc-tab:hover {
  color: var(--text);
  border-color: #c0c5d0;
  background: #f9fafb;
}

.acc-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 2px 6px rgba(26, 95, 212, 0.25);
}

.acc-tab.active:hover {
  background: #1754bf;
  border-color: #1754bf;
  color: #fff;
}

.acc-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 19px;
  height: 17px;
  padding: 0 5px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(255,255,255,0.28);
  color: #fff;
}

/* ── Accounts: initial empty state ── */
.acc-empty-initial {
  padding: 48px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.empty-icon {
  font-size: 28px;
  line-height: 1;
  margin-bottom: 4px;
}

.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }

/* ── History date range wrapper ── */
.history-dates {
  display: contents; /* transparent on desktop — children appear as direct flex items */
}

/* ── Product link in stock table ── */
.product-link {
  color: var(--text);
  text-decoration: none;
  transition: color 0.15s;
}

.product-link:hover {
  color: var(--accent);
}

/* ── Toggle switch (checkbox) ── */
.form-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  padding: 2px 0;
  position: relative;
}

.form-toggle input[type="checkbox"] {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
}

.toggle-track {
  position: relative;
  width: 38px;
  height: 22px;
  background: #d4d8e2;
  border-radius: 11px;
  flex-shrink: 0;
  transition: background 0.2s;
}

.form-toggle input[type="checkbox"]:checked + .toggle-track {
  background: var(--accent);
}

.toggle-thumb {
  position: absolute;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.form-toggle input[type="checkbox"]:checked + .toggle-track .toggle-thumb {
  transform: translateX(16px);
}

.toggle-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

/* ── Home page ── */

/* ── Home page fade-in ── */
@keyframes homeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.mini-stats    { animation: homeUp .35s ease both; }
.home-main-grid  { animation: homeUp .35s .07s ease both; }
.home-bottom-grid { animation: homeUp .35s .14s ease both; }

.home-card-head {
  padding: 18px 20px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.home-card-link {
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  opacity: .85;
}

.home-card-link:hover {
  opacity: 1;
  text-decoration: underline;
}

.home-card-body {
  padding: 16px 20px 20px;
}

.home-badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 5px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  margin-left: 6px;
  vertical-align: middle;
}

.home-badge-count.critical { background: var(--danger); color: #fff; }
.home-badge-count.warning  { background: var(--warning); color: #fff; }

/* Grids */
.home-main-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  margin-bottom: 20px;
}

.home-main-grid .card,
.home-bottom-grid .card {
  margin-bottom: 0;
}

.home-bottom-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

/* Chart */
.chart-summary {
  display: flex;
  gap: 24px;
  margin-bottom: 20px;
}

.cs-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.cs-value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.cs-value.accent { color: var(--accent); }
.cs-value.green  { color: var(--success); }

.source-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.spill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.spill-ym    { background: #dbeeff; color: #1a5fd4; }
.spill-wb    { background: #ede9fe; color: #6d28d9; }
.spill-bot   { background: #d6f0de; color: #1a7a3c; }
.spill-admin { background: #fef3c7; color: #b45309; }
.spill-crm   { background: #fef3c7; color: #b45309; }

.spill-meta { font-weight: 400; opacity: .8; }

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

.chart-wrap svg {
  display: block;
  width: 100%;
}

.chart-x-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  padding: 0 2px;
}

.chart-x-labels span {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.chart-tooltip {
  position: absolute;
  background: var(--text);
  color: #fff;
  padding: 5px 10px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 500;
  pointer-events: none;
  opacity: 0;
  transition: opacity .12s;
  white-space: nowrap;
  z-index: 50;
  transform: translateX(-50%);
}

/* Problem items */
.problem-list { display: flex; flex-direction: column; }

.problem-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.problem-item:last-child { border-bottom: none; }

.pi-left { display: flex; align-items: center; gap: 9px; min-width: 0; }

.pi-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.pi-dot.critical { background: var(--danger); }
.pi-dot.warning  { background: var(--warning); }

.pi-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 195px;
}

.pi-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.pi-stock {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 20px;
  text-align: right;
}

.pi-stock.critical { color: var(--danger); }
.pi-stock.warning  { color: var(--warning); }

/* Popular products */
.pop-list { display: flex; flex-direction: column; }

.pop-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.pop-item:last-child { border-bottom: none; }

.pop-left { display: flex; align-items: center; gap: 10px; min-width: 0; }

.pop-rank {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  width: 16px;
  text-align: right;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.pop-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

.pop-right { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }

.pop-qty {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.pop-rev {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Channel stats */
.ch-list { display: flex; flex-direction: column; }

.ch-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}

.ch-item:last-child { border-bottom: none; }

.ch-name { display: flex; align-items: center; gap: 8px; }

.ch-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

.ch-dot-ym  { background: #1a5fd4; }
.ch-dot-wb  { background: #6d28d9; }
.ch-dot-bot { background: #1a7a3c; }

.ch-label { font-size: 14px; font-weight: 600; }

.ch-meta { display: flex; gap: 16px; }

.ch-stat { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }

.ch-stat-val {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.ch-stat-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}

.ch-bar {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  gap: 2px;
}

.ch-bar-seg { height: 100%; }
.ch-bar-ym  { background: #1a5fd4; }
.ch-bar-wb  { background: #6d28d9; }
.ch-bar-bot { background: #1a7a3c; }

.ch-bar-legend { display: flex; gap: 10px; }

.ch-legend-ym  { font-size: 11px; font-weight: 600; color: #1a5fd4; }
.ch-legend-wb  { font-size: 11px; font-weight: 600; color: #6d28d9; }
.ch-legend-bot { font-size: 11px; font-weight: 600; color: #1a7a3c; }

/* Problem items: hidden extras + show-more button */
.pi-hidden { display: none; }

.pi-show-more {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 8px;
  padding: 7px 0;
  background: none;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  letter-spacing: .01em;
}

.pi-show-more:hover {
  background: var(--bg);
  color: var(--text);
  border-color: #c0c5d0;
}

/* Warehouse mini */
.wh-list { display: flex; flex-direction: column; }

.wh-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.wh-item:last-child { border-bottom: none; }

.wh-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 165px;
}

.wh-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.wh-stock {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 24px;
  text-align: right;
}

/* Home responsive */
@media (max-width: 1200px) {
  .home-main-grid { grid-template-columns: 1fr 320px; }
}
@media (max-width: 1000px) {
  .home-main-grid { grid-template-columns: 1fr 280px; }
}

@media (max-width: 900px) {
  .home-main-grid  { grid-template-columns: 1fr; }
  .home-bottom-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Mobile sidebar ── */
.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  flex-shrink: 0;
}

.menu-toggle:hover {
  background: var(--border);
}

.menu-toggle span {
  display: block;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 99;
}

.sidebar-backdrop.visible {
  display: block;
}

@media (max-width: 768px) {
  .menu-toggle {
    display: flex;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 100;
  }

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

  .main {
    margin-left: 0;
    width: 100%;
    min-width: 0;
    overflow-x: hidden;
  }

  .content {
    padding: 16px;
  }

  .topbar {
    padding: 12px 16px;
    gap: 12px;
  }

  /* Home grids: single column on mobile */
  .home-main-grid,
  .home-bottom-grid {
    grid-template-columns: 1fr;
  }

  /* Stat grid: 2 columns */
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
  }

  .stat-card .value {
    font-size: 28px;
  }

  /* Page header: stack title + button */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .page-header .btn {
    align-self: stretch;
    justify-content: center;
  }

  /* Filter bar: stack items vertically */
  .filter-tabs {
    flex-wrap: wrap;
    width: 100%;
  }

  .filters {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .filters select,
  .filters input[type="text"],
  .filters input[type="date"],
  .filters input[type="search"] {
    width: 100%;
  }

  /* History date inputs: side by side */
  .filters .history-dates {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  /* Forms: single column */
  .form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn {
    justify-content: center;
  }

  .card {
    padding: 16px;
  }

  /* Accounts: stack product selector row */
  .acc-product-row {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .acc-product-select-wrap {
    min-width: auto;
  }

  /* Accounts: tabs row stacks on small screen */
  .acc-tabs-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .acc-tabs {
    flex-wrap: wrap;
  }

  /* Table: compact cells on mobile */
  th, td {
    padding: 9px 10px;
  }

  th {
    font-size: 10px;
  }

  td {
    font-size: 13px;
  }

  /* Modal: full width on mobile */
  .modal {
    width: 95%;
    padding: 20px;
  }

  .pf-grid { grid-template-columns: 1fr; }
}

/* ── Product form layout ── */
.pf-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  align-items: start;
}

.pf-col-main,
.pf-col-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pf-section {
  padding: 20px 24px 22px;
}

.pf-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pf-field-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  display: block;
  margin-bottom: 10px;
}

.pf-status-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 10px;
}

.pf-hint-inline {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 12px;
}

/* ── Segment toggle ── */
.segment-toggle {
  display: inline-flex;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg);
}

.segment-toggle input[type="radio"] {
  position: absolute;
  width: 0; height: 0; opacity: 0;
}

.segment-toggle label {
  padding: 7px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
  user-select: none;
}

.segment-toggle input[type="radio"]:checked + label {
  background: var(--accent);
  color: #fff;
}

/* ── Accounts section inside product edit ── */
.pf-acc-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 20px;
}

.pf-acc-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.pf-acc-textarea {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  min-height: 90px;
}

/* ── Audit badges ── */
.audit-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.audit-badge-success { background: var(--success-soft); color: var(--success); }
.audit-badge-warning { background: var(--warning-soft); color: var(--warning); }
.audit-badge-danger  { background: var(--danger-soft);  color: var(--danger);  }
.audit-badge-muted   { background: #f0f1f5; color: var(--text-muted); }

/* ── Account validation feedback ── */
.acc-validation {
  font-size: 12px;
  line-height: 1.5;
}

.acc-valid-count {
  color: var(--success);
  font-weight: 600;
}

.acc-error-count {
  color: var(--danger);
  font-weight: 600;
}

.acc-error-list {
  margin: 4px 0 0 0;
  padding-left: 18px;
  color: var(--danger);
}

.acc-error-list li {
  margin-bottom: 2px;
}

.acc-modal-warn {
  background: var(--warning-soft);
  color: var(--warning);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 12px;
}

.acc-fmt-hint {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

/* ── Account preview table in modal ── */
.acc-preview-wrap {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 8px;
}

.acc-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.acc-preview-table th {
  padding: 7px 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}

.acc-preview-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  font-family: 'DM Mono', monospace;
  word-break: break-all;
  color: var(--text);
}

.acc-preview-table tr:last-child td {
  border-bottom: none;
}

/* ── Audit pagination ── */
.audit-pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

.audit-page-info {
  font-size: 12px;
  color: var(--text-muted);
  flex: 1;
  text-align: center;
}

/* ══════════════════════════════════════════
   ISSUE PAGE — account issuance
   ══════════════════════════════════════════ */

/* Layout */
.issue-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 860px) {
  .issue-layout { grid-template-columns: 1fr; }
}

/* ── Form panel ── */
.issue-form-panel {
  padding: 24px;
  position: sticky;
  top: 76px;
}

.issue-panel-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.issue-panel-icon {
  width: 38px;
  height: 38px;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
}

.issue-panel-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.issue-panel-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.issue-source-pill {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: .04em;
}

/* Label row with stock badge */
.issue-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.issue-label-row label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0;
}

/* Stock badge */
.issue-stock-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  transition: all .2s;
}

.issue-stock-empty   { background: #f0f1f5; color: var(--text-muted); }
.issue-stock-ok      { background: var(--success-soft); color: var(--success); }
.issue-stock-warning { background: var(--warning-soft); color: var(--warning); }
.issue-stock-critical{ background: var(--danger-soft);  color: var(--danger);  }

/* Quantity stepper */
.issue-stepper {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.issue-stepper-btn {
  width: 38px;
  background: var(--bg);
  border: none;
  color: var(--text);
  font-size: 18px;
  font-weight: 400;
  cursor: pointer;
  transition: background .15s;
  flex-shrink: 0;
}

.issue-stepper-btn:hover { background: #e8eaef; }
.issue-stepper-btn:active { background: #dde0ea; }

.issue-stepper input[type="number"] {
  flex: 1;
  border: none;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-radius: 0;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  -moz-appearance: textfield;
}

.issue-stepper input[type="number"]::-webkit-inner-spin-button,
.issue-stepper input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }

/* Price field */
.issue-price-wrap {
  position: relative;
}

.issue-price-wrap input {
  padding-right: 28px;
}

.issue-price-currency {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.issue-price-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 5px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.issue-hint-icon { font-size: 12px; }

/* Submit button */
.issue-submit-btn {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.01em;
  margin-top: 4px;
  justify-content: center;
  position: relative;
}

.issue-submit-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

/* Spinner (htmx-indicator) */
.issue-spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: issueSpin .6s linear infinite;
  margin-right: 8px;
}

.htmx-request .issue-spinner,
.htmx-request.issue-spinner { display: inline-block; }

@keyframes issueSpin {
  to { transform: rotate(360deg); }
}

/* ── Result panel ── */
.issue-result-panel {
  padding: 0;
  overflow: hidden;
  min-height: 320px;
}

/* Empty state */
.issue-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 24px;
  gap: 8px;
}

.issue-empty-icon {
  font-size: 36px;
  color: var(--border);
  margin-bottom: 4px;
}

.issue-empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
}

.issue-empty-text {
  font-size: 13px;
  color: var(--text-muted);
  opacity: .7;
}

/* Loading dots */
.issue-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 24px;
}

.issue-loading-dots {
  display: flex;
  gap: 6px;
}

.issue-loading-dots span {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  animation: issueBouce .8s ease infinite;
}

.issue-loading-dots span:nth-child(2) { animation-delay: .15s; }
.issue-loading-dots span:nth-child(3) { animation-delay: .30s; }

@keyframes issueBouce {
  0%, 80%, 100% { transform: scale(.7); opacity: .4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Error state */
.issue-error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  gap: 6px;
}

.issue-error-icon  { font-size: 28px; color: var(--danger); margin-bottom: 4px; }
.issue-error-title { font-size: 15px; font-weight: 600; color: var(--danger); }
.issue-error-text  { font-size: 13px; color: var(--text-muted); text-align: center; }

/* Result inner */
.issue-result-inner {
  padding: 0;
}

/* Success header */
.issue-result-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 22px;
  background: var(--success-soft);
  border-bottom: 1px solid rgba(26,122,60,.12);
}

.issue-result-check {
  width: 34px;
  height: 34px;
  background: var(--success);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}

.issue-result-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--success);
}

.issue-result-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* Credential list */
.issue-cred-list {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Credential card */
.issue-cred-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  animation: issueCardIn .3s ease both;
}

@keyframes issueCardIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.issue-cred-num {
  padding: 5px 12px;
  background: var(--bg);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: .06em;
  border-bottom: 1px solid var(--border);
}

/* Credential fields */
.issue-cred-fields {
  display: flex;
  flex-direction: column;
}

.issue-field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
}

.issue-field:last-child { border-bottom: none; }

.issue-field-icon {
  width: 20px;
  text-align: center;
  font-size: 13px;
  flex-shrink: 0;
}

.issue-field-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  width: 70px;
  flex-shrink: 0;
}

.issue-field-value {
  flex: 1;
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  word-break: break-all;
  min-width: 0;
}

/* Copy button */
.issue-copy-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: all .15s;
}

.issue-copy-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.issue-copy-btn.issue-copy-ok {
  border-color: var(--success);
  color: var(--success);
  background: var(--success-soft);
}

/* Copy all button */
.issue-copy-all-btn {
  display: block;
  width: calc(100% - 24px);
  margin: 10px 12px 12px;
  padding: 7px;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
  text-align: center;
}

.issue-copy-all-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.issue-copy-all-btn.issue-copy-ok-btn {
  border-color: var(--success);
  color: var(--success);
  background: var(--success-soft);
  border-style: solid;
}

/* Footer */
.issue-result-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.issue-history-note {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

/* ══════════════════════════════════════════════════════════════════
   v4 additions — sidebar polish, topbar quick-issue, flash auto-dismiss,
   clipboard feedback, bulk-copy button, monospace credential value.
   ══════════════════════════════════════════════════════════════════ */

/* ── Sidebar: section labels + icon columns ── */
.sidebar-nav .nav-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: rgba(255,255,255,0.35);
  padding: 14px 20px 4px;
  margin-top: 2px;
}

.sidebar-nav .nav-item {
  gap: 12px;
}

.sidebar-nav .nav-item .nav-icon {
  width: 18px;
  text-align: center;
  font-size: 14px;
  flex-shrink: 0;
}

.sidebar-nav .nav-item .nav-label { flex: 1; }

.sidebar-nav .nav-item .nav-kbd {
  font-family: 'DM Sans', -apple-system, system-ui, sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
  color: rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.1);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.12);
}

/* Primary "Выдача" nav item — visually louder than the rest */
.sidebar-nav a.nav-primary {
  margin: 14px 14px 8px;
  padding: 11px 14px;
  border-left: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent) 0%, #3577e5 100%);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(26,95,212,0.35);
  transition: transform .15s, box-shadow .15s, filter .15s;
}

.sidebar-nav a.nav-primary .nav-icon { font-size: 16px; }

.sidebar-nav a.nav-primary:hover {
  background: linear-gradient(135deg, #1a5fd4 0%, #4a89ed 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(26,95,212,0.45);
  color: #fff;
}

.sidebar-nav a.nav-primary.active {
  filter: brightness(1.05);
  box-shadow: 0 6px 18px rgba(26,95,212,0.5), inset 0 0 0 2px rgba(255,255,255,0.18);
  background: linear-gradient(135deg, #1a5fd4 0%, #4a89ed 100%);
}

.sidebar-nav a.nav-primary .nav-kbd {
  background: rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.9);
  border-color: rgba(255,255,255,0.25);
}

/* ── Topbar: quick actions ── */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-issue-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: 8px;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(26,95,212,0.18);
}

.topbar-issue-btn:hover {
  box-shadow: 0 4px 14px rgba(26,95,212,0.32);
  transform: translateY(-1px);
}

.topbar-kbd {
  font-family: 'DM Sans', -apple-system, system-ui, sans-serif;
  font-size: 10px;
  font-weight: 700;
  background: rgba(255,255,255,0.22);
  color: rgba(255,255,255,0.95);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.25);
  margin-left: 2px;
}

@media (max-width: 768px) {
  .topbar-issue-btn .topbar-kbd { display: none; }
  .topbar-actions .user-info { display: none; }
  .topbar-issue-btn { padding: 7px 10px; font-size: 12.5px; }
}

/* ── Flash auto-dismiss ── */
.flash-auto {
  cursor: pointer;
  transition: opacity .35s ease, transform .35s ease, margin .35s ease, padding .35s ease, max-height .35s ease;
  max-height: 200px;
  overflow: hidden;
}

.flash-auto.flash-hide {
  opacity: 0;
  transform: translateY(-6px);
  max-height: 0;
  margin-bottom: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-width: 0;
}

/* ── Bulk copy button (issue result footer) ── */
.issue-copy-bulk-btn {
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 600;
  margin-left: 10px;
}

.issue-copy-bulk-btn.issue-copy-ok-btn,
.issue-copy-all-btn.issue-copy-ok-btn {
  background: var(--success) !important;
  color: #fff !important;
  border-color: var(--success) !important;
}

/* Error pulse when clipboard fails */
.issue-copy-btn.issue-copy-err,
.issue-copy-all-btn.issue-copy-err,
.issue-copy-bulk-btn.issue-copy-err {
  background: var(--danger-soft) !important;
  color: var(--danger) !important;
  animation: issueCopyShake .3s;
}

@keyframes issueCopyShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

/* Monospace credential value (keys, promocodes) */
.issue-field-mono {
  font-family: 'SF Mono', 'Menlo', 'Consolas', 'Courier New', monospace;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: .02em;
}

/* Footer on result: let it wrap when there are 3 items */
.issue-result-footer {
  flex-wrap: wrap;
  gap: 10px;
}

/* ═══════════════════════════════════════════════════════════════
   v5 — Searchable product combobox (issue page)
   Close + repeat buttons on result panel
   Quick-issue modal (product edit page)
   ═══════════════════════════════════════════════════════════════ */

/* ── Combobox root ── */
.combobox {
  position: relative;
  width: 100%;
}
.combobox-field {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 0 6px 0 12px;
  height: 44px;
  transition: border-color .15s, box-shadow .15s;
}
.combobox.open .combobox-field,
.combobox-field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26,95,212,.12);
}
.combobox-icon {
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.combobox-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 14.5px;
  color: var(--text);
  min-width: 0;
  padding: 0;
  height: 100%;
}
.combobox-input::placeholder { color: #9aa3b2; }
.combobox-clear,
.combobox-toggle {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: background .12s, color .12s, transform .2s;
}
.combobox-clear:hover,
.combobox-toggle:hover {
  background: #eef1f5;
  color: var(--text);
}
.combobox.open .combobox-toggle { transform: rotate(180deg); }

/* ── Dropdown ── */
.combobox-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 32px rgba(17,24,39,0.12), 0 4px 12px rgba(17,24,39,0.06);
  max-height: 340px;
  overflow-y: auto;
  z-index: 40;
  padding: 4px 0;
  animation: comboboxIn .15s ease-out;
}
@keyframes comboboxIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.combobox-group { padding: 2px 0; }
.combobox-group + .combobox-group { border-top: 1px solid var(--border); margin-top: 2px; padding-top: 4px; }
.combobox-group-label {
  padding: 6px 14px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}
.combobox-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 14px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  user-select: none;
  line-height: 1.3;
}
.combobox-option:hover,
.combobox-option.active {
  background: var(--accent-soft);
}
.combobox-option.active { box-shadow: inset 2px 0 0 var(--accent); }
.co-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.co-stock {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--success-soft);
  color: var(--success);
  font-variant-numeric: tabular-nums;
}
.co-stock-warning { background: var(--warning-soft); color: var(--warning); }
.co-stock-critical { background: var(--danger-soft);  color: var(--danger);  }
.combobox-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
}

/* ── Result panel: × close (header) ── */
.issue-result-header { position: relative; }
.issue-result-close {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .12s, color .12s;
}
.issue-result-close:hover {
  background: #eef1f5;
  color: var(--text);
}

/* Repeat button emphasis */
.issue-repeat-btn {
  display: inline-flex;
  align-items: center;
  font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════════
   Quick-issue modal on Product Edit page
   ═══════════════════════════════════════════════════════════════ */

.pf-quick-issue-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--accent) 0%, #2c7cff 100%);
  color: #fff;
  border: none;
  font-weight: 600;
  font-size: 13.5px;
  padding: 8px 16px;
  border-radius: 9px;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(26,95,212,.25);
  transition: transform .12s, box-shadow .12s, filter .12s;
}
.pf-quick-issue-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(26,95,212,.32);
  filter: brightness(1.05);
}
.pf-quick-issue-btn:disabled {
  cursor: not-allowed;
  opacity: .55;
  transform: none;
  box-shadow: none;
}

/* Reuse existing .modal-overlay / .modal, add issue-specific body */
.qi-modal {
  max-width: 520px;
  width: 96%;
  padding: 0;
  overflow: hidden;
  border-radius: 14px;
}
.qi-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
}
.qi-head-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent) 0%, #2c7cff 100%);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.qi-head-meta { flex: 1; min-width: 0; }
.qi-head-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.qi-head-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
}
.qi-head-close {
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.qi-head-close:hover { background: #eef1f5; color: var(--text); }

.qi-body { padding: 18px 22px 8px; }
.qi-result { padding: 0 22px 4px; min-height: 0; }
.qi-result:empty { display: none; }
.qi-footer {
  padding: 14px 22px 18px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--border);
  background: #fafbfc;
}
.qi-stock-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 10px;
  font-variant-numeric: tabular-nums;
}
.qi-stock-ok       { background: var(--success-soft); color: var(--success); }
.qi-stock-warning  { background: var(--warning-soft); color: var(--warning); }
.qi-stock-critical { background: var(--danger-soft);  color: var(--danger);  }
.qi-stock-empty    { background: #eef1f5; color: var(--text-muted); }
