/* ══ INDEX STYLES ══════════════════════════════════ */

html, body { height: 100%; font-family: 'Sora', sans-serif; background: var(--bg-primary); color: var(--text-primary); font-size: 14px; transition: background 0.3s ease, color 0.3s ease; }

/* ══ LAYOUT ══════════════════════════════════ */
#app { display: flex; min-height: 100vh; flex-direction: column; }

/* ══ TOPBAR ══════════════════════════════════ */
.topbar {
  height: 56px;
  background: rgba(10,6,18,0.9);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 18px;
  position: sticky;
  top: 0;
  z-index: 200;
  flex-shrink: 0;
  transition: background 0.3s ease, border-color 0.3s ease;
}

:root.light-mode .topbar {
  background: rgba(249,249,251,0.95);
  border-bottom: 1px solid var(--border-color);
}

.topbar-brand {
  font-family: 'DM Serif Display', serif;
  font-size: 18px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.topbar-brand span {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 2px 8px;
  border: 1px solid rgba(196,164,255,0.2);
  border-radius: 10px;
  margin-left: 4px;
}

:root.light-mode .topbar-brand span {
  border-color: rgba(124,58,237,0.2);
}

.topbar-sep { width: 1px; height: 18px; background: var(--border-light); }

/* ══ TOPBAR NAV GROUP ══════════════════════════════ */
.topbar-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 4px;
  flex: 1;
  justify-content: center;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  padding: 5px 14px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 500;
  font-family: 'Sora', sans-serif;
  color: var(--text-muted);
  text-decoration: none;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.nav-link:hover {
  background: var(--border-color);
  color: var(--text-primary);
}

.nav-link.active {
  background: rgba(139,92,246,0.18);
  color: rgba(255,255,255,0.9);
  cursor: default;
}

:root.light-mode .nav-link.active {
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

/* ══ HAMBURGER (mobile only) ══════════════════════ */
.topbar-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  background: var(--bg-tertiary);
  border: 1px solid rgba(0,0,0,0.05);
  border-radius: 8px;
  cursor: pointer;
  color: rgba(196,164,255,0.7);
  font-size: 16px;
  flex-shrink: 0;
  padding: 0;
}

.topbar-hamburger:hover {
  background: rgba(0,0,0,0.05);
  color: rgba(196,164,255,0.9);
}

.topbar-right { display: flex; align-items: center; gap: 10px; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 5px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: 20px;
}

.avatar {
  width: 27px; height: 27px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-dark));
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: #fff; flex-shrink: 0;
}

.user-chip span { font-size: 12px; color: var(--text-secondary); font-weight: 500; }

/* ══ MAIN ══════════════════════════════════ */
.main { flex: 1; padding: 32px 36px; max-width: 1500px; margin: 0 auto; width: 95%; }

/* ══ VIEWS ══════════════════════════════════ */
.view { display: none; animation: fadeIn 0.2s ease; }
.view.active { display: block; }

/* ══ BUTTONS ══════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 20px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-dark));
  color: #fff;
  border: 1px solid rgba(0,0,0,0.05);
  border-radius: 10px;
  font-size: 13px; font-weight: 600;
  font-family: 'Sora', sans-serif;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.22,1,0.36,1);
  box-shadow: 0 4px 18px rgba(109,40,217,0.4), inset 0 1px 0 var(--bg-tertiary);
  white-space: nowrap;
  position: relative; overflow: hidden;
}
.btn::before {
  content: ''; position: absolute; top: 0; left: -100%; width: 60%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(0,0,0,0.05), transparent);
  transition: left 0.45s ease;
}
.btn:hover { transform: translateY(-1px); background: linear-gradient(135deg, var(--purple-light), #7c3aed); box-shadow: 0 8px 28px rgba(139,92,246,0.55); }
.btn:hover::before { left: 160%; }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-ghost {
  background: var(--bg-tertiary); border: 1px solid var(--border-light);
  box-shadow: none; color: var(--text-secondary);
}
.btn-ghost:hover { background: rgba(0,0,0,0.05); box-shadow: none; }

:root.light-mode .btn-ghost {
  background: #ffffff;
  border: 1px solid var(--border-light);
  color: #2d2d4a;
}

:root.light-mode .btn-ghost:hover {
  background: #f9f9fb;
  border-color: #7c3aed;
  color: #000000;
}

.btn-outline {
  background: transparent; border: 1px solid rgba(139,92,246,0.35);
  color: var(--purple-light); box-shadow: none;
}
.btn-outline:hover { background: rgba(139,92,246,0.1); border-color: rgba(167,139,250,0.6); box-shadow: 0 0 14px rgba(139,92,246,0.2); }

.btn-danger {
  background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.25);
  color: var(--error); box-shadow: none;
}
.btn-danger:hover { background: rgba(239,68,68,0.18); border-color: rgba(239,68,68,0.45); box-shadow: none; }

.btn-sm { padding: 7px 14px; font-size: 12px; }
.btn-full { width: 100%; }

/* ══ CARDS ══════════════════════════════════ */
.card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: 18px;
  padding: 22px 24px;
  margin-bottom: 16px;
  position: relative; overflow: hidden;
}

