/* ==========================================================================
   Bashy3D Facturación - Premium Dark Emerald & Pink Theme (v4)
   Matching https://bashy3d.work
   ========================================================================== */

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Official Bashy3D Palette */
  --bg: #0e1412;
  --bg-2: #131917;
  --bg-panel: rgba(255, 255, 255, 0.04);
  --bg-panel-hover: rgba(255, 255, 255, 0.07);
  --bg-input: rgba(255, 255, 255, 0.06);

  --text-main: #f3f5f4;
  --text-muted: #9eb0a7;
  --text-dim: #6b7c74;

  /* Accents */
  --green: #1a8060;
  --green-hover: #229973;
  --green-light: #8fcca3;
  --green-glow: rgba(26, 128, 96, 0.35);

  --pink: #e85d9e;
  --pink-hover: #f06ca9;
  --pink-light: #ff99bf;
  --pink-glow: rgba(232, 93, 158, 0.3);

  --blue: #38bdf8;
  --amber: #fbbf24;
  --rose: #f43f5e;

  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.15);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);
  --shadow-paper: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background:
    radial-gradient(circle at 15% 10%, rgba(76, 217, 100, 0.08), transparent 32%),
    radial-gradient(circle at 85% 15%, rgba(232, 93, 158, 0.08), transparent 28%),
    linear-gradient(180deg, #0e1412 0%, #0a0e0d 100%);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

.font-mono {
  font-family: var(--font-mono);
}

/* ==========================================================================
   DEFAULT VISIBILITY: MOBILE ELEMENTS STRICTLY HIDDEN ON DESKTOP
   ========================================================================== */
.mobile-top-header {
  display: none !important;
}

.mobile-bottom-nav {
  display: none !important;
}

.mobile-modal-tabs {
  display: none !important;
}

/* Layout */
.app-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* Sidebar */
.sidebar {
  width: 270px;
  background: rgba(19, 25, 23, 0.95);
  backdrop-filter: blur(14px);
  color: var(--text-main);
  display: flex !important;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid var(--line);
  padding: 24px 16px;
  gap: 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 6px 16px 6px;
  border-bottom: 1px solid var(--line);
}

.brand-logo-wrap {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  box-shadow: 0 4px 12px rgba(26, 128, 96, 0.25);
}

.brand-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-info {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
}

.brand-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--green-light);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
  position: relative;
}

.nav-item:hover {
  background: var(--bg-panel-hover);
  color: var(--text-main);
  border-color: var(--line);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(26, 128, 96, 0.25), rgba(26, 128, 96, 0.15));
  color: var(--green-light);
  border-color: rgba(26, 128, 96, 0.4);
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(26, 128, 96, 0.15);
}

.nav-item.active svg {
  stroke: var(--green-light);
}

.badge-count {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.1);
  color: var(--green-light);
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

/* Sidebar Sync Widget */
.sidebar-sync-widget {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sync-status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green-light);
  box-shadow: 0 0 10px var(--green-light);
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.sync-dot.syncing {
  background: var(--blue);
  box-shadow: 0 0 10px var(--blue);
  animation: pulseSync 1s infinite alternate;
}

.sync-dot.local {
  background: var(--text-dim);
  box-shadow: none;
}

.btn-sync-action {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  transition: transform 0.2s, color 0.2s;
  padding: 2px 4px;
}

.btn-sync-action:hover {
  color: #fff;
  transform: rotate(45deg);
}

@keyframes pulseSync {
  from { opacity: 0.4; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1.2); }
}

/* Sidebar Exchange Rate Widget */
.sidebar-exchange-widget {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

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

.widget-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.btn-icon-subtle {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 13px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.btn-icon-subtle:hover {
  opacity: 1;
}

.exchange-rate-display {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
}

.fx-pair {
  color: var(--text-muted);
}

.fx-input {
  width: 75px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  color: var(--pink-light);
  font-family: var(--font-mono);
  font-weight: 700;
  padding: 2px 6px;
  text-align: center;
}

.fx-curr {
  color: var(--pink-light);
  font-weight: 700;
}

.widget-footer {
  margin-top: 6px;
}

.fx-note {
  font-size: 10px;
  color: var(--text-dim);
}

/* Sidebar User Info */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 10px;
  background: var(--bg-panel);
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--green), #135d45);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
}

