:root {
  --ink: #172033;
  --muted: #65738a;
  --line: #dce3ec;
  --soft: #f4f6f9;
  --panel: #ffffff;
  --brand: #1557a0;
  --brand-dark: #0f3f77;
  --accent: #e8a317;
  --danger: #b42318;
  --ok: #157347;
  --shadow: 0 4px 16px rgba(23, 32, 51, .06);
}
* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; font-family: Inter, "Segoe UI", Arial, sans-serif; color: var(--ink); background: var(--soft); font-size: 14px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(135deg, #eef6ff, #f8fafc); }
.login-card { width: min(420px, 100%); background: white; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 24px; }
.login-card h1 { margin: 0 0 6px; font-size: 24px; }
.login-card p { margin: 0 0 18px; color: var(--muted); }
.password-field { position: relative; display: block; width: 100%; }
.password-field input { padding-right: 58px; display: block; width: 100%; }
.password-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 34px;
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  background: #f3f5f9;
  color: #4b5563;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.password-toggle svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}
.password-toggle .hidden {
  display: none;
}
.shell { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar { background: #122033; color: white; padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 50; }
.brand { border-bottom: 1px solid rgba(255,255,255,.12); padding: 2px 6px 18px; margin-bottom: 10px; display: flex; align-items: center; gap: 11px; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 6px; background: var(--accent); color: #172033; font-size: 12px; font-weight: 900; }
.brand strong { display: block; font-size: 16px; }
.brand span { color: #cbd5e1; font-size: 12px; }
.nav button, .nav a { width: 100%; border: 0; background: transparent; color: #d7e0eb; text-align: left; padding: 10px 11px; border-radius: 5px; margin-bottom: 2px; display: block; text-decoration: none; font-size: 13px; font-weight: 600; }
.nav button.active, .nav a.active { background: #ffffff; color: #173f72; box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.nav button:hover, .nav a:hover { background: rgba(255,255,255,.09); color: white; }
.nav a.active:hover { background: #fff; color: #173f72; }
.main { padding: 0 24px 32px; min-width: 0; max-width: 1900px; width: 100%; }
.topbar { min-height: 72px; display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 22px; border-bottom: 1px solid var(--line); background: rgba(244,246,249,.94); position: sticky; top: 0; z-index: 35; }
.page-heading > span { display: block; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.topbar h1 { font-size: 20px; margin: 3px 0 0; }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: #dce9f8; color: var(--brand-dark); font-weight: 900; }
.user-meta strong, .user-meta span { display: block; }
.user-meta strong { font-size: 12px; }
.user-meta span { margin-top: 2px; color: var(--muted); font-size: 10px; }
.logout-button { color: var(--muted); }
.logout-button svg, .menu-toggle svg { width: 19px; height: 19px; fill: currentColor; }
.layout-toggle svg { width: 18px; height: 18px; fill: currentColor; }
.layout-toggle .layout-icon-sidebar { display: none; }
.layout-horizontal .layout-toggle .layout-icon-horizontal { display: none; }
.layout-horizontal .layout-toggle .layout-icon-sidebar { display: block; }
.menu-toggle { display: none; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); align-items: center; justify-content: center; }
.sidebar-backdrop { display: none; }

@media (min-width: 981px) {
  body.layout-horizontal .shell { display: block; }
  body.layout-horizontal .sidebar {
    width: 100%;
    height: 62px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 24px;
    overflow: visible;
    box-shadow: 0 2px 12px rgba(12,24,40,.13);
  }
  body.layout-horizontal .brand {
    flex: 0 0 auto;
    min-width: 190px;
    height: 62px;
    margin: 0;
    padding: 0 22px 0 0;
    border: 0;
    border-right: 1px solid rgba(255,255,255,.12);
  }
  body.layout-horizontal .brand-mark { width: 32px; height: 32px; }
  body.layout-horizontal .brand span { display: none; }
  body.layout-horizontal .nav { display: flex; flex: 1 1 auto; align-items: center; gap: 3px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  body.layout-horizontal .nav::-webkit-scrollbar { display: none; }
  body.layout-horizontal .nav-group { display: none; }
  body.layout-horizontal .nav a,
  body.layout-horizontal .nav button {
    width: auto;
    margin: 0;
    padding: 9px 11px;
    white-space: nowrap;
  }
  body.layout-horizontal .main { margin: 0 auto; }
  body.layout-horizontal .topbar { top: 62px; }
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.compact-actions { gap: 12px; flex-wrap: nowrap; }
.btn { border: 1px solid #cfd8e5; background: white; color: var(--ink); padding: 9px 12px; border-radius: 5px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; transition: background .15s, border-color .15s, box-shadow .15s; }
.btn:hover { border-color: #9cacc1; box-shadow: 0 2px 6px rgba(23,32,51,.08); }
.btn.primary { background: var(--brand); color: white; border-color: var(--brand); }
.btn.ok { background: var(--ok); color: white; border-color: var(--ok); }
.btn.danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn.small { padding: 6px 8px; font-size: 12px; }
.icon-action { width: 28px; height: 28px; border: 0; background: transparent; display: inline-flex; align-items: center; justify-content: center; font-size: 19px; line-height: 1; padding: 0; }
.icon-action.danger-outline { color: #f43f5e; border: 1px solid #f43f5e; border-radius: 999px; font-size: 20px; }
.icon-action.menu-outline { color: #0ea5d8; font-size: 22px; }
.cards { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 16px; box-shadow: var(--shadow); }
.metric span { color: var(--muted); font-size: 12px; }
.metric strong { display: block; font-size: 26px; margin-top: 6px; }
.section { display: none; min-width: 0; }
.section.active { display: block; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0; }
.panel h2 { margin: 0; padding: 14px 16px; border-bottom: 1px solid var(--line); font-size: 15px; }
.panel-body { padding: 16px; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
#articleItemForm {
  grid-column: 1 / -1;
  width: 100%;
}
.article-program-grid {
  grid-template-columns: repeat(3, minmax(145px, 1fr)) minmax(120px, 1.5fr) minmax(300px, 300px);
  align-items: start;
}
.article-program-grid > .field:nth-child(1) { grid-column: 1; grid-row: 1; }
.article-program-grid > .field:nth-child(2) { grid-column: 2; grid-row: 1; }
.article-program-grid > .field:nth-child(3) { grid-column: 3; grid-row: 1; }
.article-program-grid > .field:nth-child(4) { grid-column: 1; grid-row: 2; }
.article-program-grid > .field:nth-child(5) { grid-column: 2; grid-row: 2; }
.article-program-grid > .field:nth-child(6) { grid-column: 3; grid-row: 2; }
.article-program-grid > .field:nth-child(7) { grid-column: 1; grid-row: 3; }
.article-program-grid > .tax-specific-card {
  grid-column: 5;
  grid-row: 1 / span 3;
  align-self: start;
  width: 100%;
}
label { display: block; font-size: 12px; font-weight: 700; color: #334155; margin-bottom: 6px; }
input, select, textarea { width: 100%; border: 1px solid #cfd8e5; border-radius: 5px; padding: 9px 10px; background: white; min-height: 40px; color: var(--ink); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(21,87,160,.12); }
textarea { min-height: 72px; resize: vertical; }
.field { margin-bottom: 12px; }
.tax-specific-card {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line);
  padding-top: 6px;
  margin-top: 0;
  background: #f3f4f6;
}
.tax-specific-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 12px 8px;
  font-size: 13px;
  color: #111827;
}
.switch-control {
  width: 38px;
  height: 20px;
  margin: 0;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.switch-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.switch-control span {
  position: relative;
  width: 38px;
  height: 18px;
  border-radius: 999px;
  background: #cbd5e1;
  transition: background .15s ease;
}
.switch-control span::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 0;
  top: -1px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .25);
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
}
.switch-control input:checked + span { background: #68b487; }
.switch-control input:checked + span::after {
  transform: translateX(18px);
  background: #16a34a;
  border-color: #16a34a;
}
.tax-specific-type {
  border: 0;
  border-radius: 0;
  min-height: 40px;
  padding: 0 12px;
  background: #b88b00;
  color: #111827;
  font-size: 13px;
}
.tax-specific-value-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 90px;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  margin: 0;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 400;
  color: #111827;
}
.tax-specific-value-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tax-specific-value-row input {
  border: 0;
  background: transparent;
  color: #0082a8;
  text-align: left;
  font-size: 13px;
  min-height: 32px;
}
.tax-specific-card.is-disabled .tax-specific-type,
.tax-specific-card.is-disabled .tax-specific-value-row {
  opacity: .55;
}
.muted { color: var(--muted); font-size: 12px; }
.table-wrap { overflow: auto; max-width: 100%; }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); padding: 9px; text-align: left; vertical-align: top; font-size: 13px; }
th { background: #f8fafc; font-size: 12px; color: #334155; }
.right { text-align: right; }
.panel-title-actions { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.table-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.compact-toolbar { display: grid; grid-template-columns: minmax(260px, 1fr) 150px 150px 160px auto; align-items: center; gap: 8px; }
.compact-toolbar input,
.compact-toolbar select { width: 100%; min-height: 34px; padding: 7px 10px; border-radius: 5px; }
.history-export-buttons { display: inline-flex; align-items: center; justify-content: flex-end; gap: 6px; min-width: 154px; }
.history-export-buttons .dt-buttons { display: inline-flex; align-items: center; gap: 6px; float: none; }
.history-export-buttons button.dt-button,
.history-export-buttons div.dt-button,
.history-export-buttons a.dt-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  margin: 0;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  background-image: none !important;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  box-shadow: none;
}
.history-export-buttons button.dt-button:hover,
.history-export-buttons div.dt-button:hover,
.history-export-buttons a.dt-button:hover { border-color: #9fb0c9; background: #f8fafc; color: var(--ink); }
.history-export-buttons .dt-btn-icon,
.btn-icon { width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 16px; }
.history-export-buttons svg,
.btn-icon svg { width: 16px; height: 16px; display: block; fill: currentColor; }
.dt-btn-excel { color: #166534 !important; }
.dt-btn-csv { color: #0f4c81 !important; }
.btn.icon-only {
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn.icon-only svg { width: 18px; height: 18px; display: block; fill: currentColor; }
.history-action-btn { color: var(--brand); }
#historyCasesTable,
.case-compact-table { table-layout: fixed; width: 100% !important; }
#invoiceHistoryTable { table-layout: fixed; width: 100% !important; }
#historyCasesTable th,
#historyCasesTable td,
.case-compact-table th,
.case-compact-table td,
#invoiceHistoryTable th,
#invoiceHistoryTable td { white-space: nowrap; vertical-align: middle; }
#invoiceHistoryTable th,
#invoiceHistoryTable td,
#historyCasesTable th,
#historyCasesTable td,
.case-compact-table th,
.case-compact-table td {
  overflow: hidden;
  text-overflow: ellipsis;
}
#historyCasesTable td:nth-child(5),
#historyCasesTable td:nth-child(6),
#historyCasesTable td:nth-child(7),
#historyCasesTable td:nth-child(9),
#invoiceHistoryTable td:nth-child(1),
#invoiceHistoryTable td:nth-child(2),
#invoiceHistoryTable td:nth-child(8),
#invoiceHistoryTable td:nth-child(9),
#invoiceHistoryTable td:nth-child(10) {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}
#invoiceHistoryTable th:nth-child(1), #invoiceHistoryTable td:nth-child(1) { width: 11%; }
#invoiceHistoryTable th:nth-child(2), #invoiceHistoryTable td:nth-child(2) { width: 9%; }
#invoiceHistoryTable th:nth-child(3), #invoiceHistoryTable td:nth-child(3) { width: 4%; }
#invoiceHistoryTable th:nth-child(4), #invoiceHistoryTable td:nth-child(4) { width: 4%; }
#invoiceHistoryTable th:nth-child(5), #invoiceHistoryTable td:nth-child(5) { width: 11%; }
#invoiceHistoryTable th:nth-child(6), #invoiceHistoryTable td:nth-child(6) { width: 8%; }
#invoiceHistoryTable th:nth-child(7), #invoiceHistoryTable td:nth-child(7) { width: 7%; }
#invoiceHistoryTable th:nth-child(8), #invoiceHistoryTable td:nth-child(8) { width: 9%; }
#invoiceHistoryTable th:nth-child(9), #invoiceHistoryTable td:nth-child(9) { width: 12%; }
#invoiceHistoryTable th:nth-child(10), #invoiceHistoryTable td:nth-child(10) { width: 11%; }
#invoiceHistoryTable th:nth-child(11), #invoiceHistoryTable td:nth-child(11) { width: 8%; }
#invoiceHistoryTable th:nth-child(12), #invoiceHistoryTable td:nth-child(12) {
  width: 6%;
  min-width: 96px;
  overflow: visible;
  text-align: center;
}
#invoiceHistoryTable td:nth-child(12) .compact-actions {
  justify-content: center;
  flex-wrap: nowrap;
  gap: 4px;
}
#invoiceHistoryTable td:nth-child(12) .btn.icon-only {
  width: 30px;
  height: 30px;
  min-height: 30px;
}
#historyCasesTable th:nth-child(12),
#historyCasesTable td:nth-child(12) { text-align: center; width: 54px; }
#caseDefinitionsTable th:nth-child(1), #caseDefinitionsTable td:nth-child(1) { width: 4%; }
#caseDefinitionsTable th:nth-child(2), #caseDefinitionsTable td:nth-child(2) { width: 18%; }
#caseDefinitionsTable th:nth-child(3), #caseDefinitionsTable td:nth-child(3) { width: 18%; }
#caseDefinitionsTable th:nth-child(4), #caseDefinitionsTable td:nth-child(4) { width: 26%; }
#caseDefinitionsTable th:nth-child(5), #caseDefinitionsTable td:nth-child(5) { width: 20%; }
#caseDefinitionsTable th:nth-child(6), #caseDefinitionsTable td:nth-child(6) { width: 14%; }
#localCasesTable th:nth-child(1), #localCasesTable td:nth-child(1) { width: 13%; }
#localCasesTable th:nth-child(2), #localCasesTable td:nth-child(2) { width: 7%; }
#localCasesTable th:nth-child(3), #localCasesTable td:nth-child(3) { width: 7%; }
#localCasesTable th:nth-child(4), #localCasesTable td:nth-child(4) { width: 15%; }
#localCasesTable th:nth-child(5), #localCasesTable td:nth-child(5) { width: 11%; }
#localCasesTable th:nth-child(6), #localCasesTable td:nth-child(6) { width: 9%; }
#localCasesTable th:nth-child(7), #localCasesTable td:nth-child(7) { width: 17%; }
#localCasesTable th:nth-child(8), #localCasesTable td:nth-child(8) { width: 13%; }
#localCasesTable th:nth-child(9), #localCasesTable td:nth-child(9) { width: 8%; text-align: center; }
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate { padding-top: 9px; font-size: 12px; color: var(--muted); }
.dataTables_wrapper .dataTables_paginate .paginate_button { border-radius: 5px !important; padding: 4px 8px !important; margin-left: 2px !important; }
.dataTables_wrapper .dataTables_paginate .paginate_button.current { background: var(--brand) !important; border-color: var(--brand) !important; color: #fff !important; }
@media (max-width: 980px) {
  .compact-toolbar { grid-template-columns: 1fr 1fr; }
  .compact-toolbar input { grid-column: 1 / -1; }
  .history-export-buttons { justify-content: flex-start; min-width: 0; }
  .article-program-grid { grid-template-columns: 1fr; }
  .article-program-grid > .field,
  .article-program-grid > .tax-specific-card {
    grid-column: 1;
    grid-row: auto;
  }
}
@media (max-width: 640px) {
  .compact-toolbar { grid-template-columns: 1fr; }
}
.status { display: inline-block; padding: 4px 7px; border-radius: 999px; background: #e2e8f0; font-size: 11px; font-weight: 700; }
.status.NORMALISEE { background: #dcfce7; color: #166534; }
.status.BROUILLON { background: #e0f2fe; color: #075985; }
.status.ERREUR_DGI, .status.ERREUR_ANNULATION { background: #fee2e2; color: #991b1b; }
.status.ANNULEE { background: #fef3c7; color: #92400e; }
.nav-group { display: block; margin: 18px 11px 6px; color: #8998ac; font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.role-label { display: inline-block; margin-left: 6px; padding: 2px 6px; border: 1px solid #b9c7da; border-radius: 4px; color: #3d536f; font-size: 10px; font-weight: 800; }
.admin-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 14px; }
.admin-heading h2 { margin: 0; font-size: 22px; }
.admin-heading p { margin: 4px 0 0; color: var(--muted); }
.admin-tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.admin-tabs button { border: 0; border-bottom: 2px solid transparent; background: transparent; padding: 10px 2px; color: var(--muted); font-weight: 700; cursor: pointer; }
.admin-tabs button.active { border-bottom-color: var(--brand); color: var(--brand); }
.admin-view { display: none; }
.admin-view.active { display: block; }
.admin-table { width: 100%; border-collapse: collapse; background: #fff; }
.admin-table th { background: #f4f7fb; color: #526078; font-size: 11px; text-align: left; }
.admin-table th, .admin-table td { border-bottom: 1px solid var(--line); padding: 10px 12px; vertical-align: middle; }
.admin-filter { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.admin-filter input { width: min(440px, 100%); min-height: 38px; }
.audit-details { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-family: Consolas, monospace; font-size: 11px; }
.user-editor-dialog { width: min(680px, calc(100vw - 32px)); }
.settings-section-title { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 2px; margin-top: 12px; padding: 10px 0 6px; border-bottom: 1px solid var(--line); }
.settings-section-title:first-child { margin-top: 0; }
.settings-section-title strong { font-size: 14px; color: var(--ink); }
.settings-section-title span { font-size: 11px; color: var(--muted); }
.settings-address { margin-top: 12px; }
.settings-actions { display: flex; justify-content: flex-end; position: sticky; bottom: 0; margin: 16px -16px -16px; padding: 12px 16px; border-top: 1px solid var(--line); background: rgba(255,255,255,.96); }
.dashboard-welcome { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 14px; }
.dashboard-welcome h2 { margin: 0; font-size: 22px; }
.dashboard-welcome p { margin: 4px 0 0; color: var(--muted); }
.dashboard-metrics { margin-bottom: 14px; }
.dashboard-metrics .metric { border-left: 3px solid #2b5ea3; }
.dashboard-metrics .metric:nth-child(3) { border-left-color: #b42318; }
.dashboard-metrics .metric small { display: block; margin-top: 6px; color: var(--muted); font-size: 10px; }
.item-row { display: block; margin-bottom: 8px; }
.payment-row { grid-template-columns: minmax(180px, 260px) minmax(140px, 220px) 42px; }
.totals { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.totalbox { min-width: 160px; border: 1px solid var(--line); border-radius: 6px; padding: 10px; background: #f8fafc; }
.totalbox span { display: block; color: var(--muted); font-size: 12px; }
.totalbox strong { font-size: 18px; }
.notice { padding: 12px 14px; border-radius: 6px; border: 1px solid #b6d7ff; background: #eef6ff; color: #173f72; margin-bottom: 14px; white-space: pre-wrap; }
.danger-note { border-color: #fecaca; background: #fff1f2; color: #991b1b; }
.mt-sm { margin-top: 12px; }
.mt-md { margin-top: 14px; }
.mt-lg { margin-top: 16px; }
.hidden { display: none; }
.flat-panel { box-shadow: none; }
pre { white-space: pre-wrap; background: #0f172a; color: #dbeafe; padding: 14px; border-radius: 8px; overflow: auto; max-height: 420px; }
dialog { border: 0; border-radius: 8px; padding: 0; width: min(900px, calc(100vw - 32px)); box-shadow: 0 24px 80px rgba(0,0,0,.24); }
dialog::backdrop { background: rgba(15, 23, 42, .55); }
.article-form-modal { width: min(1120px, calc(100vw - 32px)); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; font-size: 16px; }
.dialog-body { padding: 16px; }
.print-page { margin: 24px; background: white; }
.print-top { display: flex; justify-content: space-between; gap: 24px; border-bottom: 3px solid var(--brand); padding-bottom: 16px; }
.print-meta { text-align: right; font-size: 13px; }
.badge { display: inline-block; padding: 5px 9px; border-radius: 4px; background: var(--brand); color: white; font-weight: 700; }
.badge-soft { display: inline-block; min-width: 24px; text-align: center; padding: 3px 7px; border-radius: 5px; background: #f6c400; color: #111827; font-size: 11px; font-weight: 700; }
.badge-soft.blue { background: #0ea5d8; color: #ffffff; }
.invoice-workspace { border-radius: 4px; position: relative; }
.invoice-workspace h2 { padding: 8px 12px; font-size: 14px; }
.invoice-workspace .invoice-titlebar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.invoice-titlebar small { color: var(--muted); font-size: 10px; font-weight: 600; }
.invoice-workspace .panel-body { padding: 10px 14px; }
.invoice-workspace .invoice-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 14px; align-items: start; }
.invoice-workspace .invoice-block { margin-bottom: 8px; }
.invoice-workspace .invoice-block-title { font-size: 14px; font-weight: 500; margin: 0 0 2px; }
.invoice-workspace .invoice-block-title.with-action { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.invoice-workspace .grid { gap: 7px 12px; }
.invoice-workspace .grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.invoice-workspace .field { margin-bottom: 5px; }
.invoice-workspace label { font-size: 11px; margin-bottom: 3px; }
.invoice-workspace input,
.invoice-workspace select { min-height: 38px; padding: 7px 10px; border-radius: 5px; }
.invoice-workspace .btn { min-height: 38px; padding: 7px 11px; border-radius: 5px; }
.invoice-workspace .btn.small { padding: 5px 8px; }
.invoice-workspace .mt-sm { margin-top: 6px; }
.invoice-workspace .mt-md { margin-top: 8px; }
.invoice-workspace .item-row {
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}
.invoice-items-table { margin-top: 10px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #fff; }
.invoice-items-head,
.invoice-item-line {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 72px 62px 112px 104px 118px 76px;
  gap: 0;
  align-items: center;
}
.invoice-items-head { min-height: 34px; background: #f3f6fa; color: #526078; font-size: 10px; font-weight: 700; text-transform: uppercase; }
.invoice-items-head span,
.invoice-item-line > * { padding: 8px 9px; min-width: 0; }
.invoice-item-line { min-height: 54px; font-size: 12px; }
.invoice-item-line:hover { background: #f8fbff; }
.invoice-item-name strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.invoice-item-name small { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }
.invoice-item-group { display: inline-flex; justify-content: center; font-weight: 800; color: var(--brand); }
.invoice-item-quantity,
.invoice-item-price,
.invoice-item-discount,
.invoice-item-total { text-align: right; white-space: nowrap; }
.invoice-item-discount { color: #9f2d20; }
.invoice-item-actions { display: flex; justify-content: flex-end; gap: 4px; }
.invoice-workspace .payment-row { display: grid; grid-template-columns: minmax(0, 1fr) 108px 38px; gap: 6px; padding: 0; border: 0; background: transparent; }
.preview-discount { color: #9f2d20; font-size: 6px; font-weight: 700; }
.invoice-workspace .invoice-item-actions .btn,
.invoice-workspace .payment-row .btn { width: 38px; min-height: 38px; padding: 0; }
.invoice-workspace .invoice-catalog-toolbar { grid-template-columns: 180px minmax(240px, 1fr) auto; align-items: end; }
.invoice-workspace .invoice-catalog-toolbar .field:last-child { width: auto; }
.invoice-workspace .invoice-catalog-toolbar .btn { min-height: 38px; white-space: nowrap; }
.invoice-workspace .optional-block { margin-top: 4px; }
.invoice-workspace .optional-block summary { font-size: 13px; cursor: pointer; }
.invoice-workspace .invoice-side-column { display: grid; grid-template-columns: 1fr; gap: 8px; position: sticky; top: 12px; }
.invoice-workspace .invoice-side-column .invoice-block.compact { margin-bottom: 0; }
.invoice-workspace .totals { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin-top: 4px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.invoice-workspace .totalbox { min-width: 0; padding: 9px; border: 0; border-radius: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #fff; }
.invoice-workspace .totalbox:nth-child(2n) { border-right: 0; }
.invoice-workspace .totalbox.total-main { grid-column: 1 / -1; background: #eef5ff; border-right: 0; }
.invoice-workspace .totalbox.discount-total strong { color: #9f2d20; }
.invoice-workspace .totalbox span { font-size: 11px; }
.invoice-workspace .totalbox strong { font-size: 16px; }
.invoice-workspace .invoice-action-bar { display: grid; grid-template-columns: 1fr; margin-top: 4px; }
.invoice-workspace .invoice-action-bar .btn { width: 100%; min-height: 39px; }
.payment-balance,
.invoice-validation-state { margin-top: 7px; padding: 7px 9px; border-radius: 5px; font-size: 11px; font-weight: 700; }
.payment-balance.balanced,
.invoice-validation-state.valid { background: #e8f7ee; color: #17643a; border: 1px solid #b8e0c7; }
.payment-balance.pending,
.invoice-validation-state.invalid { background: #fff6e5; color: #7a4a00; border: 1px solid #f0d49b; }
.invoice-workspace .invoice-preview-panel { margin-top: 8px; }
.invoice-workspace .preview-head { padding: 10px 12px; cursor: pointer; list-style: none; }
.invoice-workspace .preview-head::-webkit-details-marker { display: none; }
.invoice-workspace .invoice-live-preview { padding: 8px; max-height: 420px; }
.invoice-loading {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(245, 247, 251, .78);
  backdrop-filter: blur(1px);
}
.item-editor-dialog { width: min(720px, calc(100vw - 32px)); }
.item-editor-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.item-editor-name { grid-column: 1 / -1; }
.item-editor-dialog .field { margin: 0; }
.item-editor-dialog input,
.item-editor-dialog select { width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 5px; }
.item-editor-result { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; padding: 12px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.item-editor-result span { color: var(--muted); }
.item-editor-result strong { font-size: 20px; color: var(--brand); }
.item-editor-actions { justify-content: flex-end; margin-top: 16px; }
.invoice-loading.hidden { display: none; }
.invoice-loading-box {
  min-width: min(360px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 18px;
  text-align: center;
}
.invoice-loading-box strong {
  display: block;
  margin-top: 10px;
  font-size: 15px;
}
.invoice-loading-box small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
}
.invoice-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid #dbe4f0;
  border-top-color: var(--brand);
  border-radius: 50%;
  display: inline-block;
  animation: invoice-spin .8s linear infinite;
}
@keyframes invoice-spin {
  to { transform: rotate(360deg); }
}
.print-box { border: 1px solid var(--line); padding: 12px; border-radius: 6px; }
.security { margin-top: 24px; border: 2px solid #172033; padding: 14px; display: grid; grid-template-columns: 140px 1fr; gap: 16px; align-items: center; }
.qrbox { width: 130px; height: 130px; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; text-align: center; font-size: 10px; overflow: hidden; }
.qrbox img { width: 130px; height: 130px; }
.invoice-preview-panel { border: 1px solid var(--line); border-radius: 8px; background: #f8fafc; overflow: hidden; }
.preview-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.preview-head h3 { margin: 0; font-size: 15px; }
.preview-head span { color: var(--muted); font-size: 12px; }
.invoice-live-preview { padding: 14px; overflow: auto; }
.preview-sheet { width: 718px; max-width: 100%; margin: 0 auto; background: #fff; color: #000; border: 1px solid #000; font-size: 8px; font-family: Arial, Helvetica, sans-serif; }
.preview-company-row { display: grid; grid-template-columns: minmax(260px, 1fr) 260px; gap: 14px; align-items: start; padding: 10px 10px 2px; }
.preview-company-row img { width: 320px; max-width: 100%; height: auto; }
.preview-company-row div { text-align: right; line-height: 1.2; font-size: 9px; }
.preview-company-row span { color: #ff8a00; }
.preview-sheet h2 { text-align: center; margin: 8px 0; font-size: 15px; font-weight: 800; }
.preview-info-grid { display: grid; grid-template-columns: 1.45fr 1fr; border-top: 1px solid #000; border-bottom: 1px solid #000; }
.preview-client { min-height: 112px; border-right: 1px solid #000; padding: 3px 6px; line-height: 1.08; font-size: 8px; }
.preview-client strong { font-size: 10px; }
.preview-info-grid table, .preview-lines, .preview-totals { width: 100%; border-collapse: collapse; }
.preview-info-grid td, .preview-info-grid th { border-bottom: 1px solid #000; padding: 1px 3px; font-size: 8px; line-height: 1.05; }
.preview-info-grid th { text-align: center; }
.preview-lines th, .preview-lines td { border: 1px solid #000; padding: 2px; font-size: 7px; line-height: 1.15; }
.preview-lines th { background: #bfbfbf; text-align: center; font-weight: 800; }
.preview-ref-row { text-align: left; background: #fff; font-size: 8px; border: 1px solid #000; border-bottom: 0; padding: 2px; line-height: 1.15; }
.preview-lines .section-row td { background: #bfbfbf; font-weight: 800; text-decoration: underline; }
.preview-lines .blank-row td { height: 24px; }
.preview-totals td, .preview-totals th { border: 1px solid #000; padding: 2px 4px; font-size: 9px; }
.preview-totals td { text-align: right; width: 86%; }
.preview-totals th { text-align: right; width: 14%; }
.preview-totals .main td, .preview-totals .main th { background: #d9d9d9; font-size: 11px; font-weight: 900; }
.preview-security { border-top: 1px solid #000; padding: 4px 6px; text-align: center; font-size: 9px; font-weight: 800; }
.preview-security span { float: right; }
.preview-security-box { display: grid; grid-template-columns: 145px 1fr; border-top: 1px solid #000; min-height: 92px; }
.preview-qr { display: flex; align-items: center; justify-content: center; border-right: 1px solid #000; }
.preview-qr img { width: 78px; height: 78px; }
.preview-security-data { padding: 8px; line-height: 1.35; font-size: 11px; }
.preview-security-data strong { display: block; text-align: center; color: #00a529; margin-bottom: 6px; }
@media (max-width: 980px) {
  .shell { display: block; }
  .sidebar { width: min(280px, 86vw); height: 100vh; position: fixed; left: 0; top: 0; transform: translateX(-102%); transition: transform .2s ease; box-shadow: 18px 0 40px rgba(12,24,40,.24); }
  body.nav-open { overflow: hidden; }
  body.nav-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 45; border: 0; background: rgba(12,24,40,.48); }
  body.nav-open .sidebar-backdrop { display: block; }
  .main { padding: 0 18px 28px; }
  .menu-toggle { display: inline-flex; flex: 0 0 38px; }
  .layout-toggle { display: none !important; }
  .cards, .grid, .grid.three { grid-template-columns: 1fr; }
  .item-row { grid-template-columns: 1fr 1fr; }
  .invoice-workspace .invoice-layout { grid-template-columns: 1fr; }
  .invoice-workspace .invoice-side-column { position: static; }
  .invoice-workspace .invoice-catalog-toolbar { grid-template-columns: 1fr 1fr; }
  .invoice-workspace .invoice-catalog-toolbar .field:last-child { grid-column: 1 / -1; }
  .topbar { min-height: 64px; margin-bottom: 16px; }
  .page-heading { margin-right: auto; }
  .preview-company-row, .preview-info-grid { grid-template-columns: 1fr; }
  .preview-client { border-right: 0; border-bottom: 1px solid #000; }
  .preview-security-box { grid-template-columns: 1fr; }
  .preview-qr { border-right: 0; border-bottom: 1px solid #000; padding: 8px; }
}
@media (max-width: 640px) {
  .main { padding: 0 12px 24px; }
  .topbar { gap: 9px; }
  .topbar h1 { font-size: 17px; }
  .page-heading > span, .user-meta { display: none; }
  .dashboard-welcome { align-items: flex-start; flex-direction: column; }
  .dashboard-welcome .actions, .dashboard-welcome .btn { width: 100%; }
  .panel-body { padding: 12px; }
  .cards { gap: 8px; }
  .invoice-items-head { display: none; }
  .invoice-item-line { grid-template-columns: 1fr auto; padding: 8px; }
  .invoice-item-line > * { padding: 4px; }
  .invoice-item-name { grid-column: 1 / -1; }
  .invoice-item-group,
  .invoice-item-quantity,
  .invoice-item-price,
  .invoice-item-discount,
  .invoice-item-total { text-align: left; justify-content: flex-start; }
  .invoice-item-actions { grid-column: 2; grid-row: 2 / span 3; align-self: center; }
  .invoice-workspace .invoice-catalog-toolbar,
  .invoice-workspace .payment-row,
  .item-editor-grid { grid-template-columns: 1fr; }
  .invoice-workspace .invoice-catalog-toolbar .field:last-child,
  .item-editor-name { grid-column: auto; }
  .invoice-workspace .payment-row .btn { width: 100%; }
  .invoice-workspace .totals { grid-template-columns: 1fr; }
  .invoice-workspace .totalbox,
  .invoice-workspace .totalbox:nth-child(2n) { border-right: 0; }
}
@media print {
  .actions { display: none; }
  body.print-page { margin: 0; }
}

.invoice-print-page { background: #ffffff; color: #000000; font-family: Arial, Helvetica, sans-serif; font-size: 8px; margin: 0; }
.invoice-actions { padding: 10px; }
.invoice-sheet { width: 718px; margin: 0 auto 24px; background: #fff; color: #000; }
.invoice-header { display: grid; grid-template-columns: 1fr 260px; align-items: start; gap: 14px; padding-top: 10px; }
.invoice-logo img { width: 330px; height: auto; display: block; }
.invoice-company { text-align: right; line-height: 1.2; font-size: 9px; }
.invoice-company .orange { color: #ff8a00; }
.invoice-title { text-align: center; font-size: 15px; margin: 8px 0; font-weight: 800; }
.invoice-info-grid { display: grid; grid-template-columns: 1.46fr 1fr; border: 1px solid #000; border-bottom: 0; }
.invoice-client-box { min-height: 112px; padding: 3px 6px; border-right: 1px solid #000; line-height: 1.08; font-size: 8px; }
.invoice-client-box > strong { font-size: 10px; }
.invoice-client-box .box-title { font-weight: 700; text-decoration: underline; margin-bottom: 2px; }
.invoice-meta-table { width: 100%; border-collapse: collapse; }
.invoice-meta-table td, .invoice-meta-table th { border-bottom: 1px solid #000; padding: 1px 3px; font-size: 8px; height: 16px; line-height: 1.05; }
.invoice-meta-table td { width: 55%; font-weight: 400; }
.invoice-meta-table th { text-align: center; font-weight: 800; }
.invoice-lines { width: 100%; border-collapse: collapse; table-layout: fixed; }
.invoice-comments { border: 1px solid #000; border-bottom: 0; padding: 3px 5px; font-size: 8px; line-height: 1.2; }
.invoice-lines th, .invoice-lines td { border: 1px solid #000; padding: 2px; font-size: 7px; line-height: 1.15; }
.invoice-lines th { background: #bfbfbf; text-align: center; font-weight: 800; height: 24px; }
.invoice-lines th:nth-child(1), .invoice-lines td:nth-child(1) { width: 43%; }
.invoice-lines th:nth-child(2), .invoice-lines td:nth-child(2) { width: 9%; }
.invoice-lines th:nth-child(3), .invoice-lines td:nth-child(3) { width: 9%; }
.invoice-lines th:nth-child(4), .invoice-lines td:nth-child(4) { width: 11%; }
.invoice-lines th:nth-child(5), .invoice-lines td:nth-child(5) { width: 14%; }
.invoice-lines th:nth-child(6), .invoice-lines td:nth-child(6) { width: 14%; }
.invoice-lines .section-row td { background: #bfbfbf; font-weight: 800; text-decoration: underline; height: 16px; }
.invoice-lines .blank-row td { height: 27px; }
.center { text-align: center; }
.article-count { border-left: 1px solid #000; border-right: 1px solid #000; padding: 2px 0; font-size: 8px; }
.invoice-total-table { width: 100%; border-collapse: collapse; margin-left: auto; }
.invoice-total-table td, .invoice-total-table th { border: 1px solid #000; padding: 2px 4px; font-size: 9px; }
.invoice-total-table td { text-align: right; width: 86%; }
.invoice-total-table th { text-align: right; width: 14%; }
.invoice-total-table .total-strong td, .invoice-total-table .total-strong th { font-weight: 800; }
.invoice-total-table .total-main td, .invoice-total-table .total-main th { background: #d9d9d9; font-size: 11px; font-weight: 900; }
.invoice-note { border: 1px solid #000; border-top: 0; padding: 3px 5px; font-size: 8px; line-height: 1.15; }
.invoice-note ul { margin: 4px 0 0 20px; padding: 0; }
.invoice-security-title { border-left: 1px solid #000; border-right: 1px solid #000; padding: 2px 8px; text-align: center; font-size: 8px; font-weight: 800; }
.invoice-security-title span { float: right; }
.invoice-security-box { border: 1px solid #000; display: grid; grid-template-columns: 146px 1fr; min-height: 100px; }
.invoice-qr { display: flex; align-items: center; justify-content: center; border-right: 1px solid #000; min-height: 100px; font-size: 12px; }
.invoice-qr img { width: 92px; height: 92px; }
.invoice-security-data { padding: 10px 8px; line-height: 1.35; font-size: 11px; }
.invoice-security-data .green { display: block; color: #00a529; text-align: center; margin-bottom: 8px; }
@media print {
  .invoice-actions { display: none; }
  .invoice-sheet { margin: 0; width: 718px; }
}