:root.light-mode .card {
  background: #ffffff;
  box-shadow: var(--shadow-sm);
}

.card::after {
  content: ''; position: absolute; top: 0; left: 12%; right: 12%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(196,164,255,0.25), transparent);
}

:root.light-mode .card::after {
  display: none;
}
.card::before {
  content: ''; position: absolute; top: -50px; right: -50px;
  width: 160px; height: 160px;
  background: radial-gradient(circle, rgba(109,40,217,0.1) 0%, transparent 70%);
  pointer-events: none;
}

:root.light-mode .card::before {
  display: none;
}

.card-title {
  font-size: 10px; font-weight: 600; letter-spacing: 2px; text-transform: uppercase;
  color: rgba(196,164,255,0.55); margin-bottom: 18px;
  display: flex; align-items: center; gap: 8px;
  justify-content: flex-start !important;
}

:root.light-mode .card-title {
  color: #595975;
}
.card-title::before {
  content: ''; width: 3px; height: 12px;
  background: linear-gradient(180deg, var(--purple-light), var(--accent-dark));
  border-radius: 2px; flex-shrink: 0;
}

/* ══ FORM FIELDS ══════════════════════════════ */
.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 11px; font-weight: 500;
  color: rgba(220,210,255,0.7); margin-bottom: 6px; letter-spacing: 0.2px;
}

:root.light-mode .field label {
  color: #595975;
}
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 13px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: 9px;
  font-size: 13px; font-family: 'Sora', sans-serif;
  color: var(--text-primary);
  outline: none; transition: all 0.25s ease;
  -webkit-appearance: none;
}

:root.light-mode .field input,
:root.light-mode .field select,
:root.light-mode .field textarea {
  color: #000000;
}

:root.light-mode input[type="checkbox"] {
  accent-color: #7c3aed;
}

:root.light-mode input[type="date"],
:root.light-mode input[type="date"]::-webkit-calendar-picker-indicator {
  color: #000000;
  color-scheme: light;
}

:root.light-mode input[type="text"],
:root.light-mode input[type="email"],
:root.light-mode input[type="number"],
:root.light-mode input[type="search"] {
  color: #000000 !important;
  background: #ffffff !important;
}

:root.light-mode label {
  color: #2d2d4a !important;
}
.field input::placeholder, .field textarea::placeholder { color: var(--bg-tertiary); font-size: 12px; }

:root.light-mode .field input::placeholder,
:root.light-mode .field textarea::placeholder {
  color: #bfbfd8;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: rgba(160,120,255,0.55); background: var(--border-light);
  box-shadow: 0 0 0 3px rgba(139,92,246,0.1);
}
.field select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23b09cff' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 34px; background-color: var(--bg-tertiary);
}
.field select option { background: #1a0d3d; color: #fff; }
.field textarea { resize: vertical; min-height: 85px; line-height: 1.6; }

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

/* ══ PAGE HEADER ══════════════════════════════ */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 26px; }
.page-header h1 {
  font-family: 'DM Serif Display', serif; font-size: 28px; font-weight: 400; color: #fff; margin-bottom: 4px;
}

:root.light-mode .page-header h1 {
  color: #000000;
}

.page-header p { font-size: 12px; font-weight: 300; color: rgba(196,164,255,0.5); }

:root.light-mode .page-header p {
  color: #595975;
}

/* ══ STATS ══════════════════════════════════ */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 22px; }

.stat {
  background: var(--bg-tertiary); border: 1px solid var(--border-light);
  border-radius: 14px; padding: 16px 18px; position: relative; overflow: hidden;
}