.user-details {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-name {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.user-nif {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Main Content Area */
.main-content {
  flex: 1;
  padding: 36px 48px;
  max-width: 1500px;
  overflow-x: hidden;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

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

/* Header */
.content-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 26px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.03em;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}

.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  white-space: nowrap;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-primary {
  background-color: var(--green);
  color: #fff;
  box-shadow: 0 4px 14px rgba(26, 128, 96, 0.35);
}

.btn-primary:hover {
  background-color: var(--green-hover);
  box-shadow: 0 6px 20px rgba(26, 128, 96, 0.45);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--bg-panel);
  border-color: var(--line);
  color: var(--text-main);
}

.btn-secondary:hover {
  background-color: var(--bg-panel-hover);
  border-color: var(--line-strong);
}

.btn-dashed {
  width: 100%;
  border: 1.5px dashed rgba(26, 128, 96, 0.5);
  background: rgba(26, 128, 96, 0.05);
  color: var(--green-light);
  font-weight: 600;
  padding: 12px;
  margin-top: 10px;
  border-radius: var(--radius-md);
}

.btn-dashed:hover {
  border-color: var(--green-light);
  background: rgba(26, 128, 96, 0.12);
}

.btn-danger-ghost {
  background: transparent;
  border: none;
  color: var(--rose);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}

.btn-danger-ghost:hover {
  background: rgba(244, 63, 94, 0.15);
}

/* Metrics Cards Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.metric-card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  gap: 16px;
  align-items: center;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
}

.metric-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.metric-icon-green { background: rgba(26, 128, 96, 0.18); color: var(--green-light); border: 1px solid rgba(26, 128, 96, 0.3); }
.metric-icon-blue { background: rgba(56, 189, 248, 0.15); color: var(--blue); border: 1px solid rgba(56, 189, 248, 0.25); }
.metric-icon-pink { background: rgba(232, 93, 158, 0.15); color: var(--pink-light); border: 1px solid rgba(232, 93, 158, 0.3); }
.metric-icon-amber { background: rgba(251, 191, 36, 0.15); color: var(--amber); border: 1px solid rgba(251, 191, 36, 0.25); }

.metric-content {
  display: flex;
  flex-direction: column;
}

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

.metric-value {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.02em;
  margin-top: 2px;
}

.metric-sub {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Table and Toolbars */
.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 240px;
}

.search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
}

.search-box input {
  width: 100%;
  padding: 10px 12px 10px 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--bg-panel);
  color: #fff;
  font-size: 13px;
  outline: none;
}

.search-box input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(26, 128, 96, 0.2);
}

.filter-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-select {
  padding: 9px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--bg-2);
  font-size: 13px;
  color: var(--text-main);
  outline: none;
  cursor: pointer;
}

.filter-select:focus {
  border-color: var(--green);
}

.card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.table-card {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  background: rgba(255, 255, 255, 0.02);
  padding: 14px 18px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.data-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  white-space: nowrap;
}

.data-table tbody tr:hover {
  background-color: var(--bg-panel-hover);
}

.text-right {
  text-align: right;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-paid { background: rgba(26, 128, 96, 0.2); color: var(--green-light); border: 1px solid rgba(26, 128, 96, 0.4); }
.badge-sent { background: rgba(56, 189, 248, 0.15); color: var(--blue); border: 1px solid rgba(56, 189, 248, 0.3); }
.badge-draft { background: rgba(255, 255, 255, 0.08); color: var(--text-muted); border: 1px solid var(--line); }
.badge-uk { background: rgba(232, 93, 158, 0.15); color: var(--pink-light); border: 1px solid rgba(232, 93, 158, 0.35); font-weight: 800; }
.badge-es { background: rgba(56, 189, 248, 0.15); color: var(--blue); border: 1px solid rgba(56, 189, 248, 0.3); font-weight: 700; }

.action-buttons {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.btn-icon-action {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-icon-action:hover {
  background: var(--bg-panel-hover);
  border-color: var(--line-strong);
}

/* Empty State */
.empty-state {
  padding: 48px 24px;
  text-align: center;
}

.empty-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}

/* Presets Grid */
.grid-presets, .grid-clients {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.preset-card, .client-card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.preset-card:hover, .client-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(26, 128, 96, 0.4);
}

.preset-card-header, .client-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.preset-title, .client-name {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

.preset-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  flex: 1;
}

.preset-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.preset-price {
  font-size: 17px;
  font-weight: 800;
  color: var(--green-light);
  font-family: var(--font-mono);
}

/* Tax Quarters Grid */
.tax-quarters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.quarter-card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.quarter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.quarter-title {
  font-size: 15px;
  font-weight: 800;
  color: #fff;
}

.quarter-dates {
  font-size: 11px;
  color: var(--text-muted);
}

.tax-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 12px;
}

.tax-row.highlight {
  font-weight: 700;
  color: #fff;
  border-top: 1px dashed var(--line);
  margin-top: 6px;
  padding-top: 8px;
}

.tax-row .val {
  font-family: var(--font-mono);
  font-weight: 600;
}

.tax-info-card {
  padding: 24px;
  background: var(--bg-panel);
}

.tax-info-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.tax-info-header h3 {
  color: #fff;
}

.tax-info-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.tax-info-item p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Forms */
.form-card {
  padding: 28px;
  background: var(--bg-panel);
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-row {
  display: flex;
  gap: 16px;
}

.align-center {
  align-items: center;
}

.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

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

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

.form-group input, 
.form-group textarea {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--bg-input);
  font-size: 13px;
  color: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-height: 42px;
}

.form-group select,
select,
.filter-select,
.quick-preset-selector select {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(143, 204, 163, 0.35);
  background-color: #172d24 !important;
  font-size: 13px;
  font-weight: 500;
  color: #f3f5f4 !important;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-height: 42px;
  cursor: pointer;
}

.form-group input:focus, 
.form-group textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(26, 128, 96, 0.25);
}

