:root {
  --topbar-h: 72px;
  --bg: #f3f6fb;
  --bg-strong: #e7efff;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #0f172a;
  --muted: #64748b;
  --primary: #1d4ed8;
  --primary-700: #1e3a8a;
  --accent: #0ea5a4;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --border: #e2e8f0;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Manrope", "Sora", sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, #eef3ff 0%, #f6f8fc 40%, #ffffff 100%);
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 10% 10%, rgba(29, 78, 216, 0.14), transparent 45%),
    radial-gradient(circle at 80% 0%, rgba(14, 165, 164, 0.12), transparent 40%),
    radial-gradient(circle at 20% 80%, rgba(59, 130, 246, 0.08), transparent 45%);
  pointer-events: none;
  z-index: -1;
}

body.theme-dark {
  --bg: #0b1220;
  --bg-strong: #0f1b35;
  --surface: #0f172a;
  --surface-2: #111827;
  --ink: #e2e8f0;
  --muted: #94a3b8;
  --primary: #60a5fa;
  --primary-700: #93c5fd;
  --accent: #22d3ee;
  --success: #22c55e;
  --warning: #fbbf24;
  --danger: #f87171;
  --info: #60a5fa;
  --border: #1f2937;
  --shadow: 0 16px 40px rgba(2, 6, 23, 0.6);
  background: linear-gradient(160deg, #0b1220 0%, #0b1324 50%, #0f172a 100%);
}

body.theme-dark::before {
  background:
    radial-gradient(circle at 10% 10%, rgba(96, 165, 250, 0.12), transparent 45%),
    radial-gradient(circle at 80% 0%, rgba(34, 211, 238, 0.12), transparent 40%),
    radial-gradient(circle at 20% 80%, rgba(99, 102, 241, 0.12), transparent 45%);
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w, 240px) 1fr;
  grid-template-areas: "sidebar main";
  min-height: 100vh;
  padding-top: var(--topbar-h);
  box-sizing: border-box;
  transition: grid-template-columns 0.3s cubic-bezier(.4,0,.2,1);
}

/* ── Sidebar wrapper (grid item) ───────────────────────── */
.sidebar-wrapper {
  grid-area: sidebar;
}

/* ── Sidebar shell ─────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: calc(var(--topbar-h) + 12px);
  left: 12px;
  width: calc(var(--sidebar-w, 240px) - 24px);
  height: calc(100vh - var(--topbar-h) - 24px);
  background: var(--surface);
  border: none;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.10);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.3s cubic-bezier(.4,0,.2,1), left 0.3s cubic-bezier(.4,0,.2,1);
  z-index: 10;
}

body.theme-dark .sidebar {
  background: var(--surface);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

/* ── Sidebar header (oculto — hamburger movido al topbar) ── */
.sb-header {
  display: none;
}

.sb-logo {
  width: 200px;
  height: auto;
  max-height: 100px;
  border-radius: 10px;
  object-fit: contain;
}

.sb-brand-name {
  font-family: "Sora", sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  text-align: center;
}

.sb-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}
.sb-toggle:hover {
  background: var(--bg-strong);
  border-color: var(--primary);
  color: var(--primary);
}

/* ── Nav area ──────────────────────────────────────────── */
.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 12px 8px;
}

.nav::-webkit-scrollbar { width: 4px; }
.nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── Nav item (top-level link or group toggle) ─────────── */
.sb-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  font-family: inherit;
  line-height: 1.3;
}

.sb-item:hover {
  background: var(--bg-strong);
}

.sb-item.active,
.sb-group.is-open > .sb-item {
  background: rgba(29, 78, 216, 0.09);
  color: var(--primary);
}

.sb-item.active .sb-icon,
.sb-group.is-open > .sb-item .sb-icon {
  opacity: 1;
  color: var(--primary);
}

.sb-item.active .sb-label,
.sb-group.is-open > .sb-item .sb-label {
  color: var(--primary);
  font-weight: 600;
}

.sb-item.active .sb-arrow,
.sb-group.is-open > .sb-item .sb-arrow,
.sb-item.active .sb-chevron,
.sb-group.is-open > .sb-item .sb-chevron {
  color: var(--primary);
}

.sb-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.65;
}

.sb-item:hover .sb-icon {
  opacity: 1;
}

.sb-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}

.sb-chevron {
  flex-shrink: 0;
  width: 14px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  opacity: 0.5;
}

/* Arrow for accordion groups */
.sb-arrow {
  flex-shrink: 0;
  color: var(--muted);
  transition: transform 0.25s ease;
  opacity: 0.5;
}

.sb-group.is-open > .sb-item .sb-arrow {
  transform: rotate(180deg);
}

/* ── Sub-menu (accordion children) ─────────────────────── */
.sb-sub {
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0 2px 12px;
  margin-top: 2px;
}

.sb-group.is-open > .sb-sub {
  display: flex;
}

.sb-sub-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 600;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}

.sb-sub-link:hover {
  background: rgba(29, 78, 216, 0.07);
  color: var(--primary);
}

.sb-sub-link.active {
  background: rgba(29, 78, 216, 0.08);
  color: var(--primary);
  font-weight: 700;
}

.sb-sub-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.5;
}

.sb-sub-link.active .sb-sub-icon,
.sb-sub-link:hover .sb-sub-icon {
  opacity: 0.85;
}

/* ── Sidebar footer ────────────────────────────────────── */
.sb-footer {
  flex-shrink: 0;
  padding: 6px 12px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* ── Collapsed state ───────────────────────────────────── */
body.sidebar-collapsed {
  --sidebar-w: 72px;
}

body.sidebar-collapsed .sb-brand-name,
body.sidebar-collapsed .sb-logo,
body.sidebar-collapsed .sb-label,
body.sidebar-collapsed .sb-chevron,
body.sidebar-collapsed .sb-arrow {
  display: none;
}

body.sidebar-collapsed .sb-header {
  padding: 14px 8px 10px;
}

body.sidebar-collapsed .nav {
  padding: 6px 8px;
  align-items: center;
}

body.sidebar-collapsed .sb-item {
  justify-content: center;
  padding: 12px;
  width: 48px;
  border-radius: var(--radius-md);
}

body.sidebar-collapsed .sb-icon {
  opacity: 0.75;
}

body.sidebar-collapsed .sb-sub {
  display: none !important;
}

body.sidebar-collapsed .sb-footer {
  padding: 8px 8px 14px;
  align-items: center;
}

body.sidebar-collapsed .sb-footer .sb-item {
  width: 48px;
}

/* Tooltip on hover in collapsed mode */
body.sidebar-collapsed .sb-item {
  position: relative;
}

body.sidebar-collapsed .sb-item[title]:hover::after,
body.sidebar-collapsed .sb-item[data-tooltip]:hover::after {
  content: attr(title);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--ink);
  color: var(--surface);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  z-index: 100;
  pointer-events: none;
}