:root.light-mode .stat {
  background: #ffffff;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}

.stat::before {
  content: ''; position: absolute; top: -30px; right: -20px;
  width: 90px; height: 90px;
  background: radial-gradient(circle, rgba(139,92,246,0.12) 0%, transparent 70%);
  pointer-events: none;
}

:root.light-mode .stat::before {
  display: none;
}
.stat-label { font-size: 9px; font-weight: 600; letter-spacing: 1.8px; text-transform: uppercase; color: rgba(196,164,255,0.5); margin-bottom: 8px; }

:root.light-mode .stat-label {
  color: #595975;
}

.stat-val { font-family: 'DM Serif Display', serif; font-size: 28px; line-height: 1; color: #fff; }

:root.light-mode .stat-val {
  color: #000000;
}

.stat-money { font-size: 12px; font-weight: 600; color: rgba(167, 139, 250, 0.85); margin-top: 6px; font-family: 'DM Mono', monospace; letter-spacing: 0.3px; }

:root.light-mode .stat-money {
  color: #7c3aed;
}

/* ══ TABLE ══════════════════════════════════ */
.table-wrap {
  background: rgba(255,255,255,0.03); border: 1px solid var(--border-light);
  border-radius: 18px; overflow: hidden;
  position: relative;
}

/* Visual indicator that table can be scrolled */
.table-wrap::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 20px;
  background: linear-gradient(to right, transparent, rgba(139,92,246,0.15));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

:root.light-mode .table-wrap {
  background: #ffffff;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 13px 17px; text-align: left;
  font-size: 10px; font-weight: 600; letter-spacing: 1.5px; text-transform: uppercase;
  color: rgba(196,164,255,0.45); border-bottom: 1px solid var(--bg-tertiary);
  white-space: nowrap;
}

:root.light-mode thead th {
  color: #595975;
  border-bottom: 1px solid #e0e1e8;
}

tbody tr { border-bottom: 1px solid var(--bg-tertiary); cursor: pointer; transition: background 0.18s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(139,92,246,0.05); }

:root.light-mode tbody tr:hover {
  background: rgba(124, 58, 237, 0.05);
}

tbody td {
  padding: 14px 17px;
  font-size: 13px;
  color: rgba(220, 210, 255, 0.75);
  vertical-align: middle;
}

:root.light-mode tbody td {
  color: #000000 !important;
}

:root.light-mode tbody td:not([style*="color"]) {
  color: #000000 !important;
}

.td-id { font-family: 'DM Mono', monospace; font-size: 11px; color: rgba(196,164,255,0.4); }

:root.light-mode .td-id {
  color: #000000;
}

.td-name { }

:root.light-mode .td-name {
  color: #000000 !important;
}

.quote-name-main {
  font-size: 12px;
  font-weight: 600;
  color: rgba(220,210,255,0.9);
}

:root.light-mode .quote-name-main {
  color: #000000;
}

.quote-name-sub {
  font-size: 11px;
  color: rgba(196,164,255,0.5);
  cursor: pointer;
  text-decoration: none;
}

:root.light-mode .quote-name-sub {
  color: #2d2d4a;
  text-decoration: none;
}

.quote-name-sub[onclick] {
  text-decoration: underline;
  cursor: pointer;
}

.td-currency { }

:root.light-mode .td-currency {
  color: #2d2d4a !important;
}

.td-date {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: rgba(196, 164, 255, 0.4);
}

:root.light-mode .td-date {
  color: #000000 !important;
}

.td-kam {
  font-size: 12px;
  color: rgba(196, 164, 255, 0.7);
}

:root.light-mode .td-kam {
  color: #000000 !important;
}

.td-amount {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  font-weight: 500;
}

:root.light-mode .td-amount {
  color: #2d2d4a;
}

.td-margin {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--warning);
}

/* Light mode: all table cells override */
:root.light-mode table tbody tr {
  color: #000000;
}

:root.light-mode table tbody tr td {
  color: #000000 !important;
}

:root.light-mode #users-body td,
:root.light-mode #kams-body td {
  color: #000000 !important;
}

/* Override inline color styles in light mode */
:root.light-mode td[style*="color"] {
  color: #000000 !important;
}

/* Select dropdown in light mode */
:root.light-mode select[style*="background"] {
  background: #ffffff !important;
  border-color: #e0e1e8 !important;
  color: #000000 !important;
}

/* Badge badges in light mode */
:root.light-mode .badge[style*="color"] {
  color: #000000 !important;
}

:root.light-mode .td-margin {
  color: #7c3aed;
}

.empty-state { text-align: center; padding: 64px 20px; }
.empty-icon { font-size: 38px; opacity: 0.25; margin-bottom: 12px; }
.empty-state p { font-size: 13px; color: rgba(196,164,255,0.35); font-weight: 300; }

:root.light-mode .empty-state p {
  color: #7a7a9e;
}