.form-group select:focus,
select:focus,
.filter-select:focus,
.quick-preset-selector select:focus {
  border-color: var(--green-light) !important;
  box-shadow: 0 0 0 3px rgba(26, 128, 96, 0.35) !important;
}

/* Dropdown Menu Options (Soft Green Theme Background) */
select option,
.form-group select option,
.filter-select option,
.quick-preset-selector select option {
  background-color: #172d24 !important;
  color: #f3f5f4 !important;
  padding: 10px 14px !important;
  font-size: 13px !important;
  font-weight: 500 !important;
}

select option:checked,
select option:hover,
.form-group select option:checked,
.form-group select option:hover {
  background-color: #1a8060 !important;
  color: #ffffff !important;
}

.divider-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--green-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-top: 16px;
  margin-top: 8px;
  border-top: 1px solid var(--line);
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 13, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-container {
  background: #141b18;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  max-height: 94vh;
  overflow: hidden;
  animation: modalPop 0.2s ease-out;
  color: #fff;
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-medium { width: 580px; max-width: 95vw; }
.modal-large { width: 1380px; max-width: 96vw; height: 92vh; }

.modal-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.02);
  flex-shrink: 0;
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-title-group h2 {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
}

.modal-actions-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-close-modal {
  background: transparent;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.btn-close-modal:hover { color: #fff; }

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: rgba(255, 255, 255, 0.02);
  flex-shrink: 0;
}

/* Split Layout inside Invoice Creator Modal */
.modal-split-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.editor-pane {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: #141b18;
}

.preview-pane {
  flex: 1.15;
  background: #0b0f0e;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.preview-toolbar {
  width: 100%;
  max-width: 680px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.preview-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.preview-tag {
  font-size: 11px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.1);
  color: var(--pink-light);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(232, 93, 158, 0.3);
}

.form-section {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

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

.section-title {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--green-light);
  margin-bottom: 10px;
}

.quick-preset-selector select {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(26, 128, 96, 0.4);
  background: rgba(26, 128, 96, 0.15);
  color: var(--green-light);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  max-width: 220px;
}

/* Market Alerts */
.market-alert {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 12px;
}

.market-alert.uk-mode {
  background: rgba(232, 93, 158, 0.12);
  border: 1px solid rgba(232, 93, 158, 0.3);
  color: var(--pink-light);
}

.market-alert.es-mode {
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: var(--blue);
}

.market-alert p {
  margin-top: 2px;
  opacity: 0.9;
}

/* Invoice Line Items inside Editor */
.invoice-items-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.invoice-item-row {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item-main-grid {
  display: grid;
  grid-template-columns: 2fr 70px 95px 95px 30px;
  gap: 8px;
  align-items: center;
}

.item-desc-input {
  font-size: 13px;
  font-weight: 600;
}

.item-qty-input, .item-price-input {
  text-align: right;
  font-family: var(--font-mono);
}

.item-total-col {
  text-align: right;
}

.item-total-eur {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  font-family: var(--font-mono);
}

.item-total-gbp {
  font-size: 11px;
  font-weight: 600;
  color: var(--pink-light);
  font-family: var(--font-mono);
}

/* ==========================================================================
   A4 INVOICE SHEET (CRISP WHITE PAPER PREVIEW & PRINT)
   ========================================================================== */

.invoice-paper {
  position: relative;
  overflow: hidden;
  width: 100%;
  max-width: 680px;
  background: #ffffff;
  box-shadow: var(--shadow-paper);
  border-radius: 4px;
  padding: 40px;
  color: #0f172a;
  min-height: 850px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: 12px;
}

.invoice-watermark-bg {
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  width: 320px !important;
  height: 320px !important;
  max-width: 60% !important;
  max-height: 45% !important;
  opacity: 0.25 !important;
  filter: grayscale(100%) !important;
  pointer-events: none !important;
  z-index: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.inv-sheet-header,
.inv-parties-grid,
.inv-table,
.inv-summary-section,
.inv-legal-footer {
  position: relative;
  z-index: 1;
}

.inv-sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 30px;
  gap: 16px;
}

.inv-brand-block h1 {
  font-size: 22px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.02em;
}

.inv-brand-block p {
  color: #64748b;
  font-size: 11px;
  margin-top: 2px;
}

.inv-meta-block {
  text-align: right;
}

.inv-type-title {
  font-size: 18px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #1a8060;
}

.inv-meta-table {
  margin-top: 6px;
  margin-left: auto;
  font-size: 11px;
}

.inv-meta-table td {
  padding: 2px 0 2px 10px;
}

.inv-meta-table .meta-label {
  color: #64748b;
  font-weight: 600;
}

.inv-meta-table .meta-val {
  font-weight: 700;
  font-family: var(--font-mono);
  color: #0f172a;
}

.inv-parties-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid #e2e8f0;
}

.party-box-title {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
  margin-bottom: 6px;
}

.party-name {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
}

.party-info {
  font-size: 11px;
  color: #475569;
  line-height: 1.4;
  margin-top: 2px;
}

.inv-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
}

