/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  --navy:      #1f3864;
  --blue:      #2e75b6;
  --blue-lt:   #bdd7ee;
  --blue-bg:   #e8f4fd;
  --grey-bg:   #f4f6f9;
  --white:     #ffffff;
  --border:    #d0dce8;
  --text:      #1a1a1a;
  --text-mute: #6b7280;
  --red:       #c53030;
  --radius:    6px;
  --radius-sm: 4px;
  --shadow-sm: 0 1px 3px rgba(31,56,100,.08), 0 1px 2px rgba(31,56,100,.05);
  --shadow:    0 2px 8px rgba(31,56,100,.10), 0 1px 3px rgba(31,56,100,.06);
  --transition: 150ms ease;
}

/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--grey-bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--navy); text-decoration: none; }

/* ── Navigation ───────────────────────────────────────────── */
header {
  background: var(--navy);
  padding: 0 2rem;
  box-shadow: 0 2px 6px rgba(0,0,0,.18);
  position: sticky;
  top: 0;
  z-index: 100;
}
header nav {
  display: flex;
  gap: 0;
  height: 52px;
  align-items: center;
}
header nav a {
  color: #cbd5e1;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.03em;
  padding: 0 1rem;
  height: 100%;
  display: flex;
  align-items: center;
  border-bottom: 3px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}
header nav a:hover {
  color: #fff;
  border-bottom-color: var(--blue-lt);
}

/* ── Main content ─────────────────────────────────────────── */
main {
  max-width: 980px;
  margin: 1.75rem auto;
  padding: 0 1.25rem;
}

h1 { font-size: 1.4rem; color: var(--navy); margin-bottom: 1.5rem; font-weight: 700; }
h2 { font-size: 1rem; color: var(--blue); margin-bottom: 0.75rem; font-weight: 600; }

/* ── Form layout ──────────────────────────────────────────── */
section {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}
section:focus-within {
  box-shadow: var(--shadow);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem 1.5rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-mute);
  font-weight: 600;
  letter-spacing: 0.01em;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="email"],
input[type="file"],
select,
textarea {
  font-size: 13px;
  padding: 6px 10px;
  border: 1px solid #c4cfd8;
  border-radius: var(--radius-sm);
  background: #fafcfe;
  color: var(--text);
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  font-family: inherit;
}
input:hover:not(:focus), select:hover:not(:focus) {
  border-color: var(--blue);
  background: var(--white);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(46,117,182,.15);
  background: var(--white);
}

.form-actions {
  margin-top: 1.5rem;
  display: flex;
  gap: 1rem;
}

/* ── Buttons ─────────────────────────────────────────────── */
button, .btn {
  background: var(--navy);
  color: #fff;
  border: none;
  padding: 8px 22px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  letter-spacing: 0.01em;
  white-space: nowrap;
}
button:hover, .btn:hover {
  background: var(--blue);
  box-shadow: 0 2px 6px rgba(46,117,182,.30);
}
button:active, .btn:active {
  transform: translateY(1px);
  box-shadow: none;
}