/* ══ STATUS BADGES ══════════════════════════════ */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px;
  border-radius: 20px; font-size: 10px; font-weight: 600;
  font-family: 'DM Mono', monospace; letter-spacing: 0.3px; white-space: nowrap;
}
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge-draft        { background: var(--bg-tertiary); color: rgba(200,185,255,0.4); }
.badge-sent         { background: rgba(58,143,255,0.14); color: var(--info); }
.badge-under_review { background: rgba(245,166,35,0.14); color: var(--warning); }
.badge-modified     { background: rgba(245,166,35,0.14); color: var(--warning); }
.badge-accepted     { background: rgba(76,217,100,0.14); color: var(--success); }
.badge-rejected     { background: rgba(255,80,80,0.14); color: #ff9090; }
.badge-purchased    { background: rgba(139,92,246,0.18); color: var(--purple-light); }
.badge-closed       { background: var(--bg-tertiary); color: rgba(196,164,255,0.25); }

/* ══ FORM VIEW ══════════════════════════════════ */
.form-header { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; flex-wrap: wrap; }
.form-header h1 { font-family: 'DM Serif Display', serif; font-size: 24px; font-weight: 400; flex: 1; }

:root.light-mode .form-header h1 {
  color: #000000;
}

.id-pill {
  font-family: 'DM Mono', monospace; font-size: 10px;
  background: rgba(139,92,246,0.12); border: 1px solid rgba(139,92,246,0.22);
  border-radius: 6px; padding: 3px 9px; color: var(--purple-light);
}

:root.light-mode .id-pill {
  background: rgba(124, 58, 237, 0.1);
  border: 1px solid rgba(124, 58, 237, 0.25);
  color: #7c3aed;
}

.form-layout { display: grid; grid-template-columns: 1fr 288px; gap: 20px; align-items: start; }

/* ══ ITEMS TABLE ══════════════════════════════ */
.items-scroll { overflow-x: auto; margin-bottom: 12px; }
/* ══ GRID LAYOUT FOR ITEMS ══ */
.items-grid {
  display: grid;
  grid-template-columns: auto;
  gap: 0;
  width: 100%;
}

.items-header {
  display: grid;
  grid-template-columns: 30px 1fr 50px 100px 70px 100px 120px 90px 30px;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--bg-tertiary);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(196,164,255,0.38);
  align-items: center;
}

:root.light-mode .items-header {
  color: #595975;
  border-bottom: 1px solid #e0e1e8;
}
:root.light-mode div#client-response-items div span:first-child {
    color: #702adc !important;
}
:root.light-mode .cur-row .cur-btn {
    color: var(--accent-primary);
}
:root.light-mode .cur-row .cur-btn.active {
    color: var(--bg-primary);
}

.items-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.items-row {
  display: grid;
  grid-template-columns: 30px 1fr 50px 100px 70px 100px 120px 90px 30px;
  gap: 8px;
  align-items: start;
  padding: 8px 0;
  border-bottom: 1px solid rgba(139,92,246,0.1);
  align-items: center;
}

:root.light-mode .items-row {
  border-bottom: 1px solid #e0e1e8;
}

.items-row:hover {
  background: rgba(139,92,246,0.03);
}

:root.light-mode .items-row:hover {
  background: rgba(124,58,237,0.03);
}

.items-group-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: rgba(139,92,246,0.08);
  border-left: 3px solid #8b5cf6;
  font-weight: 700;
  font-size: 13px;
  color: #c4b5fd;
  letter-spacing: 0.3px;
}

/* Column wrappers */
.items-col-num, .items-col-qty, .items-col-margin, .items-col-action {
  display: flex;
  align-items: center;
  justify-content: center;
}

.items-col-desc, .items-col-supplier, .items-col-price, .items-col-cost, .items-col-subtotal {
  display: flex;
  align-items: stretch;
  width: 100%;
}

/* Inputs and Textareas */
.items-grid input,
.items-grid textarea {
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: 6px;
  font-size: 12px;
  font-family: 'Sora', sans-serif;
  color: var(--text-primary);
  outline: none;
  transition: all 0.2s;
  box-sizing: border-box;
  min-height: 36px;
}

.items-grid input:focus,
.items-grid textarea:focus {
  border-color: rgba(139, 92, 246, 0.6);
  background: rgba(139, 92, 246, 0.05);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.1);
}

.items-grid input[type="number"] {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  text-align: right;
}

/* Textarea para descripción */
.items-desc-textarea {
  min-height: 40px;
  resize: vertical;
  line-height: 1.4;
  overflow-wrap: break-word;
  white-space: pre-wrap;
}

:root.light-mode .items-grid input,
:root.light-mode .items-grid textarea {
  border-color: rgba(124, 58, 237, 0.2);
  color: #000000;
}