.inv-table th {
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
  padding: 8px 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  text-align: left;
}

.inv-table td {
  padding: 10px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: top;
  font-size: 11px;
  color: #0f172a;
}

.inv-item-desc {
  font-weight: 600;
  color: #0f172a;
}

.dual-curr-val {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.dual-curr-main {
  font-weight: 700;
  font-family: var(--font-mono);
  color: #0f172a;
}

.dual-curr-sub {
  font-size: 10px;
  color: #e85d9e;
  font-weight: 700;
  font-family: var(--font-mono);
}

.inv-summary-section {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
}

.inv-bank-box {
  flex: 1;
  background: #f8fafc;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 11px;
  color: #334155;
}

.inv-bank-title {
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 4px;
}

.inv-totals-box {
  width: 250px;
}

.inv-total-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 11px;
  color: #475569;
}

.inv-total-row.grand-total {
  border-top: 2px solid #0f172a;
  margin-top: 6px;
  padding-top: 8px;
  font-size: 14px;
  font-weight: 800;
  color: #0f172a;
}

.grand-total-gbp-box {
  margin-top: 6px;
  padding: 6px 10px;
  background: #fdf4ff;
  border: 1px solid #f0abfc;
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.grand-total-gbp-title {
  font-size: 11px;
  font-weight: 700;
  color: #86198f;
}

.grand-total-gbp-val {
  font-size: 13px;
  font-weight: 800;
  color: #a21caf;
  font-family: var(--font-mono);
}

.inv-legal-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
  font-size: 10px;
  color: #64748b;
  line-height: 1.4;
}