/* Legacy classes kept for badge styling */
.empresa-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 6px;
  font-size: .75rem;
  font-weight: 600;
  background: var(--bg-strong, #f1f5f9);
  color: var(--text-muted, #64748b);
}

.empresa-count-badge.multi {
  background: #eff6ff;
  color: #2563eb;
}

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

.force-password-change .app-shell {
  grid-template-columns: 1fr;
  grid-template-areas: "main";
}

.force-password-change .sidebar {
  display: none;
}

.force-password-change .topbar-left {
  display: none;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  gap: 16px;
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  z-index: 100;
  background: var(--bg);
  border-bottom: none;
  box-shadow: none;
}

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

.topbar-hamburger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  color: var(--ink);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06);
}

.topbar-hamburger:hover {
  background: var(--bg-strong);
  border-color: var(--primary);
}

.topbar-logo-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

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

/* ── Global search ──────────────────────────────────── */
.topbar-search {
  position: relative;
}
.topbar-search-input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-strong);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.topbar-search-input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(29,78,216,0.12);
}
.topbar-search-icon {
  flex-shrink: 0;
  color: var(--muted);
}
.topbar-search-input {
  border: none;
  outline: none;
  background: transparent;
  font-size: 13px;
  width: 180px;
  color: var(--ink);
  font-family: inherit;
}
.topbar-search-input::placeholder {
  color: var(--muted);
}
.topbar-search-kbd {
  font-size: 10px;
  font-family: inherit;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  line-height: 1.4;
  pointer-events: none;
}
.topbar-search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  min-width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.15);
  max-height: 420px;
  overflow-y: auto;
  z-index: 200;
}
.topbar-search-dropdown[hidden] { display: none; }
.search-group-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  padding: 10px 14px 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.search-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
  font-size: 13px;
  transition: background 0.1s;
}
.search-item:hover,
.search-item.active {
  background: var(--bg-strong);
}
.search-item-main {
  flex: 1;
  min-width: 0;
}
.search-item-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-item-sub {
  font-size: 11px;
  color: var(--muted);
}
.search-item-right {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.search-empty {
  padding: 16px 14px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
@media (max-width: 768px) {
  .topbar-search-input { width: 100px; }
  .topbar-search-kbd { display: none; }
  .topbar-search-dropdown { min-width: 260px; right: 0; left: auto; }
  .user-toggle-name { display: none; }
  .user-menu-toggle { padding: 3px; }
  .user-menu-panel { min-width: 220px; }
}

.topbar-logo {
  height: auto;
  max-height: 38px;
  width: auto;
  display: block;
}

.topbar-brand-wrap {
  display: flex;
  flex-direction: column;
  gap: 0px;
}

.topbar-brand {
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
  white-space: nowrap;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.3;
}

.topbar-subtitle {
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 1.3;
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-btn {
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}

.theme-btn:hover {
  background: var(--bg-strong);
}

.theme-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.35);
}

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

.theme-btn .icon-sun {
  display: none;
}

body.theme-dark .theme-btn .icon-sun {
  display: block;
}

body.theme-dark .theme-btn .icon-moon {
  display: none;
}

body.theme-dark .theme-btn {
  background: #0b1220;
  color: #e2e8f0;
  border-color: #1f2937;
}

body.theme-dark .user-menu-panel {
  background: #111827;
  border-color: #1f2937;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}
body.theme-dark .user-panel-name {
  color: #f1f5f9;
}
body.theme-dark .user-panel-email {
  color: #94a3b8;
}
body.theme-dark .user-panel-role {
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
}
body.theme-dark .user-panel-divider {
  background: #1f2937;
}
body.theme-dark .action-menu-item {
  color: #e2e8f0;
}
body.theme-dark .action-menu-item:hover {
  background: rgba(148, 163, 184, 0.1);
}
body.theme-dark .action-menu-item--danger {
  color: #fca5a5;
}
body.theme-dark .action-menu-item--danger:hover {
  background: rgba(239, 68, 68, 0.12);
}
body.theme-dark .user-menu-toggle {
  border-color: #1f2937;
}
body.theme-dark .user-menu-toggle:hover {
  background: rgba(148, 163, 184, 0.08);
}
body.theme-dark .user-toggle-name {
  color: #e2e8f0;
}
body.theme-dark .user-chevron-icon {
  color: #64748b;
}

body.theme-dark .permission-group {
  background: #0b1220;
  border-color: #1f2937;
}

body.theme-dark .permission-item:hover {
  background: rgba(148, 163, 184, 0.12);
}

body.theme-dark .permission-badge {
  background: rgba(148, 163, 184, 0.18);
  color: #cbd5f5;
}

/* ── Notification bell ────────────────────────────────────────── */
.notif-bell {
  position: relative;
}
.notif-bell-btn {
  position: relative;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--ink);
  transition: background 0.15s;
}
.notif-bell-btn:hover {
  background: var(--bg-strong);
}
.notif-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: #dc2626;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: grid;
  place-items: center;
  padding: 0 4px;
  line-height: 1;
}
.notif-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 320px;
  max-height: 400px;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.10);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16);
  z-index: 220;
  display: none;
  flex-direction: column;
  animation: userMenuIn 0.15s ease;
}
.notif-bell.is-open .notif-panel {
  display: flex;
}
.notif-panel-head {
  padding: 12px 14px 8px;
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
  border-bottom: 1px solid var(--border);
}
.notif-panel-body {
  overflow-y: auto;
  max-height: 340px;
  padding: 6px;
}
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--ink);
  transition: background 0.15s;
}
.notif-item:hover {
  background: rgba(15, 23, 42, 0.05);
}
.notif-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}
.notif-dot--error { background: #dc2626; }
.notif-dot--warning { background: #d97706; }
.notif-dot--info { background: #2563eb; }
.notif-item-content {
  flex: 1;
  min-width: 0;
}
.notif-item-title {
  font-weight: 600;
  font-size: 12.5px;
  line-height: 1.3;
}
.notif-item-msg {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.3;
  margin-top: 1px;
}
.notif-empty {
  padding: 24px 14px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
/* Dark mode */
body.theme-dark .notif-bell-btn {
  border-color: #1f2937;
}
body.theme-dark .notif-bell-btn:hover {
  background: rgba(148, 163, 184, 0.08);
}
body.theme-dark .notif-panel {
  background: #111827;
  border-color: #1f2937;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}
body.theme-dark .notif-panel-head {
  border-color: #1f2937;
}
body.theme-dark .notif-item:hover {
  background: rgba(148, 163, 184, 0.08);
}

/* ── User menu (toggle + dropdown) ───────────────────────────── */
.user-pill {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1d4ed8, #0ea5a4);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 11px;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.user-menu {
  position: relative;
}

.user-menu-toggle {
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 999px;
  padding: 3px 10px 3px 3px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  color: var(--ink);
  font-family: inherit;
}

.user-menu-toggle:hover {
  background: var(--bg-strong);
}

.user-menu-toggle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.35);
}

.user-toggle-name {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  line-height: 1;
}

.user-chevron-icon {
  color: var(--muted);
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.user-menu.is-open .user-chevron-icon {
  transform: rotate(180deg);
}

/* ── Dropdown panel ──────────────────────────────────────────── */
.user-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 240px;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.10);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16);
  padding: 6px;
  display: none;
  flex-direction: column;
  z-index: 220;
  animation: userMenuIn 0.15s ease;
}

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

.user-menu.is-open .user-menu-panel {
  display: flex;
}

/* Panel header with user info */
.user-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 8px;
}