:root.light-mode .items-grid input:focus,
:root.light-mode .items-grid textarea:focus {
  border-color: rgba(124, 58, 237, 0.5);
  background: rgba(124, 58, 237, 0.05);
}

.cost-tag {
  display: inline-block; font-size: 8px; background: rgba(245,166,35,0.14);
  color: var(--warning); border-radius: 3px; padding: 1px 5px;
  font-family: 'DM Mono', monospace; margin-left: 4px; vertical-align: middle;
}

.item-sub { font-family: 'DM Mono', monospace; font-size: 11px; color: rgba(196,164,255,0.5); text-align: right; padding: 0 8px; white-space: nowrap; }

:root.light-mode .item-sub {
  color: #7a7a9e;
}

.remove-btn {
  background: none; border: none; cursor: pointer; color: rgba(0,0,0,0.05);
  font-size: 18px; line-height: 1; padding: 4px 8px; border-radius: 6px; transition: all 0.2s;
}
.remove-btn:hover { color: var(--error); background: rgba(239,68,68,0.1); }

/* ══ CURRENCY TOGGLE ══════════════════════════════ */
.cur-row { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.cur-label { font-size: 10px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: rgba(196,164,255,0.4); }

:root.light-mode .cur-label {
  color: #595975;
}
.cur-btn {
  padding: 4px 14px; border-radius: 20px; font-family: 'DM Mono', monospace;
  font-size: 11px; font-weight: 500; cursor: pointer;
  border: 1px solid rgba(0,0,0,0.05); background: transparent; color: rgba(255,255,255,0.3);
  transition: all 0.22s;
}
.cur-btn.active {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-dark));
  border-color: rgba(139,92,246,0.5); color: #fff;
  box-shadow: 0 2px 10px rgba(109,40,217,0.38);
}

/* ══ TOTALS ══════════════════════════════════ */
.totals {
  background: rgba(139,92,246,0.06); border: 1px solid rgba(139,92,246,0.18);
  border-radius: 12px; padding: 14px 16px; margin-top: 12px;
}
.totals-row { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 12px; }
.totals-row label { color: rgba(196,164,255,0.55); }

:root.light-mode .totals-row label {
  color: #595975;
}

.totals-row .amt { font-family: 'DM Mono', monospace; color: rgba(220,210,255,0.7); }

:root.light-mode .totals-row .amt {
  color: #2d2d4a;
}

.totals-row.margin .amt { color: var(--warning); }
.totals-row.grand { border-top: 1px solid rgba(139,92,246,0.18); margin-top: 8px; padding-top: 11px; }

:root.light-mode .totals-row.grand {
  border-top: 1px solid #e0e1e8;
}

.totals-row.grand label { font-size: 13px; font-weight: 600; color: rgba(220,210,255,0.9); }

:root.light-mode .totals-row.grand label {
  color: #000000;
}

.totals-row.grand .amt { font-size: 15px; font-weight: 600; color: var(--purple-light); }

:root.light-mode .totals-row.grand .amt {
  color: #7c3aed;
}

/* ══ RECIPIENTS ══════════════════════════════════ */
.rec-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; margin-bottom: 8px; }
.rec-row input {
  padding: 9px 11px; background: var(--bg-tertiary); border: 1px solid var(--border-light);
  border-radius: 8px; font-size: 12px; font-family: 'Sora', sans-serif;
  color: var(--text-primary); outline: none; transition: all 0.2s; width: 100%;
}
.rec-row input:focus { border-color: rgba(160,120,255,0.5); background: var(--border-light); box-shadow: 0 0 0 2px rgba(139,92,246,0.1); }
.rec-label { font-size: 10px; font-weight: 500; color: rgba(196,164,255,0.5); margin-bottom: 5px; display: block; }

:root.light-mode .rec-label {
  color: #595975;
}

/* ══ SIDEBAR ══════════════════════════════════ */
.sidebar { position: sticky; top: 74px; }

.action-card {
  background: var(--bg-tertiary); border: 1px solid var(--border-light);
  border-radius: 16px; padding: 18px; margin-bottom: 12px; position: relative; overflow: hidden;
}

:root.light-mode .action-card {
  background: #ffffff;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}

.action-card::after {
  content: ''; position: absolute; top: 0; left: 12%; right: 12%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(196,164,255,0.3), transparent);
}

:root.light-mode .action-card::after {
  display: none;
}