.legal-highlight {
  font-weight: 700;
  color: #0f172a;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #141b18;
  border: 1px solid rgba(26, 128, 96, 0.4);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  transition: transform 0.2s, opacity 0.2s;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   MOBILE RESPONSIVE RULES (< 900px)
   ========================================================================== */
@media (max-width: 900px) {
  /* Hide desktop sidebar */
  .sidebar {
    display: none !important;
  }

  /* Show Mobile Top Header */
  .mobile-top-header {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(19, 25, 23, 0.95);
    backdrop-filter: blur(14px);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--line);
    width: 100%;
  }

  .mobile-brand-box {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .mobile-brand-box .brand-logo-img {
    width: 28px;
    height: 28px;
  }

  .mobile-header-title {
    display: flex;
    flex-direction: column;
  }

  .mobile-brand-name {
    font-size: 15px;
    font-weight: 800;
    color: #fff;
  }

  .badge-sub {
    font-size: 10px;
    color: var(--green-light);
    font-weight: 600;
  }

  .mobile-sync-status {
    font-size: 10px;
    color: var(--green-light);
    font-weight: 600;
  }

  /* Show Mobile Bottom Navigation */
  .mobile-bottom-nav {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(19, 25, 23, 0.98);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--line);
    padding: 6px 4px calc(env(safe-area-inset-bottom, 0px) + 6px);
    z-index: 100;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
    justify-content: space-around;
    width: 100%;
  }

  .mobile-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 600;
    padding: 6px 8px;
    cursor: pointer;
    border-radius: var(--radius-sm);
  }

  .mobile-nav-btn.active {
    color: var(--green-light);
  }

  .mobile-nav-btn.active svg {
    stroke: var(--green-light);
    stroke-width: 2.4;
  }

  /* Main Container Padding for Mobile */
  .app-container {
    flex-direction: column;
  }

  .main-content {
    padding: 16px 14px 80px 14px;
    max-width: 100%;
  }

  .content-header {
    margin-bottom: 16px;
  }

  .page-title {
    font-size: 20px;
  }

  .page-subtitle {
    font-size: 12px;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .header-actions .btn {
    flex: 1;
  }

  .metrics-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
  }

  .metric-card {
    padding: 14px;
    gap: 10px;
  }

  .metric-icon {
    width: 38px;
    height: 38px;
  }

  .metric-value {
    font-size: 16px;
  }

  .form-row {
    flex-direction: column;
    gap: 12px;
  }

  .tax-info-body {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .tax-quarters-grid {
    grid-template-columns: 1fr;
  }

  /* Invoice Line Items on Mobile */
  .item-main-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .item-desc-input {
    grid-column: 1 / -1;
  }

  .item-total-col {
    grid-column: 1 / 2;
    text-align: left;
  }

  /* Modal on Mobile */
  .modal-overlay {
    padding: 0;
  }

  .modal-large, .modal-medium {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }

  .modal-header {
    padding: 12px 16px;
  }

  .hide-mobile {
    display: none !important;
  }

  /* Mobile Switcher inside Modal */
  .mobile-modal-tabs {
    display: flex !important;
    background: var(--bg-2);
    border-bottom: 1px solid var(--line);
  }

  .mobile-modal-tab-btn {
    flex: 1;
    padding: 12px;
    border: none;
    background: transparent;
    font-weight: 700;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
  }

  .mobile-modal-tab-btn.active {
    background: var(--bg-panel);
    color: var(--green-light);
    border-bottom: 2px solid var(--green);
  }

  .modal-split-layout {
    flex-direction: column;
    overflow-y: auto;
  }

  .editor-pane, .preview-pane {
    display: none;
    width: 100%;
    padding: 16px;
    border-right: none;
  }

  .editor-pane.active-mobile-view, .preview-pane.active-mobile-view {
    display: block;
  }

  .invoice-paper {
    padding: 20px 14px;
    min-height: auto;
    font-size: 10px;
  }

  .inv-parties-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .inv-summary-section {
    flex-direction: column;
    gap: 16px;
  }

  .inv-totals-box {
    width: 100%;
  }

  .inv-bank-box {
    width: 100%;
  }
}

/* Print */
@media print {
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  html, body {
    width: 210mm !important;
    height: 297mm !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    overflow: hidden !important;
  }

  @page {
    size: A4 portrait;
    margin: 0;
  }

  .app-container, .modal-overlay, .sidebar, .toast, .mobile-top-header, .mobile-bottom-nav {
    display: none !important;
  }

  .print-only {
    display: block !important;
    width: 210mm !important;
    height: 297mm !important;
    max-height: 297mm !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
  }

  #print-container .invoice-paper {
    position: relative !important;
    overflow: hidden !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    width: 210mm !important;
    max-width: 210mm !important;
    height: 297mm !important;
    max-height: 297mm !important;
    min-height: 297mm !important;
    padding: 16mm 18mm !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    page-break-inside: avoid !important;
    page-break-after: avoid !important;
    page-break-before: avoid !important;
  }

  .invoice-watermark-bg {
    position: absolute !important;
    top: 48% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 300px !important;
    height: 300px !important;
    opacity: 0.12 !important;
    filter: opacity(0.12) !important;
    pointer-events: none !important;
    z-index: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .invoice-watermark-bg img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    opacity: 0.12 !important;
  }

  .inv-sheet-header,
  .inv-parties-grid,
  .inv-table,
  .inv-summary-section,
  .inv-legal-footer {
    position: relative !important;
    z-index: 2 !important;
  }
}