.user-panel-pill {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1d4ed8, #0ea5a4);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.user-panel-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.user-panel-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-panel-email {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-panel-role {
  display: inline-block;
  margin-top: 2px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(29, 78, 216, 0.1);
  color: #1d4ed8;
  line-height: 1.4;
  width: fit-content;
}

.user-panel-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 6px;
}

/* Panel menu items */
.user-menu-panel .action-menu-item {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
  font-family: inherit;
}

.user-menu-panel .action-menu-item:hover {
  background: rgba(15, 23, 42, 0.06);
}

.user-menu-panel .action-menu-item svg {
  flex-shrink: 0;
  opacity: 0.55;
}

.action-menu-item--danger {
  color: #dc2626 !important;
}

.action-menu-item--danger:hover {
  background: rgba(239, 68, 68, 0.08) !important;
}

.action-menu-item--danger svg {
  opacity: 0.7 !important;
}

.user-menu-status {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #b45309;
  padding: 6px 10px 2px;
}


/* ── Activity timeline ───────────────────────────────────────── */
.activity-timeline {
  padding: 4px 0 8px;
}
.tl-item {
  display: flex;
  gap: 12px;
  position: relative;
  min-height: 48px;
}
.tl-line {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  width: 28px;
}
.tl-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  z-index: 1;
}
.tl-dot svg {
  width: 14px;
  height: 14px;
}
.tl-item:not(.tl-item--last) .tl-line::after {
  content: '';
  flex: 1;
  width: 2px;
  background: var(--border);
  margin: 4px 0;
}
.tl-content {
  padding-bottom: 16px;
  flex: 1;
  min-width: 0;
}
.tl-item--last .tl-content {
  padding-bottom: 4px;
}
.tl-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
  line-height: 28px;
}
.tl-detail {
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
  word-break: break-all;
}
.tl-date {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  opacity: 0.7;
}
/* Timeline dot color variants */
.tl-blue     { background: rgba(59, 130, 246, 0.15); color: #2563eb; }
.tl-slate    { background: rgba(100, 116, 139, 0.15); color: #475569; }
.tl-green    { background: rgba(34, 197, 94, 0.15); color: #16a34a; }
.tl-red      { background: rgba(239, 68, 68, 0.15); color: #dc2626; }
.tl-amber    { background: rgba(245, 158, 11, 0.15); color: #d97706; }
.tl-indigo   { background: rgba(99, 102, 241, 0.15); color: #4f46e5; }
.tl-emerald  { background: rgba(16, 185, 129, 0.15); color: #059669; }

body.theme-dark .tl-blue     { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
body.theme-dark .tl-slate    { background: rgba(148, 163, 184, 0.15); color: #94a3b8; }
body.theme-dark .tl-green    { background: rgba(34, 197, 94, 0.2); color: #4ade80; }
body.theme-dark .tl-red      { background: rgba(239, 68, 68, 0.2); color: #f87171; }
body.theme-dark .tl-amber    { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
body.theme-dark .tl-indigo   { background: rgba(99, 102, 241, 0.2); color: #a5b4fc; }
body.theme-dark .tl-emerald  { background: rgba(16, 185, 129, 0.2); color: #34d399; }

.impersonation-pill {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.18);
  color: #b45309;
  font-size: 12px;
  font-weight: 700;
}

.company-pill {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  font-size: 12px;
  font-weight: 600;
}

.content {
  padding: 28px 28px 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.page-header {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 16px;
}

.page-title h1 {
  margin: 0 0 6px;
  font-family: "Sora", sans-serif;
  font-size: 20px;
}

.page-title .doc-number {
  font-family: "Sora", sans-serif;
  font-size: 18px;
  font-weight: 400;
  margin: 0 0 4px;
  color: var(--ink);
}

.page-title p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.actions .action-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.actions .action-hint {
  font-size: 12px;
  color: var(--muted);
}

.floating-action {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 500;
  margin: 0;
}

.floating-action .btn {
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.25);
}

@media (max-width: 720px) {
  .floating-action {
    right: 16px;
    bottom: 16px;
  }
}

.floating-spacer {
  height: 140px;
  pointer-events: none;
}

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

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-head strong {
  font-family: "Sora", sans-serif;
}

.summary-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.filter-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.table-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px 0 8px;
}

.table-pagination .btn[aria-disabled="true"] {
  opacity: 0.4;
  pointer-events: none;
  cursor: default;
}

.pagination-info {
  font-size: 0.85rem;
  color: var(--color-muted, #888);
}

.pagination-ellipsis {
  display: inline-flex;
  align-items: center;
  padding: 0 2px;
  font-size: 0.85rem;
  color: var(--color-muted, #888);
  user-select: none;
  letter-spacing: 1px;
}

.pagination-perpage {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.ui-input.sm {
  padding: 4px 8px;
  font-size: 0.85rem;
}

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

.quick-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.quick-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(15, 23, 42, 0.08);
}

.btn.primary .quick-count {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.quick-clear-all {
  width: 32px;
  height: 32px;
  padding: 0;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}


.header-qr {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  align-self: start;
}

.header-qr .qr-frame {
  padding: 4px;
  border-radius: 10px;
}

.header-qr .qr-img {
  max-width: 90px;
  max-height: 90px;
}

.header-qr .qr-link {
  font-size: 12px;
  color: #1d4ed8;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.header-qr .qr-link svg {
  width: 14px;
  height: 14px;
}

.header-qr .qr-link:hover {
  text-decoration: none;
  background: rgba(59, 130, 246, 0.18);
  border-color: rgba(59, 130, 246, 0.5);
  box-shadow: 0 6px 14px rgba(59, 130, 246, 0.18);
  transform: translateY(-1px);
}

.filters {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
  margin-bottom: 14px;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.filters.is-hidden {
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
  height: 0;
  margin: 0;
}

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

.grid-customer-id {
  grid-template-columns: minmax(280px, 2.8fr) minmax(200px, 1.3fr) minmax(200px, 1.3fr) minmax(48px, 0.4fr);
}

.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid-4 .span-3 {
  grid-column: span 3;
}

.grid-product {
  grid-template-columns: minmax(80px, 0.6fr) minmax(280px, 2.8fr) minmax(150px, 1.1fr) minmax(150px, 1fr);
}

.tax-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  margin-top: 6px;
}

.tax-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.tax-item input {
  margin: 0;
}

.tax-item.is-disabled {
  opacity: 0.6;
}

.tax-preview {
  margin-top: 12px;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  display: grid;
  gap: 8px;
}

.tax-preview-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.tax-preview-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.tax-preview-row strong {
  font-size: 14px;
}

.tax-preview-row.total {
  border-top: 1px solid var(--border);
  padding-top: 6px;
  margin-top: 2px;
}

.tax-preview-note {
  font-size: 12px;
  color: var(--muted);
}

.section-title {
  margin: 18px 0 8px;
  font-family: "Sora", sans-serif;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

.span-3 {
  grid-column: span 3;
}

.span-4 {
  grid-column: span 4;
}

.span-6 {
  grid-column: span 6;
}

.span-12 {
  grid-column: span 12;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.field input,
.field select {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface-2);
  color: var(--ink);
}

select.ui-input {
  font-family: inherit;
  color: var(--ink);
  -webkit-appearance: none;
  appearance: none;
  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 d='M2 4l4 4 4-4' fill='none' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.field input::placeholder,
.field select::placeholder,
.ui-input::placeholder {
  color: var(--muted);
}

.field input:focus,
.field select:focus {
  outline: 2px solid rgba(29, 78, 216, 0.25);
  border-color: rgba(29, 78, 216, 0.5);
}

.field.actions {
  align-items: flex-end;
  flex-direction: row;
  gap: 8px;
}

.ui-input {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 10px 12px;
  font-size: 14px;
  background: var(--surface-2);
  color: var(--ink);
}

.ui-input:focus {
  outline: 2px solid rgba(29, 78, 216, 0.25);
  border-color: rgba(29, 78, 216, 0.5);
}

.ui-input.readonly {
  background: #f1f5f9;
  color: #64748b;
  border-color: #e2e8f0;
  cursor: not-allowed;
}

body.theme-dark .ui-input.readonly {
  background: #0b1220;
  color: #94a3b8;
  border-color: #1f2937;
}

.ui-input.no-spin::-webkit-outer-spin-button,
.ui-input.no-spin::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.ui-input.no-spin {
  -moz-appearance: textfield;
}

.input-prefix {
  position: relative;
}

.input-prefix .prefix {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-weight: 600;
  pointer-events: none;
}

.input-prefix .ui-input {
  padding-left: 26px;
}

.no-spin::-webkit-outer-spin-button,
.no-spin::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.no-spin {
  -moz-appearance: textfield;
}
.input-dv {
  width: 100%;
  max-width: 48px;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.btn.primary {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  color: white;
  box-shadow: 0 10px 20px rgba(29, 78, 216, 0.18);
}

.btn.info {
  background: linear-gradient(135deg, var(--info), var(--primary-700));
  color: white;
  box-shadow: 0 10px 18px rgba(59, 130, 246, 0.2);
}

.btn.ghost {
  background: rgba(15, 23, 42, 0.06);
  color: var(--ink);
}

.btn.dark {
  background: #0f172a;
  color: white;
}

.btn.danger {
  background: #dc2626;
  color: white;
  box-shadow: 0 10px 18px rgba(220, 38, 38, 0.2);
}

.btn.delete {
  background: #f97316;
  color: white;
  box-shadow: 0 10px 18px rgba(249, 115, 22, 0.2);
}

.btn.success {
  background: #16a34a;
  color: white;
  box-shadow: 0 10px 18px rgba(22, 163, 74, 0.2);
}

.btn.sm {
  padding: 8px 12px;
  font-size: 12px;
}

.btn-consultar {
  width: 120px;
  height: 32px;
  padding: 0 12px;
  justify-content: center;
}

.btn.xs {
  padding: 6px 10px;
  font-size: 12px;
}

.btn .btn-content {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

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

.btn.sm .btn-icon,
.btn.xs .btn-icon {
  width: 12px;
  height: 12px;
}

.radio-group {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.radio-group label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--ink);
}

.btn-segment {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  background: rgba(15, 23, 42, 0.06);
  border-radius: 999px;
}

.btn-segment .btn {
  padding: 8px 14px;
  border-radius: 999px;
  box-shadow: none;
  transform: none;
}

.btn-segment .btn:hover {
  transform: none;
}

.btn-segment .btn.ghost {
  background: transparent;
}

.btn-segment .btn.primary {
  box-shadow: none;
}

.btn-segment {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  background: rgba(15, 23, 42, 0.06);
  border-radius: 999px;
}

.btn-segment .btn {
  padding: 8px 14px;
  border-radius: 999px;
  box-shadow: none;
  transform: none;
}

.btn-segment .btn:hover {
  transform: none;
}

.btn-segment .btn.ghost {
  background: transparent;
}

.btn-segment .btn.primary {
  box-shadow: none;
}

.btn-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  margin-left: 6px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.btn-count.mail {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  margin-left: 8px;
  background: #2563eb;
  color: #ffffff;
  border: none;
  box-shadow: 0 6px 12px rgba(37, 99, 235, 0.25);
}

.btn[disabled] .btn-count.mail,
.btn.disabled .btn-count.mail {
  background: #94a3b8;
  box-shadow: none;
}

.btn.delete-square {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
  background: #ef4444;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}

.btn.delete-square:hover {
  background: #dc2626;
}

.btn.add-square {
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 10px;
  background: #1d4ed8;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

.btn.add-square:hover {
  background: #1e40af;
}

.index-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-weight: 600;
}

.line-index {
  padding-right: 18px;
}

#lines-table th:nth-child(2),
#lines-table td:nth-child(2) {
  padding-left: 12px;
}

.btn.disabled,
.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 9999;
}

.popup-card {
  width: min(420px, 90vw);
  background: var(--surface);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.popup-card.wide {
  width: min(820px, 94vw);
}

.preview-modal {
  max-height: 88vh;
}

.preview-body {
  display: grid;
  gap: 16px;
  overflow: auto;
  padding-right: 4px;
}

.preview-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.preview-block {
  display: grid;
  gap: 8px;
}

.preview-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.preview-meta {
  display: grid;
  gap: 4px;
  color: var(--ink);
}

.preview-table-wrap {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-2);
}

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

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

.preview-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  background: rgba(15, 23, 42, 0.04);
}

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

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

.preview-summary {
  display: grid;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: var(--surface-2);
}

.preview-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.preview-summary-row.total {
  font-weight: 700;
  font-size: 14px;
}

.preview-error-list {
  margin: 0;
  padding-left: 18px;
  color: #991b1b;
  display: grid;
  gap: 6px;
}

.popup-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.popup-message {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.popup-details {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--ink);
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  margin: 0;
}

.popup-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.popup-actions form {
  margin: 0;
}

/* toggle sidebar se maneja con .sb-toggle en el topbar */

.table-wrap {
  overflow: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.table-wrap.items-wrap {
  border: 0;
  border-radius: 0;
  overflow: visible;
}

.data-table {
  width: 100%;
  min-width: 1200px;
  border-collapse: collapse;
  background: var(--surface);
}

.data-table.compact {
  min-width: 0;
}

.data-table.invoices-table {
  min-width: 0;
  table-layout: fixed;
}

.data-table.invoices-table td:last-child {
  overflow: visible;
}

.data-table.items-compact {
  table-layout: fixed;
}

.data-table.items-compact th:last-child,
.data-table.items-compact td:last-child {
  padding-right: 12px;
}

.data-table.invoices-table th:nth-child(1),
.data-table.invoices-table td:nth-child(1) {
  width: 70px;
  padding-left: 12px;
  padding-right: 40px;
  text-align: right;
}

.data-table.invoices-table th:nth-child(2),
.data-table.invoices-table td:nth-child(2) {
  width: 90px;
}

.data-table.invoices-table th:nth-child(3),
.data-table.invoices-table td:nth-child(3) {
  width: 100px;
}

.data-table.invoices-table th:nth-child(4),
.data-table.invoices-table td:nth-child(4) {
  width: 110px;
}

.data-table.invoices-table th:nth-child(5),
.data-table.invoices-table td:nth-child(5) {
  width: 100px;
}

.data-table.invoices-table th:nth-child(6),
.data-table.invoices-table td:nth-child(6) {
  width: 90px;
}

.data-table.invoices-table th:nth-child(7),
.data-table.invoices-table td:nth-child(7) {
  width: 90px;
}

.data-table.invoices-table th:nth-child(8),
.data-table.invoices-table td:nth-child(8) {
  width: 90px;
}

.data-table.invoices-table th:nth-child(9),
.data-table.invoices-table td:nth-child(9) {
  width: 100px;
}

.data-table.invoices-table th:nth-child(10),
.data-table.invoices-table td:nth-child(10) {
  width: 100px;
}

.data-table.invoices-table th:nth-child(11),
.data-table.invoices-table td:nth-child(11) {
  width: 90px;
}

.data-table.invoices-table .cell-meta {
  min-width: 0;
}

.data-table.invoices-table .cell-meta strong,
.data-table.invoices-table .cell-meta small {
  display: block;
  width: 100%;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-table.customers-table {
  table-layout: fixed;
  min-width: 0;
}

.data-table.customers-table th:nth-child(1),
.data-table.customers-table td:nth-child(1) {
  width: 36px;
  padding-left: 12px;
}

.data-table.customers-table th:nth-child(2),
.data-table.customers-table td:nth-child(2) {
  width: 120px;
}

.data-table.customers-table th:nth-child(3),
.data-table.customers-table td:nth-child(3) {
  width: 80px;
}

.data-table.customers-table th:nth-child(4),
.data-table.customers-table td:nth-child(4) {
  width: 110px;
}

.data-table.customers-table th:nth-child(5),
.data-table.customers-table td:nth-child(5) {
  width: 60px;
}

.data-table.customers-table th:nth-child(6),
.data-table.customers-table td:nth-child(6) {
  width: 60px;
}

.data-table.customers-table th:nth-child(7),
.data-table.customers-table td:nth-child(7) {
  width: 80px;
}

.invoice-summary {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
}

.summary-panel {
  min-width: 320px;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.summary-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.summary-label {
  flex: 1;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--ink);
}

.summary-sep {
  color: var(--muted);
}

.summary-value {
  min-width: 140px;
  text-align: right;
  font-weight: 600;
}

.summary-discount {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 10px;
  align-items: center;
}

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

.mode-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.mode-label.active {
  color: var(--ink);
}

.summary-input {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.summary-input .ui-input {
  padding-right: 28px;
  padding-left: 28px;
  text-align: right;
  min-width: 90px;
}

.summary-input .prefix {
  position: absolute;
  left: 10px;
  color: var(--muted);
  font-weight: 600;
  pointer-events: none;
}

.summary-input.input-prefix {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 0;
}

.summary-input.input-prefix .ui-input {
  border: none;
  background: transparent;
  padding-right: 28px;
  padding-left: 28px;
  min-width: 120px;
}

.summary-input.input-prefix .suffix {
  right: 10px;
}

.summary-input .suffix {
  position: absolute;
  right: 10px;
  color: var(--muted);
  font-weight: 600;
  pointer-events: none;
}

.summary-total {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.summary-total .summary-label {
  font-size: 22px;
  font-weight: 700;
}

.summary-total .summary-value {
  font-size: 26px;
  font-weight: 800;
}

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch .slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #cbd5f5;
  border-radius: 999px;
  transition: 0.2s ease;
}

.switch .slider::before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  top: 3px;
  background: #ffffff;
  border-radius: 999px;
  transition: 0.2s ease;
}

.switch input:checked + .slider {
  background: #0f172a;
}

.switch input:checked + .slider::before {
  transform: translateX(20px);
}

.data-table thead {
  background: var(--surface-2);
}

.data-table th,
.data-table td {
  padding: 7px 4px;
  text-align: left;
  font-size: 11px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.data-table th:first-child,
.data-table td:first-child {
  padding-left: 12px;
}

.data-table tbody tr {
  animation: fadeInUp 0.5s ease both;
  animation-delay: calc(var(--i) * 0.03s);
  position: relative;
  z-index: 0;
}

.data-table tbody tr.menu-open {
  z-index: 8;
}

.data-table tbody tr:hover {
  background: rgba(29, 78, 216, 0.04);
}

.data-table.items-table {
  min-width: 0;
}

.data-table.items-table thead {
  background: transparent;
}

.data-table.items-table th,
.data-table.items-table td {
  padding: 12px 8px;
  font-size: 13px;
}

.data-table.items-table th {
  color: var(--muted);
  font-weight: 600;
}

.data-table.items-table tbody tr:hover {
  background: transparent;
}

.item-index {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.item-desc {
  font-weight: 600;
  color: var(--ink);
}

.item-tax {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(15, 23, 42, 0.08);
  color: var(--ink);
}

.badge-fixed {
  height: 23px;
  padding: 0 8px;
  white-space: nowrap;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-fixed.status-width {
  width: 100px;
}

.badge-fixed.note-width {
  width: 46px;
}

.badge-row .badge.note-width:only-child {
  width: 100px;
}

.badge-fixed.dian-width {
  width: 80px;
  height: 23px;
}

.badge-fixed.dian-detail {
  height: 32px;
}

.invoices-table .badge {
  padding: 2px 6px;
  font-size: 9px;
}

.invoices-table .badge-fixed {
  height: 16px;
  padding: 0 5px;
}

.invoices-table .badge-fixed.status-width {
  width: 70px;
}

.invoices-table .badge-fixed.note-width {
  width: 32px;
}

.invoices-table .badge-row .badge.note-width:only-child {
  width: 70px;
}

.invoices-table .badge-fixed.dian-width {
  width: 60px;
  height: 16px;
}

.doc-badge-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.item-count-badge {
  height: 16px;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(14, 165, 164, 0.16);
  color: #0f766e;
  font-size: 9px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
}

.badge-click {
  cursor: pointer;
}

.badge-click:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.35);
  outline-offset: 2px;
}

.badge.status-draft {
  background: rgba(245, 158, 11, 0.15);
  color: #92400e;
}

.badge.status-generated,
.badge.status-sent {
  background: rgba(59, 130, 246, 0.15);
  color: #1d4ed8;
}

.badge.status-partial {
  background: rgba(245, 158, 11, 0.18);
  color: #b45309;
}

.badge.status-paid,
.badge.status-accepted {
  background: rgba(34, 197, 94, 0.18);
  color: #15803d;
}

.badge.status-debit {
  background: rgba(14, 116, 144, 0.18);
  color: #0e7490;
}

.badge.status-adjust {
  background: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
}

.badge.status-rejected {
  background: rgba(239, 68, 68, 0.16);
  color: #b91c1c;
}

.badge.status-cancelled {
  background: rgba(239, 68, 68, 0.16);
  color: #b91c1c;
}

.badge.status-active {
  background: rgba(34, 197, 94, 0.18);
  color: #15803d;
}

.badge.status-inactive {
  background: rgba(148, 163, 184, 0.25);
  color: #475569;
}

.badge.status-user {
  background: rgba(148, 163, 184, 0.2);
  color: #64748b;
  font-size: 10px;
  padding: 1px 5px;
  height: 14px;
  width: auto;
  min-width: 0;
}

.password-rules {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.password-rule {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.password-rule .rule-indicator {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  position: relative;
  flex-shrink: 0;
}

.password-rule.is-ok {
  color: #15803d;
}

.password-rule.is-ok .rule-indicator {
  border-color: rgba(34, 197, 94, 0.5);
  background: rgba(34, 197, 94, 0.16);
}

.password-rule.is-ok .rule-indicator::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 2px;
  width: 5px;
  height: 9px;
  border: solid #15803d;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.password-match {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.password-match .match-indicator {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}

.password-match.is-match {
  color: #15803d;
}

.password-match.is-match .match-indicator {
  border-color: rgba(34, 197, 94, 0.6);
  background: rgba(34, 197, 94, 0.18);
}

.password-match.is-mismatch {
  color: #b91c1c;
}

.password-match.is-mismatch .match-indicator {
  border-color: rgba(239, 68, 68, 0.7);
  background: rgba(239, 68, 68, 0.16);
}

.input-password {
  position: relative;
}

.input-password .ui-input {
  padding-right: 46px;
}

.password-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  transition: transform 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
}

.password-toggle:hover {
  transform: translateY(-50%) translateY(-1px);
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.12);
  color: var(--ink);
}

.password-toggle svg {
  width: 16px;
  height: 16px;
}

.password-toggle .eye-slash {
  display: none;
}

.password-toggle.is-visible .eye-slash {
  display: block;
}

.cell-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cell-meta small {
  color: var(--muted);
  font-size: 11px;
}

.badge-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cell-center {
  align-items: center;
  text-align: center;
  width: 100%;
}

.cell-center .badge-row {
  justify-content: center;
  width: 100%;
}

.status-cell {
  text-align: center;
}

.status-cell .cell-meta {
  align-items: center;
  width: 100%;
}

.status-cell .badge-row {
  justify-content: center;
  width: 100%;
}

.table-actions {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  align-items: center;
  white-space: nowrap;
  overflow: visible;
}

.table-actions form {
  margin: 0;
}

.icon-action {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  padding: 0;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.icon-action svg {
  width: 16px;
  height: 16px;
}

.icon-action:hover {
  transform: translateY(-1px);
  border-color: rgba(15, 23, 42, 0.2);
  box-shadow: 0 6px 12px rgba(15, 23, 42, 0.08);
}

.icon-action.info {
  background: rgba(59, 130, 246, 0.12);
  color: #1d4ed8;
  border-color: rgba(59, 130, 246, 0.35);
}

.icon-action.success {
  background: rgba(34, 197, 94, 0.14);
  color: #15803d;
  border-color: rgba(34, 197, 94, 0.35);
}

.icon-action.danger {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
  border-color: rgba(239, 68, 68, 0.35);
}

.icon-action.accent {
  background: rgba(14, 165, 164, 0.14);
  color: #0f766e;
  border-color: rgba(14, 165, 164, 0.35);
}

.icon-action.warning {
  background: rgba(245, 158, 11, 0.16);
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.4);
}

.icon-action.disabled,
.icon-action[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  pointer-events: none;
}

.action-menu {
  position: relative;
}

.action-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 120px;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18);
  padding: 8px;
  display: none;
  flex-direction: column;
  gap: 4px;
  z-index: 200;
  white-space: nowrap;
}

.action-menu.is-open .action-menu-panel {
  display: flex;
}

.action-menu-item {
  padding: 9px 10px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  transition: background 0.2s ease;
}

.action-menu-item:hover {
  background: rgba(15, 23, 42, 0.06);
}

.permission-grid {
  display: grid;
  gap: 16px;
  margin-top: 8px;
}

.permission-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.permission-group {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: var(--surface-2);
}

.permission-title {
  font-weight: 700;
  margin-bottom: 8px;
}

.permission-grid.compact .permission-group {
  padding: 10px;
}

.permission-grid.compact .permission-title {
  margin-bottom: 6px;
  font-size: 13px;
}

.permission-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  transition: background 0.2s ease;
}

.permission-grid.compact .permission-item {
  padding: 6px 8px;
  border-radius: 8px;
}

.permission-item:hover {
  background: rgba(15, 23, 42, 0.04);
}

.permission-left {
  display: inline-flex;
  align-items: flex-start;
  gap: 10px;
}

.permission-label {
  font-weight: 600;
  display: block;
}

.permission-grid.compact .permission-label {
  font-size: 12px;
}

.permission-desc {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.permission-grid.compact .permission-desc {
  display: none;
}

.permission-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  background: rgba(15, 23, 42, 0.08);
  padding: 4px 8px;
  border-radius: 999px;
}

.permission-badge.is-override {
  color: #1d4ed8;
  background: rgba(37, 99, 235, 0.12);
}

.permission-badge.is-allow {
  color: #15803d;
  background: rgba(34, 197, 94, 0.18);
}

.permission-badge.is-deny {
  color: #475569;
  background: rgba(148, 163, 184, 0.25);
}

.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-row .ui-input {
  flex: 1;
}

.search-modal {
  gap: 14px;
}

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

.search-list {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 12px;
  max-height: min(420px, 60vh);
  overflow: auto;
  padding: 6px;
  display: grid;
  gap: 4px;
}

.search-item {
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
}

.search-item:hover {
  background: rgba(15, 23, 42, 0.06);
}

.search-item.is-selected {
  background: rgba(29, 78, 216, 0.12);
  border: 1px solid rgba(29, 78, 216, 0.25);
}

.search-empty {
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
}

.doc-type-field {
  min-width: 80px;
  max-width: 80px;
}

.doc-number-field {
  min-width: 140px;
  max-width: 140px;
}

.grid.invoice-head {
  grid-template-columns: minmax(260px, 2.4fr) 80px 140px minmax(240px, 1.6fr) minmax(240px, 1.6fr);
  align-items: start;
}

@media (max-width: 1100px) {
  .grid.invoice-head {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }
}

.doc-type-field label,
.doc-number-field label {
  white-space: nowrap;
}

.qr-frame {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.qr-img {
  display: block;
  image-rendering: pixelated;
  width: auto;
  height: auto;
  max-width: 640px;
  max-height: 640px;
}

.icon-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #1d4ed8;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  border: 2px solid var(--surface);
}

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  margin-bottom: 12px;
}

.alert.error {
  background: #fee2e2;
  border-color: #fecaca;
  color: #991b1b;
}

.alert.info {
  background: #e0f2fe;
  border-color: #bae6fd;
  color: #1e3a8a;
}

.alert.success {
  background: #dcfce7;
  border-color: #bbf7d0;
  color: #166534;
}

.alert.warning {
  background: #fef3c7;
  border-color: #fde68a;
  color: #92400e;
}

.alert ul {
  margin: 0;
  padding-left: 18px;
}

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: min(460px, 100%);
}

.auth-card.wide {
  width: min(720px, 100%);
}

.auth-card .card-head {
  justify-content: center;
}

.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.form-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}

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

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 10;
}

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

@media (max-width: 1100px) {
  .filters {
    grid-template-columns: repeat(6, 1fr);
  }

  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-4 .span-3 {
    grid-column: span 2;
  }

  .grid-product {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas: "main";
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 280px;
    height: 100vh;
    border-radius: 0 16px 16px 0;
    transform: translateX(-100%);
    z-index: 20;
    transition: transform 0.3s ease;
  }

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

  body.sidebar-open .overlay {
    display: block;
  }

  /* En móvil no colapsar, siempre modo expandido con slide */
  body.sidebar-collapsed .sidebar {
    width: 280px;
  }
  body.sidebar-collapsed .sb-brand-name,
  body.sidebar-collapsed .sb-logo,
  body.sidebar-collapsed .sb-label,
  body.sidebar-collapsed .sb-chevron,
  body.sidebar-collapsed .sb-arrow {
    display: unset;
  }
  body.sidebar-collapsed .sb-header {
    padding: 18px 14px 14px;
  }
  body.sidebar-collapsed .nav {
    padding: 6px 12px;
    align-items: stretch;
  }
  body.sidebar-collapsed .sb-item {
    justify-content: flex-start;
    width: 100%;
    padding: 12px 14px;
  }
  body.sidebar-collapsed .sb-sub {
    display: none !important;
  }
  body.sidebar-collapsed .sb-group.is-open > .sb-sub {
    display: flex !important;
  }
  body.sidebar-collapsed .sb-footer {
    padding: 8px 12px 14px;
    align-items: stretch;
  }
  body.sidebar-collapsed .sb-footer .sb-item {
    width: 100%;
  }

  .topbar {
    padding: 18px 20px;
  }

  .content {
    padding: 20px 20px 28px;
  }

}

@media (max-width: 720px) {
  .filters {
    grid-template-columns: repeat(2, 1fr);
  }

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

  .grid-4 .span-3 {
    grid-column: span 1;
  }

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

  .field.actions {
    grid-column: span 2;
    justify-content: flex-start;
  }

  .page-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-right {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* Customer profile card */
.customer-profile-card {
  overflow: hidden;
}

.customer-two-col {
  display: flex;
  align-items: stretch;
  gap: 0;
}

.customer-col-left {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-right: 24px;
  margin-right: 24px;
  border-right: 1px solid var(--border);
  flex: 0 0 45%;
}

.customer-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-700));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Sora", sans-serif;
  font-size: 19px;
  font-weight: 700;
  flex-shrink: 0;
}

.customer-identity {
  min-width: 0;
}

.customer-profile-name {
  font-family: "Sora", sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.customer-profile-doc {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.customer-col-right {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  min-width: 0;
}

.customer-contact-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink);
}

.customer-contact-row svg {
  color: var(--muted);
  flex-shrink: 0;
}

/* Document hero section */
.doc-hero {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}

.doc-hero-number {
  font-family: "Sora", sans-serif;
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.doc-hero-type {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.doc-hero-date {
  font-size: 13px;
  color: var(--muted);
  margin-left: auto;
}

.doc-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.doc-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 12px;
  line-height: 1.4;
}

.doc-pill-label {
  font-weight: 600;
  color: var(--muted);
}

.doc-pill-value {
  color: var(--ink);
}

a.doc-pill-value {
  color: var(--primary);
  text-decoration: none;
}

a.doc-pill-value:hover {
  text-decoration: underline;
}

.doc-cufe-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 11px;
}

.doc-cufe-label {
  font-weight: 700;
  color: var(--muted);
  flex-shrink: 0;
}

.doc-cufe-value {
  color: var(--muted);
  word-break: break-all;
  line-height: 1.4;
}

/* ── Doc Timeline Card ── */
.doc-timeline-card {
  display: flex;
  gap: 0;
  padding: 0 !important;
  overflow: hidden;
}

.doc-timeline-rail {
  width: 56px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 0;
  position: relative;
  background: var(--surface-2);
}

.doc-timeline-rail::after {
  content: "";
  position: absolute;
  top: 60px;
  bottom: 24px;
  width: 2px;
  background: var(--border);
}

.doc-timeline-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

.doc-timeline-dot svg {
  width: 16px;
  height: 16px;
}

.doc-timeline-dot.dot-accepted {
  background: #dcfce7;
  color: #16a34a;
}

.doc-timeline-dot.dot-rejected {
  background: #fde2e2;
  color: #dc2626;
}

.doc-timeline-dot.dot-pending {
  background: #fef3c7;
  color: #d97706;
}

.doc-timeline-dot.dot-default {
  background: var(--bg);
  color: var(--muted);
}

.doc-timeline-body {
  flex: 1;
  padding: 24px 24px 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.doc-timeline-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.doc-timeline-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.doc-timeline-number-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.doc-timeline-number-row .badge {
  position: relative;
  top: -1px;
}

.doc-timeline-number {
  font-family: "Sora", sans-serif;
  font-size: 24px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.doc-timeline-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.doc-timeline-sub .sep {
  color: var(--border);
}

.doc-timeline-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.doc-timeline-badges .btn.sm {
  height: 32px;
  padding: 0 12px;
}

.doc-timeline-badges .badge-fixed {
  height: 32px;
}

.btn.icon-only {
  padding: 0 10px;
}

.btn.icon-only svg,
.badge.icon-only svg {
  width: 16px;
  height: 16px;
}

.doc-timeline-badges .badge.icon-only {
  width: 36px;
  padding: 0;
}

.doc-timeline-meta {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.doc-timeline-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.doc-timeline-field-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.doc-timeline-field-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

a.doc-timeline-field-value {
  color: var(--primary);
  text-decoration: none;
}

a.doc-timeline-field-value:hover {
  text-decoration: underline;
}

.doc-timeline-cufe {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 11px;
}

.doc-timeline-cufe-label {
  font-weight: 700;
  color: var(--muted);
  flex-shrink: 0;
}

.doc-timeline-cufe-value {
  color: var(--muted);
  word-break: break-all;
  line-height: 1.4;
}

.btn-fixed-save {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
}

@media (max-width: 720px) {
  .btn-fixed-save {
    right: 16px;
    bottom: 16px;
  }
}

@media (max-width: 600px) {
  .doc-timeline-rail {
    width: 40px;
  }
  .doc-timeline-body {
    padding: 20px 16px 20px 12px;
  }
  .doc-timeline-header {
    flex-direction: column;
  }
  .doc-timeline-number {
    font-size: 20px;
  }
  .doc-timeline-meta {
    gap: 14px;
  }
}