:root.light-mode .action-card h3 {
  color: #595975;
}
.action-card h3 {
  font-size: 9px; font-weight: 600; letter-spacing: 2px; text-transform: uppercase;
  color: rgba(196,164,255,0.45); margin-bottom: 13px;
}
.action-card .btn { width: 100%; margin-bottom: 7px; }
.action-card .btn:last-child { margin-bottom: 0; }

.summary-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 12px; border-bottom: 1px solid var(--bg-tertiary); }
.summary-row:last-child { border-bottom: none; }
.summary-row label { color: rgba(196,164,255,0.45); }

:root.light-mode .summary-row {
  border-bottom: 1px solid #e0e1e8;
}

:root.light-mode .summary-row label {
  color: #595975;
}

.summary-row span { color: var(--text-secondary); font-weight: 500; }

:root.light-mode .summary-row span {
  color: #2d2d4a;
}

/* ══ TOGGLE CLIENT ══════════════════════════════ */
.toggle-link {
  font-size: 11px; color: var(--purple-light); cursor: pointer; background: none; border: none;
  font-family: 'Sora', sans-serif; padding: 0; text-decoration: underline; text-underline-offset: 2px;
}

:root.light-mode .toggle-link {
  color: #7c3aed;
}
.new-client-form { display: none; }
.new-client-form.open { display: block; }
.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(196,164,255,0.18), transparent);
  margin: 16px 0;
}

/* ══ LOADER ══════════════════════════════════ */
.loader {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.08); border-top-color: var(--accent-primary);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
.loading-cell { text-align: center !important; padding: 50px !important; }

/* ══ TOAST ══════════════════════════════════ */
#toast {
  position: fixed; bottom: 22px; right: 22px; z-index: 9999;
  display: flex; flex-direction: column; gap: 7px;
}
.toast {
  background: rgba(14,8,28,0.97); backdrop-filter: blur(20px);
  border: 1px solid var(--border-light); border-radius: 11px;
  padding: 11px 16px; font-size: 12px; font-weight: 500;
  display: flex; align-items: center; gap: 9px;
  animation: toastIn 0.22s ease; max-width: 290px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.45);
}

:root.light-mode .toast {
  background: #ffffff;
  border: 1px solid #e0e1e8;
  box-shadow: 0 8px 28px rgba(124, 58, 237, 0.15);
}

.toast.ok  { border-color: rgba(76,217,100,0.28); color: var(--success); }

:root.light-mode .toast.ok {
  border-color: rgba(16, 185, 129, 0.3);
  color: #059669;
}

.toast.err { border-color: rgba(239,68,68,0.28); color: var(--error); }

:root.light-mode .toast.err {
  border-color: rgba(239, 68, 68, 0.3);
  color: #dc2626;
}

.toast.inf { border-color: rgba(139,92,246,0.32); color: var(--purple-light); }

:root.light-mode .toast.inf {
  border-color: rgba(124, 58, 237, 0.3);
  color: #7c3aed;
}

/* ══ RESPONSIVE — GENERAL ══════════════════════════════════ */
@media (max-width: 960px) {
  .form-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .main { padding: 20px 16px; }
  .stats { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .grid-2 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
  .rec-row { grid-template-columns: 1fr; }
}

/* ══ RESPONSIVE — TOPBAR MOBILE ════════════════════════════ */
@media (max-width: 768px) {
  .topbar {
    padding: 0 16px;
    gap: 10px;
  }

  .topbar-brand span {
    display: none;
  }

  .topbar-sep {
    display: none;
  }

  .topbar-hamburger {
    display: flex;
  }

  .topbar-right .user-chip span {
    display: none;
  }

  .topbar-nav {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    background: rgba(10,6,18,0.97);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    padding: 10px;
    gap: 4px;
    z-index: 199;
    border-radius: 0;
    border: none;
    justify-content: flex-start;
    flex: unset;
  }

  .topbar-nav.open {
    display: flex;
  }

  .nav-link {
    padding: 10px 16px;
    font-size: 13px;
  }

  /* ══ TABLE — MOBILE HORIZONTAL SCROLL ═════════════════════ */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 100%;
  }

  /* ══ ITEMS GRID — MOBILE CARD LAYOUT ════════════════════ */
  .items-header {
    display: none;
  }

  .items-row {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 12px;
    background: rgba(139,92,246,0.04);
    border-radius: 8px;
    margin-bottom: 8px;
    border: 1px solid rgba(139,92,246,0.15);
  }

  :root.light-mode .items-row {
    background: #f8f7ff;
    border: 1px solid #e0e1e8;
  }

  /* Show label before each field */
  .items-col-num::before    { content: "#"; }
  .items-col-desc::before   { content: "Descripción"; }
  .items-col-qty::before    { content: "Cantidad"; }
  .items-col-price::before  { content: "Precio cliente"; }
  .items-col-margin::before { content: "Margen %"; }
  .items-col-cost::before   { content: "Precio costo"; }
  .items-col-supplier::before { content: "Proveedor"; }
  .items-col-subtotal::before { content: "Subtotal"; }

  /* Label style */
  [class^="items-col-"]::before {
    display: block;
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(196,164,255,0.5);
    margin-bottom: 4px;
  }

  :root.light-mode [class^="items-col-"]::before {
    color: #595975;
  }

  /* Hide action col number and action button label */
  .items-col-num::before,
  .items-col-action::before {
    display: none;
  }

  /* Full-width inputs */
  .items-col-desc,
  .items-col-price,
  .items-col-cost,
  .items-col-supplier,
  .items-col-subtotal {
    flex-direction: column;
  }

  /* Row: label left, input right for numeric fields */
  .items-col-qty,
  .items-col-margin {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  /* Group header stays full-width */
  .items-group-header {
    grid-column: 1 / -1;
  }
}

/* ══ ITEM NUMBER ══════════════════════════════ */
.item-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  background: rgba(139,92,246,0.12); border: 1px solid rgba(139,92,246,0.22);
  border-radius: 6px; font-size: 10px; font-weight: 700;
  color: rgba(196,164,255,0.7); font-family: 'DM Mono', monospace;
  flex-shrink: 0;
}