.btn-secondary {
  background: #64748b;
  color: #fff;
  border: none;
  padding: 8px 22px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.btn-secondary:hover { background: #475569; box-shadow: 0 2px 6px rgba(0,0,0,.15); }
.btn-secondary:active { transform: translateY(1px); box-shadow: none; }

.btn-danger, .btn-delete {
  background: none;
  border: 1px solid #dc2626;
  color: #dc2626;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.btn-danger:hover, .btn-delete:hover {
  background: #dc2626;
  color: #fff;
  box-shadow: 0 2px 6px rgba(220,38,38,.25);
}

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

/* ── Report header ────────────────────────────────────────── */
.report-header {
  background: var(--navy);
  color: #fff;
  padding: 1rem 1.5rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  box-shadow: var(--shadow);
}
.report-header--logo {
  background: var(--white);
  color: var(--navy);
  border: 1px solid var(--border);
}
.rh-left  { flex: 1; }
.rh-right { flex: 1; text-align: right; }
.rh-company { font-size: 11px; color: var(--blue-lt); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.report-header--logo .rh-company { color: var(--navy); }
.rh-title   { font-size: 1.2rem; font-weight: 700; margin: 3px 0; }
.report-header--logo .rh-title { color: var(--navy); }
.rh-date    { font-size: 12px; color: var(--blue-lt); margin-top: 2px; }
.report-header--logo .rh-date  { color: var(--text-mute); }
.rh-name    { font-size: 1rem; font-weight: 700; }
.report-header--logo .rh-name  { color: var(--navy); }
.rh-meta    { font-size: 12px; color: var(--blue-lt); margin-top: 2px; }
.report-header--logo .rh-meta  { color: var(--text-mute); }
.rh-logo    { max-height: 36px; max-width: 130px; width: auto; object-fit: contain; display: block; margin-bottom: 4px; }
/* Form title row with logo */
.form-title-row { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.5rem; }
.form-title-row h1 { margin: 0; }
#form-company-logo { max-height: 40px; max-width: 150px; object-fit: contain; }
.report-actions { width: 100%; display: flex; flex-direction: column; gap: 0.4rem; align-items: flex-end; margin-top: 0.5rem; }
.report-actions-row { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: flex-end; }

/* ── Two-column report layout ─────────────────────────────── */
.report-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: start;
}
.report-col { display: flex; flex-direction: column; gap: 1rem; }

.report-section {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  margin-bottom: 0;
  box-shadow: var(--shadow-sm);
}
.report-section h2 {
  background: var(--blue);
  color: #fff;
  margin: -1rem -1.5rem 0.75rem;
  padding: 7px 1.5rem;
  border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 700;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.report-table th {
  background: var(--navy);
  color: #fff;
  padding: 6px 8px;
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.report-table td {
  padding: 4px 8px;
  border-bottom: 1px solid #eef2f7;
  transition: background var(--transition);
}
.report-table tbody tr:hover:not(.total):not(.subtotal) td {
  background: #f0f7ff !important;
}
.report-table td.amt {
  text-align: right;
  font-variant-numeric: tabular-nums;
  min-width: 90px;
  white-space: nowrap;
  font-weight: 500;
}
.report-table td.rate {
  text-align: right;
  font-size: 11px;
  color: var(--text-mute);
  white-space: nowrap;
}
.recap-table td:first-child { width: 65%; }
.recap-table td.amt { width: 35%; }
.report-table .indent td:first-child { padding-left: 1.5rem; }

.report-table tr.total td {
  background: var(--navy);
  color: #fff;
  font-weight: 700;
  border-bottom: none;
}
.report-table tr.subtotal td {
  background: var(--blue-lt);
  color: var(--navy);
  font-weight: 700;
}
.report-table tr.deduction td {
  font-style: italic;
  color: #555;
}
.report-table tr:nth-child(even):not(.total):not(.subtotal) td {
  background: #f7fafd;
}

/* ── Info box ─────────────────────────────────────────────── */
.info-box {
  background: var(--blue-bg);
  border: 1px solid var(--blue);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  color: var(--navy);
  font-size: 13px;
  margin-bottom: 1rem;
}

/* ── Warning ──────────────────────────────────────────────── */
.warning {
  background: #fffbeb;
  border: 1px solid #f59e0b;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  color: #92400e;
  font-weight: 600;
  margin-bottom: 1rem;
}

/* ── Language switcher ────────────────────────────────────── */
.lang-switcher { margin-left: auto; display: flex; gap: 4px; }
.lang-btn {
  color: #94a3b8;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}
.lang-btn:hover { color: #fff; border-color: #94a3b8; }
.lang-btn.active { color: var(--navy); background: #fff; border-color: #fff; }

/* ── Print / PDF ──────────────────────────────────────────── */
@media print {
  header, .report-actions { display: none; }
  body { background: #fff; }
  .report-cols { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
  .report-section { border: 1px solid #ccc; padding: 0.5rem; margin-bottom: 0.25rem; box-shadow: none; }
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 720px) {
  .report-cols { grid-template-columns: 1fr; }
  header nav { gap: 0; }
  header nav a { padding: 0 0.6rem; font-size: 12px; }
}

/* ── Radio group ──────────────────────────────────────────── */
.radio-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin-bottom: 0.5rem;
}
.radio-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-mute);
  min-width: 140px;
}
.radio-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: normal;
  color: var(--text);
  cursor: pointer;
}
.radio-item input[type="radio"] { width: auto; cursor: pointer; accent-color: var(--blue); }

/* ── Alert / validation errors ────────────────────────────── */
.alert {
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}
.alert-error {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: var(--red);
}
.alert ul { margin: 0; padding-left: 1.25rem; }

/* ── Form sub-heading ─────────────────────────────────────── */
.form-subhead {
  font-size: 11px;
  font-weight: 700;
  color: var(--blue);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 1rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px solid #e4ecf5;
}

/* ── Utilities ────────────────────────────────────────────── */
.mt-sm { margin-top: 0.75rem; }

/* ── Field notes / inline warnings ─────────────────────────── */
.field-note {
  font-size: 11px;
  font-weight: normal;
  color: var(--red);
  margin-top: 2px;
}

/* ── Data table ─────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 0.75rem;
}
.data-table th {
  background: var(--navy);
  color: #fff;
  text-align: left;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.data-table th:first-child { border-radius: var(--radius-sm) 0 0 0; }
.data-table th:last-child  { border-radius: 0 var(--radius-sm) 0 0; }
.data-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.data-table tbody tr:hover td { background: #f0f7ff; }
.data-table tr:nth-child(even) td { background: #f7fafd; }
.data-table tbody tr:hover td { background: #e8f4fd !important; }
.data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

.btn-load {
  background: var(--blue);
  color: #fff;
  padding: 5px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  transition: background var(--transition);
}
.btn-load:hover { background: var(--navy); color: #fff; }

/* ── Tabs ─────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--blue);
  margin-bottom: 1.25rem;
}
.tab-btn {
  background: #e8f0f8;
  color: var(--navy);
  border: 1px solid var(--border);
  border-bottom: none;
  padding: 8px 22px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: background var(--transition), color var(--transition);
}
.tab-btn:hover:not(.active) { background: #d4e4f5; }
.tab-btn.active {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Input group (suffix like %) ──────────────────────────────── */
.input-group {
  display: flex;
  align-items: stretch;
  gap: 0;
}
.input-group input {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  flex: 1;
}
.input-suffix {
  background: #f1f5f9;
  border: 1px solid #c4cfd8;
  border-left: none;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--text-mute);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  white-space: nowrap;
  display: flex;
  align-items: center;
}

/* ── Form grid break ──────────────────────────────────────────── */
.grid-break {
  grid-column: 1 / -1;
  height: 0;
  border: none;
  border-top: 1px dashed #d0dce8;
  margin: 0.25rem 0;
  background: none;
}

/* ── Admin tabs ────────────────────────────────────────────────── */
.admin-tab {
  padding: 0.55rem 1.25rem;
  cursor: pointer;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: #f1f5f9;
  color: var(--navy);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
  display: inline-block;
}
.admin-tab.active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
  font-weight: 700;
}
.admin-tab:hover:not(.active) { background: #dce6f1; color: var(--navy); }

/* ── Societe selector ─────────────────────────────────────────── */
.societe-selector {
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
