/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5f5f5;
  --surface: #ffffff;
  --border: #e0e0e0;
  --text: #111111;
  --muted: #666666;
  --accent: #111111;
  --danger: #cc2200;
  --radius: 6px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  min-height: 100vh;
}

/* ─── Nav ─── */
nav {
  background: #111;
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 24px;
  height: 52px;
  gap: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: 32px;
  text-decoration: none;
  white-space: nowrap;
}

.nav-brand img {
  height: 22px;
  width: auto;
  display: block;
}

.nav-brand span {
  color: rgba(255,255,255,0.45);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  border-left: 1px solid rgba(255,255,255,0.2);
  padding-left: 10px;
}

.nav-links {
  display: flex;
  gap: 4px;
}

.nav-links a {
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 13px;
  transition: all 0.15s;
}

.nav-links a:hover,
.nav-links a.active {
  color: #fff;
  background: rgba(255,255,255,0.12);
}

/* ─── Layout ─── */
.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px;
}

.two-col {
  display: grid;
  grid-template-columns: 480px 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
}

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

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

/* ─── Form elements ─── */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.form-row.full { grid-template-columns: 1fr; }
.form-row.three { grid-template-columns: 2fr 1fr 1fr; }

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

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

input, textarea, select {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s;
  width: 100%;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: #888;
}

textarea { resize: vertical; min-height: 60px; }

/* ─── Items table ─── */
.items-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 10px;
}

.items-table th {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  padding: 0 6px 8px;
  border-bottom: 1px solid var(--border);
}

.items-table th.right,
.items-table td.right { text-align: right; }
.items-table th.center,
.items-table td.center { text-align: center; }

.items-table td {
  padding: 4px 4px;
  vertical-align: middle;
}

.items-table td input {
  padding: 6px 8px;
}

.btn-remove {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.15s;
}

.btn-remove:hover { color: var(--danger); }

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}

.btn-primary {
  background: #111;
  color: #fff;
}

.btn-primary:hover { background: #333; }

.btn-secondary {
  background: #fff;
  color: #333;
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: #f0f0f0; }

.btn-danger {
  background: #fff;
  color: var(--danger);
  border: 1px solid #fcc;
}

.btn-danger:hover { background: #fff5f5; }

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

.btn-add-item {
  background: none;
  border: 1px dashed var(--border);
  color: var(--muted);
  width: 100%;
  padding: 8px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 10px;
}

.btn-add-item:hover {
  border-color: #999;
  color: var(--text);
}

.actions-bar {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
}

/* ─── Language toggle ─── */
.lang-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 3px;
  width: fit-content;
  margin-bottom: 16px;
}

.lang-btn {
  padding: 5px 14px;
  border-radius: 4px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s;
}

.lang-btn.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* ─── Export buttons ─── */
.export-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  justify-content: flex-end;
}

/* ─── Invoice Preview ─── */
.preview-wrapper {
  position: sticky;
  top: 76px;
}

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

.invoice-preview {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 52px;
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 11px;
  color: #111;
  line-height: 1.5;
  min-height: 600px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

/* ─── Invoice header row (logo + title) ─── */
.inv-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 40px;
}

.inv-header-left .inv-title {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: -0.01em;
  line-height: 1;
  margin-bottom: 6px;
}

.inv-header-left .inv-date {
  font-size: 11px;
  color: #333;
}

.inv-header-right img {
  height: 36px;
  width: auto;
  display: block;
}

/* Legacy (kept for historial modal) */
.inv-title {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: -0.01em;
  line-height: 1;
  margin-bottom: 6px;
}

.inv-date {
  font-size: 11px;
  color: #333;
  margin-bottom: 40px;
}

.inv-to-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.inv-client {
  font-weight: 700;
  font-size: 11px;
  line-height: 1.7;
  margin-bottom: 32px;
}

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

.inv-table thead tr {
  border-top: 1px solid #111;
  border-bottom: 2px solid #111;
}

.inv-table th {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 8px 0;
  text-align: left;
}

.inv-table th:not(:first-child),
.inv-table td:not(:first-child) {
  text-align: right;
}

.inv-table td {
  padding: 8px 0;
  font-size: 11px;
  font-weight: 700;
  border-bottom: none;
}

.inv-table tbody tr:last-child td {
  padding-bottom: 8px;
}

.inv-total-row {
  border-top: 2px solid #111;
  border-bottom: 2px solid #111;
}

.inv-total-row td {
  padding: 10px 0;
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 0.05em;
}

.inv-footer {
  margin-top: 48px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.7;
  color: #111;
}

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

.page-header h1 {
  font-size: 20px;
  font-weight: 700;
}

.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.search-bar input {
  max-width: 320px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.data-table th {
  background: #f8f8f8;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid #f0f0f0;
  font-size: 13px;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fafafa; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  background: #f0f0f0;
  color: #555;
}

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

.empty-state p { font-size: 14px; margin-bottom: 12px; }

/* ─── Settings ─── */
.settings-form {
  max-width: 560px;
}

.settings-form .card-title { font-size: 13px; text-transform: none; font-weight: 700; letter-spacing: 0; color: var(--text); margin-bottom: 4px; }
.settings-form .card-subtitle { font-size: 12px; color: var(--muted); margin-bottom: 16px; }

/* ─── Toast ─── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #111;
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.25s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error { background: #cc2200; }

/* ─── PDF print styles ─── */
@media print {
  nav, .form-panel, .preview-label, .actions-bar { display: none !important; }
  body { background: #fff; }
  .invoice-preview { border: none; box-shadow: none; padding: 0; }
}