/* ══ SUPPLIER ORDERS ══════════════════════════════ */
.supplier-group {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-light);
  border-radius: 14px; padding: 16px 18px; margin-bottom: 12px;
}

:root.light-mode .supplier-group {
  background: #ffffff;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}
.supplier-group:last-child { margin-bottom: 0; }

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

.supplier-name {
  font-size: 14px; font-weight: 700; color: rgba(220,210,255,0.9);
}

:root.light-mode .supplier-name {
  color: #000000;
}

.supplier-items-list {
  display: flex; flex-direction: column; gap: 5px;
  margin-bottom: 14px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.03);
  border-radius: 8px;
}

.supplier-item-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: rgba(196,164,255,0.7);
}

:root.light-mode .supplier-item-row {
  color: #2d2d4a;
}

.supplier-item-qty {
  font-family: 'DM Mono', monospace; font-size: 11px;
  color: rgba(196,164,255,0.45); flex-shrink: 0;
}

:root.light-mode .supplier-item-qty {
  color: #7a7a9e;
}

.supplier-send-form { margin-top: 4px; }
.supplier-send-form .field { margin-bottom: 10px; }
.supplier-send-form .field:last-of-type { margin-bottom: 12px; }

.supplier-confirmed-msg {
  background: rgba(52,211,153,0.07); border: 1px solid rgba(52,211,153,0.2);
  border-radius: 8px; padding: 10px 12px;
  font-size: 12px; color: #6ee7b7;
}

/* ══ MODALS — LIGHT MODE ════════════════════════════════════ */

:root.light-mode .modal-content {
  background: #ffffff !important;
  border: 1px solid #d4d4e8 !important;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

:root.light-mode .modal-content h2 {
  color: #000000;
}

:root.light-mode .modal-content .field label {
  color: #595975;
}

:root.light-mode .modal-content .field input,
:root.light-mode .modal-content .field select {
  background: #ffffff;
  border: 1px solid #d4d4e8;
  color: #000000;
}

:root.light-mode .modal-content .field input::placeholder,
:root.light-mode .modal-content .field input:placeholder-shown {
  color: #aaaabc;
}

:root.light-mode .modal-content .field input:focus,
:root.light-mode .modal-content .field select:focus {
  border-color: #8b5cf6;
  background: #ffffff;
}

:root.light-mode .modal-content button.btn {
  color: #ffffff;
}

:root.light-mode #modal-error,
:root.light-mode #kam-modal-error {
  background: rgba(239, 68, 68, 0.1) !important;
  border: 1px solid rgba(239, 68, 68, 0.25) !important;
  color: #dc2626 !important;
}

/* Modal close buttons - visible in light mode */
:root.light-mode .modal-content button[onclick="closeModal()"],
:root.light-mode .modal-content button[onclick="closeKamModal()"],
:root.light-mode .modal-content button[onclick="closeEditClientModal()"],
:root.light-mode .modal-content button[onclick="closeConfirmModal()"],
:root.light-mode .modal-content button[onclick="closeRejectModal()"] {
  background: rgba(0, 0, 0, 0.08) !important;
  color: #000000 !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
}

:root.light-mode .modal-content button[onclick="closeModal()"]:hover,
:root.light-mode .modal-content button[onclick="closeKamModal()"]:hover,
:root.light-mode .modal-content button[onclick="closeEditClientModal()"]:hover,
:root.light-mode .modal-content button[onclick="closeConfirmModal()"]:hover,
:root.light-mode .modal-content button[onclick="closeRejectModal()"]:hover {
  background: rgba(0, 0, 0, 0.12) !important;
}

/* Text colors in confirm/reject modals */
:root.light-mode #confirm-message,
:root.light-mode #modal-confirm p {
  color: #595975 !important;
}

:root.light-mode textarea {
  background: #ffffff !important;
  border: 1px solid #d4d4e8 !important;
  color: #000000 !important;
}

/* Version preview modal - light mode overrides */
:root.light-mode div[style*="background:#0f0820"][style*="border-radius:16px"] {
  background: #ffffff !important;
  border: 1px solid #e0e1e8 !important;
}

/* Version modal: title (Version N) - black text */
:root.light-mode div[style*="background:#0f0820"] span[style*="color:#fff"][style*="font-weight:700"] {
  color: #000000 !important;
}

/* Version modal: date - gray text */
:root.light-mode div[style*="background:#0f0820"] span[style*="rgba(196,164,255,0.5)"] {
  color: #7a7a9e !important;
}

/* Version modal: close button (X) - dark background, dark text */
:root.light-mode div[style*="background:#0f0820"] button[onclick*="closest"] {
  background: rgba(0, 0, 0, 0.08) !important;
  color: #000000 !important;
  border: 1px solid rgba(0, 0, 0, 0.12) !important;
}

:root.light-mode div[style*="background:#0f0820"] button[onclick*="closest"]:hover {
  background: rgba(0, 0, 0, 0.12) !important;
}

/* Version modal: table header */
:root.light-mode div[style*="background:#0f0820"] thead tr {
  background: rgba(124, 58, 237, 0.08) !important;
}

:root.light-mode div[style*="background:#0f0820"] th {
  color: #7a7a9e !important;
}

/* Version modal: table body rows */
:root.light-mode div[style*="background:#0f0820"] tbody tr {
  border-bottom: 1px solid #e0e1e8 !important;
}

:root.light-mode div[style*="background:#0f0820"] tbody td {
  color: #000000 !important;
}

/* Quantities and prices - gray */
:root.light-mode div[style*="background:#0f0820"] tbody td[style*="text-align:center"],
:root.light-mode div[style*="background:#0f0820"] tbody td[style*="text-align:right"] {
  color: #595975 !important;
}

/* Subtotal column - purple */
:root.light-mode div[style*="background:#0f0820"] tbody td[style*="font-weight:600"]:last-child {
  color: #7c3aed !important;
}

/* Version modal: table footer */
:root.light-mode div[style*="background:#0f0820"] tfoot tr {
  background: rgba(124, 58, 237, 0.08) !important;
}

:root.light-mode div[style*="background:#0f0820"] tfoot td {
  color: #595975 !important;
}

/* Total amount in footer - purple */
:root.light-mode div[style*="background:#0f0820"] tfoot td[style*="color:#c4b5fd"] {
  color: #7c3aed !important;
}

/* Version modal: message section - light background */
:root.light-mode div[style*="background:#0f0820"] > div[style*="margin-top:16px"] {
  background: rgba(124, 58, 237, 0.06) !important;
  border: 1px solid rgba(124, 58, 237, 0.15) !important;
}

/* Message text - BLACK */
:root.light-mode div[style*="background:#0f0820"] > div[style*="margin-top:16px"] {
  color: #000000 !important;
}

/* Message label - gray */
:root.light-mode div[style*="background:#0f0820"] > div[style*="margin-top:16px"] strong {
  color: #7a7a9e !important;
}

/* Brief files list - light mode file names to black */
:root.light-mode #brief-list span[style*="rgba(220,210,255,0.8)"] {
  color: #000000 !important;
}

/* Brief file size - light mode */
:root.light-mode #brief-list span[style*="rgba(196,164,255,0.35)"] {
  color: #9ca3af !important;
}

/* Brief loading and empty messages */
:root.light-mode #brief-list div[style*="color:#a78bfa"],
:root.light-mode #brief-list div[style*="rgba(196,164,255,0.4)"] {
  color: #595975 !important;
}

/* Selected brief filename - light mode */
:root.light-mode #brief-filename {
  color: #000000 !important;
}

/* Brief upload progress message */
:root.light-mode #brief-upload-progress {
  color: #595975 !important;
}

/* Kanban styles moved to css/kanban.css */