:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #101828;
  --muted: #667085;
  --line: #d7e0ea;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --teal: #0f766e;
  --teal-dark: #0b5954;
  --amber: #b7791f;
  --red: #b42318;
  --nav: #101828;
  --nav-soft: #17213a;
  --ring: rgba(37, 99, 235, 0.16);
  --blue: #2563eb;
  --shadow: 0 18px 50px rgba(16, 24, 40, 0.08);
  --shadow-soft: 0 8px 24px rgba(16, 24, 40, 0.07);
  font-family: "Cairo", "Segoe UI", Tahoma, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 18px;
  background: #14231f;
  color: #eef7f5;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background: #0f766e;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-block strong,
.brand-block small {
  display: block;
}

.brand-block small,
.sync-panel small {
  color: #b7cbc7;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item,
.secondary-button,
.primary-button,
.danger-button {
  border: 0;
  border-radius: 8px;
  min-height: 42px;
  padding: 0 14px;
  font-weight: 700;
}

.nav-item {
  text-align: right;
  color: #d8e7e4;
  background: transparent;
}

.nav-item:hover,
.nav-item.is-active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.sync-panel {
  display: grid;
  gap: 10px;
  margin-top: auto;
}

.sync-details {
  display: grid;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
}

.sync-error-list {
  display: grid;
  gap: 10px;
}

.sync-error-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-soft);
}

.sync-error-item strong,
.sync-error-item small {
  display: block;
}

.main-area {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 18px;
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
}

h2 {
  margin-bottom: 4px;
  font-size: 18px;
}

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

.date-control,
.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.date-control span,
.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  min-height: 42px;
  padding: 9px 11px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.tab-view {
  display: none;
}

.tab-view.is-active {
  display: block;
}

.catalog-type-tabs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.catalog-admin-tabs {
  margin-bottom: 18px;
}

.doctor-search-tabs {
  align-self: end;
  margin-bottom: 0;
  white-space: nowrap;
}

.catalog-type-tab {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  padding: 10px 14px;
  cursor: pointer;
}

.catalog-type-tab.is-active {
  background: var(--primary);
  color: #ffffff;
}

.two-column-layout,
.doctor-layout,
.medicament-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 18px;
}

.reception-action-bar {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 260px));
  gap: 10px;
  margin-bottom: 18px;
}

.caisse-action-bar {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 12px;
}

.caisse-action-bar .danger-button {
  min-width: 190px;
}

.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.patients-management-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(0, 1.1fr);
  gap: 18px;
  align-items: start;
}

.doctor-layout {
  grid-template-columns: 330px minmax(0, 1fr);
  direction: ltr;
}

.doctor-layout > * {
  direction: rtl;
}

.panel {
  min-width: 0;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.panel-header p {
  margin-bottom: 0;
  font-size: 13px;
}

.stacked-form,
.workspace-panel {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.divided {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.form-grid,
.prescription-toolbar,
.caisse-grid,
.finance-grid,
.finance-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
}

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

#appointment-form .form-grid {
  grid-template-columns: minmax(82px, 0.85fr) minmax(124px, 1.25fr) minmax(76px, 0.7fr);
}

#appointment-form .form-grid input {
  padding-inline: 8px;
}

.prescription-toolbar {
  grid-template-columns: minmax(190px, 0.45fr) minmax(360px, 1fr);
  align-items: start;
}

.preset-field {
  align-self: start;
}

.catalog-search-card {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfefd;
}

.catalog-search-card:focus-within {
  border-color: rgba(15, 118, 110, 0.55);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.08);
}

.catalog-search-card[data-catalog-search-type="parapharmacy"] {
  background: #f8fcff;
}

.catalog-search-head {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  align-items: end;
  gap: 10px;
}

.catalog-search-field {
  min-width: 0;
}

.catalog-search-field input {
  min-height: 48px;
  font-size: 16px;
}

.catalog-search-card .med-results:not(:empty) {
  margin-top: 2px;
  border-color: rgba(15, 118, 110, 0.22);
}

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

.field-wide {
  grid-column: 1 / -1;
}

.primary-button {
  background: var(--primary);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--primary-dark);
}

.secondary-button {
  background: #e3efec;
  color: #17403b;
}

.danger-button {
  width: 100%;
  margin-top: 14px;
  background: #fee4e2;
  color: var(--red);
}

.action-row {
  display: flex;
  gap: 10px;
  justify-content: flex-start;
}

.toggle-field {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  color: var(--ink);
  font-weight: 800;
}

.toggle-field input {
  width: 42px;
  min-width: 42px;
  height: 24px;
  min-height: 24px;
  appearance: none;
  border: 0;
  border-radius: 999px;
  background: #cbd5d1;
  padding: 2px;
  transition: background 160ms ease;
}

.toggle-field input::before {
  content: "";
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(23, 33, 31, 0.18);
  transition: transform 160ms ease;
}

.toggle-field input:checked {
  background: var(--red);
}

.toggle-field input:checked::before {
  transform: translateX(-18px);
}

.status-pill,
.metric-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-ok {
  background: #dcfce7;
  color: #166534;
}

.status-warn {
  background: #fef3c7;
  color: #92400e;
}

.status-bad {
  background: #fee4e2;
  color: var(--red);
}

.metric-chip {
  background: #e0f2fe;
  color: #075985;
}

.queue-number {
  display: inline-grid;
  place-items: center;
  width: 36px;
  min-width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #14231f;
  color: #ffffff;
  font-weight: 900;
}

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

.table-status-row,
.patients-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

.patients-pagination {
  justify-content: center;
  margin-top: 12px;
  margin-bottom: 0;
}

.patients-pagination span {
  min-width: 120px;
  text-align: center;
  font-weight: 800;
  color: var(--text);
}

.patient-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 260px);
  gap: 12px;
  margin-bottom: 14px;
}

#tab-prescriptions .patient-tools {
  grid-template-columns: 1fr;
}

.file-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  cursor: pointer;
  opacity: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

#appointment-list table {
  min-width: 100%;
}

#appointment-list th,
#appointment-list td {
  padding: 11px 8px;
}

#appointment-list td.actions {
  white-space: normal;
}

#appointment-list .mini-button {
  margin-block: 2px;
  margin-inline-start: 3px;
  padding-inline: 8px;
}

#prescription-table table {
  min-width: 980px;
}

#finance-invoices-table table {
  min-width: 860px;
  table-layout: fixed;
}

.finance-invoices-table th:last-child,
.finance-invoices-table td.actions {
  width: 150px;
  min-width: 150px;
  text-align: center;
}

.finance-invoices-table td.actions {
  padding-inline: 12px;
}

.finance-invoices-table td.actions .mini-button {
  display: inline-flex;
  width: 126px;
  margin-inline-start: 0;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.finance-invoices-table th:nth-child(1),
.finance-invoices-table td:nth-child(1) {
  width: 115px;
}

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

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

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

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

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

.finance-ref strong,
.finance-patient strong {
  display: block;
  overflow-wrap: anywhere;
}

.finance-ref small,
.finance-patient small,
.finance-payment small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.finance-service {
  max-width: 220px;
  overflow-wrap: anywhere;
}

.finance-amount {
  white-space: nowrap;
  font-weight: 900;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
}

td.actions {
  white-space: nowrap;
}

tr.is-selected-row td {
  background: #effdf8;
}

.mini-button {
  min-height: 34px;
  margin-inline-start: 6px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
  font-weight: 700;
}

.mini-button.primary {
  background: #e6fffb;
  color: var(--primary-dark);
}

.mini-button.warn {
  background: #fff7ed;
  color: var(--amber);
}

.mini-button.danger {
  background: #fee4e2;
  color: var(--red);
}

.compact-list,
.history-list,
.prescription-archive-list,
.med-results {
  display: grid;
  gap: 8px;
}

.med-results:not(:empty) {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 8px;
  max-height: 360px;
  overflow-y: auto;
}

.med-results-shell {
  display: grid;
  gap: 8px;
}

.med-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px;
}

.med-results-header > div {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.list-row,
.history-row,
.med-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.payment-ready-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 78px;
  padding: 14px;
  color: var(--ink);
  text-align: right;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.payment-ready-row:hover,
.payment-ready-row:focus-visible,
.payment-ready-row.is-selected {
  border-color: rgba(183, 121, 31, 0.58);
  background: #fffaf0;
  box-shadow: 0 12px 28px rgba(23, 33, 31, 0.08);
  outline: 0;
  transform: translateY(-1px);
}

.payment-ready-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.payment-ready-main strong,
.payment-ready-main small {
  display: block;
  overflow-wrap: anywhere;
}

.payment-ready-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  background: #fff7ed;
  color: var(--amber);
  font-weight: 900;
  white-space: nowrap;
  pointer-events: none;
}

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

#quick-intake-form .form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.product-thumb {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: #ffffff;
}

.item-type-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  background: #e0f2fe;
  color: #075985;
  font-size: 12px;
  font-weight: 700;
}

.history-row.time-machine-row {
  display: grid;
  align-items: stretch;
  padding: 0;
  overflow: hidden;
}

.time-machine-row.is-active {
  border-color: var(--primary);
  background: #f0fdfa;
}

.history-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 0;
  padding: 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  text-align: right;
}

.history-trigger:hover {
  background: rgba(15, 118, 110, 0.07);
}

.history-trigger span {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.history-details {
  display: grid;
  gap: 10px;
  padding: 0 10px 10px;
  border-top: 1px solid var(--line);
}

.history-details ul {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.history-details li {
  padding: 8px;
  border-radius: 8px;
  background: #ffffff;
}

.replay-button {
  justify-self: start;
}

.archive-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.archive-meta-grid span {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.archive-meta-grid strong,
.archive-meta-grid small {
  display: block;
}

.archive-diagnosis {
  margin: 0;
  padding: 10px;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  overflow-wrap: anywhere;
}

/* ═══════════════════════════════════════════════════════
   ARCHIVE HERO
══════════════════════════════════════════════════════ */
.archive-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px;
  border-radius: 16px;
  background: linear-gradient(135deg, #0f766e 0%, #0b5954 55%, #134e4a 100%);
  box-shadow: 0 8px 32px rgba(15, 118, 110, 0.28);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.archive-hero-content {
  display: flex;
  align-items: center;
  gap: 16px;
}

.archive-hero-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.26);
  color: #ffffff;
  flex-shrink: 0;
}

.archive-hero-icon svg {
  width: 26px;
  height: 26px;
}

.archive-hero-title {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.25;
}

.archive-hero-sub {
  margin: 0;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.72);
  line-height: 1.5;
}

.archive-hero-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.archive-stat-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.26);
  color: #ffffff;
  backdrop-filter: blur(8px);
}

.archive-stat-pill svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.85;
}

.archive-stat-value {
  font-size: 20px;
  font-weight: 900;
  color: #ffffff;
  line-height: 1;
}

.archive-stat-label {
  font-size: 12px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.7);
}

.archive-refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.16s ease;
}

.archive-refresh-btn svg {
  width: 16px;
  height: 16px;
}

.archive-refresh-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: translateY(-1px);
}

.archive-refresh-btn:active svg {
  animation: spin 0.5s linear;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════
   ARCHIVE SEARCH BAR
══════════════════════════════════════════════════════ */
.archive-search-bar {
  margin-bottom: 20px;
}

.archive-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.archive-search-icon {
  position: absolute;
  right: 16px;
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
  flex-shrink: 0;
}

.archive-search-input {
  width: 100%;
  min-height: 48px;
  padding: 0 48px 0 16px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  outline: none;
}

.archive-search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.archive-search-input::placeholder {
  color: var(--muted);
}

/* ═══════════════════════════════════════════════════════
   ARCHIVE CARDS GRID
══════════════════════════════════════════════════════ */
.prescription-archive-list {
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  align-items: stretch;
  gap: 16px;
}

.prescription-archive-card {
  display: grid;
  gap: 0;
  min-height: 260px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 4px 20px rgba(23, 33, 31, 0.06);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
  cursor: pointer;
  overflow: hidden;
}

.prescription-archive-card:hover,
.prescription-archive-card:focus-visible {
  border-color: rgba(15, 118, 110, 0.45);
  box-shadow: 0 12px 40px rgba(15, 118, 110, 0.14);
  outline: 0;
  transform: translateY(-3px);
}

.prescription-archive-card.is-active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.18), 0 12px 40px rgba(15, 118, 110, 0.14);
  outline: 0;
}

.archive-card-stripe {
  height: 4px;
  background: linear-gradient(90deg, #0f766e, #2dd4bf);
}

.archive-card-inner {
  display: grid;
  gap: 14px;
  padding: 16px;
  flex: 1;
}

.archive-card-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.archive-avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #ccfbf1, #99f6e4);
  color: #0f766e;
  font-size: 17px;
  font-weight: 900;
  flex-shrink: 0;
  text-transform: uppercase;
}

.archive-patient-block {
  display: grid;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.archive-patient-block h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.archive-patient-block p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.archive-date-badge {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
}

.archive-date-badge strong {
  display: block;
  font-size: 12px;
  font-weight: 800;
  color: var(--primary-dark);
  white-space: nowrap;
}

.archive-date-badge small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.archive-card-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.archive-card-meta span {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.archive-card-meta small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.archive-card-meta strong {
  overflow: hidden;
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.archive-card-diagnosis {
  display: -webkit-box;
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f0fdfa;
  border-right: 3px solid #2dd4bf;
  overflow: hidden;
  color: #134e4a;
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.archive-medicine-preview {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 28px;
}

.archive-medicine-preview span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
  font-size: 11px;
  font-weight: 800;
}

.archive-reference-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  font-family: monospace;
}

.archive-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px 12px;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
}

.archive-open-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-inline-start: 0;
  font-size: 13px;
}

.archive-open-chip::after {
  content: '←';
  font-size: 14px;
}

/* Archive table layout */
.prescription-archive-list {
  display: block;
}

.archive-table-shell {
  overflow-x: hidden;
  border-top: 3px solid var(--primary);
  border-radius: 8px;
  background: #ffffff;
  direction: ltr;
}

.prescription-archive-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
  direction: rtl;
}

.archive-col-ref {
  width: 8%;
}

.archive-col-patient {
  width: 25%;
}

.archive-col-date {
  width: 15%;
}

.archive-col-visit {
  width: 18%;
}

.archive-col-status {
  width: 12%;
}

.archive-col-actions {
  width: 22%;
}

.prescription-archive-table th {
  padding: 13px 14px;
  background: #f8fafc;
  color: #1f2937;
  font-size: 14px;
  font-weight: 900;
  text-align: right;
}

.prescription-archive-table td {
  padding: 14px;
  vertical-align: middle;
}

.prescription-archive-row {
  cursor: pointer;
  transition: background 150ms ease, box-shadow 150ms ease;
}

.prescription-archive-row:hover td,
.prescription-archive-row:focus-visible td {
  background: #f8fbff;
}

.prescription-archive-row.is-active td {
  background: #eff6ff;
}

.archive-ref-cell {
  text-align: center;
}

.archive-ref-cell strong {
  display: inline-grid;
  place-items: center;
  min-width: 42px;
  min-height: 38px;
  border-radius: 8px;
  background: #111827;
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(16, 24, 40, 0.18);
}

.archive-ref-cell small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  max-width: 76px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.archive-patient-cell strong,
.archive-visit-cell strong,
.archive-date-cell strong {
  display: block;
  color: #111827;
  font-size: 15px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.archive-patient-cell small,
.archive-visit-cell small,
.archive-date-cell small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.archive-actions-cell {
  text-align: left;
  white-space: normal;
}

.archive-action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  margin: 2px;
  min-width: 58px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.archive-action-button:hover {
  transform: translateY(-1px);
}

.archive-action-details {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.archive-action-print {
  border-color: #bbf7d0;
  background: #15803d;
  color: #ffffff;
}

.archive-action-patient {
  border-color: #cbd5e1;
  background: #ffffff;
  color: #334155;
}

.archive-action-button:disabled {
  background: #f1f5f9;
  color: #94a3b8;
}

.archive-modal-actions .primary-button,
.archive-modal-actions .secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border-radius: 8px;
  padding: 0 14px;
}

/* ═══════════════════════════════════════════════════════
   ARCHIVE MODAL — PREMIUM
══════════════════════════════════════════════════════ */
.archive-modal-panel {
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(960px, 100%);
  padding: 0;
  overflow: hidden;
  border-radius: 20px;
}

.archive-modal-header {
  align-items: flex-start;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, #0f766e 0%, #0b5954 100%);
}

.archive-modal-header > div {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.archive-modal-header h2 {
  color: #ffffff;
  font-size: 20px;
}

.archive-modal-header p {
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.archive-modal-header .icon-button {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.3);
  color: #ffffff;
}

.archive-modal-header .icon-button:hover {
  background: rgba(255, 255, 255, 0.28);
}

.modal-kicker {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  width: fit-content;
}

.archive-modal-body {
  display: grid;
  gap: 14px;
  min-width: 0;
  padding: 18px;
  overflow-y: auto;
}

.archive-modal-summary {
  display: grid;
  grid-template-columns: 2fr repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.archive-modal-summary > div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(145deg, #f7faf9, #ffffff);
  box-shadow: 0 2px 8px rgba(23, 33, 31, 0.04);
}

.archive-modal-summary span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.archive-modal-summary strong {
  overflow: hidden;
  font-size: 18px;
  font-weight: 900;
  overflow-wrap: anywhere;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
}

.archive-modal-meta {
  margin-top: 0;
}

.archive-modal-meta small,
.archive-item-main strong,
.archive-item-main small {
  overflow-wrap: anywhere;
}

.archive-modal-diagnosis {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid #a7f3d0;
  background: #f0fdfa;
  border-right: 4px solid #0f766e;
}

.archive-modal-diagnosis strong {
  font-size: 13px;
  color: #065f46;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.archive-modal-diagnosis p {
  margin: 0;
  color: #134e4a;
  line-height: 1.7;
  font-size: 14px;
}

.archive-prescription-section {
  display: grid;
  gap: 12px;
}

.archive-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.archive-section-title strong {
  font-size: 15px;
  font-weight: 800;
}

.archive-section-title small {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.archive-modal-items {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.archive-modal-item {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.archive-modal-item:hover {
  border-color: rgba(15, 118, 110, 0.3);
  box-shadow: 0 4px 16px rgba(15, 118, 110, 0.08);
}

.archive-item-index {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #ccfbf1, #99f6e4);
  color: #0f766e;
  font-weight: 900;
  font-size: 14px;
  white-space: nowrap;
}

.archive-item-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.archive-item-main small {
  color: var(--muted);
  line-height: 1.55;
}

.archive-modal-actions {
  justify-content: flex-start;
  gap: 10px;
  margin: 0;
  padding: 14px 24px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
  flex-wrap: wrap;
}

.med-choice {
  align-items: stretch;
}

.med-choice-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.med-choice-main input {
  width: auto;
  min-height: 0;
}

.med-choice-main span {
  min-width: 0;
}

.med-choice.is-muted {
  opacity: 0.62;
}

.mini-button:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.list-row strong,
.history-row strong,
.med-row strong {
  display: block;
}

.list-row small,
.history-row small,
.med-row small,
.current-patient small {
  color: var(--muted);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 84px;
  border: 1px dashed #a8bdb8;
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-soft);
  text-align: center;
}

/* Archive empty state */
.archive-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 300px;
  padding: 48px 24px;
  border: 2px dashed var(--line);
  border-radius: 16px;
  background: var(--surface-soft);
  text-align: center;
  grid-column: 1 / -1;
}

.archive-empty-icon {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: linear-gradient(135deg, #ccfbf1, #99f6e4);
  color: #0f766e;
}

.archive-empty-icon svg {
  width: 36px;
  height: 36px;
}

.archive-empty-title {
  display: block;
  font-size: 18px;
  font-weight: 800;
  color: var(--ink);
}

.archive-empty-desc {
  margin: 0;
  max-width: 360px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.patient-profile-panel {
  display: grid;
  gap: 14px;
}

.patient-profile-panel.empty-state {
  display: grid;
}

.patient-profile-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f0fdfa;
}

.patient-profile-card strong,
.patient-profile-card small {
  display: block;
}

.patient-profile-card small {
  color: var(--muted);
}

.patient-profile-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.patient-profile-stats span {
  min-height: 28px;
  padding: 3px 9px;
  border: 1px solid #bbddd8;
  border-radius: 999px;
  background: #ffffff;
  color: #17403b;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.profile-section {
  display: grid;
  gap: 10px;
}

.profile-section h3 {
  margin: 0;
  font-size: 15px;
}

.profile-section p {
  margin: 0;
  padding: 10px;
  border: 1px dashed #c8d8d4;
  border-radius: 8px;
  background: var(--surface-soft);
  text-align: center;
}

.profile-row {
  align-items: flex-start;
}

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

.profile-actions .mini-button {
  margin-inline-start: 0;
}

.current-patient {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f0fdfa;
}

.patient-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.current-patient.empty-state {
  display: grid;
  background: var(--surface-soft);
}

.posology-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.posology-bar button {
  min-height: 34px;
  border: 1px solid #c7d7d4;
  border-radius: 999px;
  background: #ffffff;
  color: #17403b;
  font-weight: 800;
}

.medicine-title-cell {
  min-width: 220px;
}

.dose-input {
  width: 76px;
  min-width: 76px;
  text-align: center;
}

.duration-control {
  display: grid;
  grid-template-columns: 72px auto;
  align-items: center;
  gap: 6px;
}

.duration-control input {
  min-width: 72px;
  text-align: center;
}

.duration-control span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 90px 140px 100px auto;
  gap: 8px;
  align-items: end;
}

.caisse-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
}

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

.finance-filters {
  grid-template-columns: repeat(5, minmax(0, 1fr)) auto;
  align-items: end;
}

.filter-actions {
  display: flex;
  gap: 8px;
  align-items: end;
}

.finance-layout {
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
}

.print-block {
  margin: 8mm 0;
}

.print-total {
  margin-top: 8mm;
  text-align: left;
}

.metric-card {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

.toast {
  position: fixed;
  z-index: 20;
  left: 24px;
  bottom: 24px;
  max-width: min(380px, calc(100vw - 48px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #14231f;
  color: #ffffff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.is-warning {
  border: 1px solid #fed7aa;
  background: #fff7ed;
  color: #7c2d12;
}

.toast.is-error {
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.toast.is-success {
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  color: #14532d;
}

.is-hidden {
  display: none !important;
}

.soft-alert {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid #fde68a;
  border-radius: 8px;
  background: #fffbeb;
  color: #7c2d12;
}

.soft-alert strong,
.soft-alert span {
  display: block;
}

.settings-panel {
  max-width: 820px;
}

.offline-settings {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.offline-settings strong,
.offline-settings small {
  display: block;
}

.offline-settings small {
  color: var(--muted);
}

.radio-card-group {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
}

.radio-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.radio-card input {
  width: 18px;
  min-width: 18px;
  min-height: 18px;
}

.radio-card strong,
.radio-card small {
  display: block;
}

.radio-card small {
  color: var(--muted);
}

.modal-open {
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(20, 35, 31, 0.54);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-panel {
  display: grid;
  gap: 16px;
  width: min(820px, 100%);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.modal-panel-small {
  width: min(420px, 100%);
}

.edit-form-modal-panel {
  width: min(760px, calc(100vw - 28px));
}

.patient-profile-modal-panel {
  width: min(860px, calc(100vw - 28px));
}

.patient-delete-modal-panel {
  width: min(720px, calc(100vw - 28px));
}

.patient-delete-modal-body {
  display: grid;
  gap: 14px;
}

.patient-delete-modal-actions {
  justify-content: flex-start;
  gap: 10px;
  margin: 0;
  padding-top: 4px;
  flex-wrap: wrap;
}

.patient-delete-warning {
  margin: 0;
}

.delete-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.delete-summary-grid span {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.delete-summary-grid strong {
  color: var(--ink);
  font-size: 18px;
}

.delete-summary-grid small,
.delete-modal-note {
  color: var(--muted);
}

.delete-modal-note {
  margin: 0;
  line-height: 1.7;
}

@media (max-width: 640px) {
  .delete-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.edit-form-modal-body {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.edit-form-modal-body .stacked-form {
  width: 100%;
  min-width: 0;
}

.modal-edit-form {
  margin: 0;
  padding: 0;
  border: 0;
}

.form-helper {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.appointment-patient-picker {
  display: grid;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.appointment-patient-picker[hidden],
.appointment-patient-picker.is-hidden {
  display: none !important;
}

.appointment-patient-results {
  max-height: 260px;
  overflow: auto;
}

.appointment-patient-row {
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.appointment-patient-row:hover,
.appointment-patient-row:focus-visible {
  border-color: #7fb7ad;
  background: #f0fdfa;
  box-shadow: 0 10px 24px rgba(23, 33, 31, 0.08);
  outline: 0;
}

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

.modal-header h2 {
  margin: 0;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 20px;
  font-weight: 900;
}

.print-sheet {
  display: none;
}

/* 2026 interface refresh */
.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

body {
  background:
    linear-gradient(180deg, #f7f9fc 0%, #eef3f8 100%);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

.app-shell {
  grid-template-columns: 300px minmax(0, 1fr);
  background: transparent;
}

.side-nav {
  position: sticky;
  top: 0;
  height: 100vh;
  gap: 18px;
  padding: 22px 18px;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  background:
    linear-gradient(180deg, var(--nav) 0%, var(--nav-soft) 58%, #0b1220 100%);
  box-shadow: -12px 0 30px rgba(16, 24, 40, 0.16);
}

.brand-block {
  min-height: 72px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-color: rgba(255, 255, 255, 0.18);
  background: linear-gradient(135deg, var(--primary), var(--teal));
  color: #ffffff;
  box-shadow: 0 12px 24px rgba(15, 118, 110, 0.26);
}

.brand-block strong {
  color: #ffffff;
  font-size: 15px;
  line-height: 1.35;
}

.brand-block small,
.sync-panel small {
  color: #b8c4d6;
}

.nav-list {
  gap: 6px;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid transparent;
  color: #cbd5e1;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.nav-icon,
.button-icon,
.archive-refresh-btn svg {
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item:hover {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.nav-item.is-active {
  border-color: rgba(255, 255, 255, 0.16);
  background: linear-gradient(135deg, var(--primary), #5b7cfa);
  color: #ffffff;
  box-shadow: 0 12px 26px rgba(37, 99, 235, 0.28);
}

.nav-item.is-active::after {
  content: "";
  position: absolute;
  inset-block: 10px;
  inset-inline-end: -1px;
  width: 3px;
  border-radius: 6px;
  background: #facc15;
}

.sync-panel {
  gap: 9px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.side-nav .secondary-button {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.main-area {
  gap: 20px;
  padding: 28px;
}

.topbar {
  min-height: 92px;
  padding: 20px 22px;
  border: 1px solid rgba(215, 224, 234, 0.88);
  background: linear-gradient(135deg, #ffffff 0%, #f7fbff 100%);
  box-shadow: var(--shadow-soft);
}

.eyebrow {
  color: var(--primary);
  letter-spacing: 0;
}

h1 {
  color: #0f172a;
  font-size: 30px;
  line-height: 1.2;
}

h2 {
  color: #1d2939;
  line-height: 1.35;
}

p {
  line-height: 1.65;
}

.date-control {
  min-width: 230px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.date-control input {
  min-height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

input,
select,
textarea {
  min-height: 44px;
  border-color: #cfd8e3;
  background: #ffffff;
  box-shadow: 0 1px 0 rgba(16, 24, 40, 0.02);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #b7c4d3;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--ring);
}

input[name="reason"],
input[name="category"],
input[name="method"] {
  direction: ltr;
  text-align: left;
}

.primary-button,
.secondary-button,
.danger-button,
.mini-button,
.catalog-type-tab,
.archive-refresh-btn,
.posology-bar button {
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.primary-button {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.22);
}

.primary-button:hover {
  background: linear-gradient(135deg, #1f5de8, #1747bd);
  box-shadow: 0 12px 26px rgba(37, 99, 235, 0.28);
  transform: translateY(-1px);
}

.secondary-button {
  border: 1px solid #cfd8e3;
  background: #ffffff;
  color: #1d2939;
}

.secondary-button:hover,
.mini-button:hover,
.posology-bar button:hover {
  border-color: #b7c4d3;
  background: #f8fafc;
  transform: translateY(-1px);
}

.danger-button {
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: var(--red);
}

.action-button {
  min-height: 48px;
  padding-inline: 18px;
}

.button-icon {
  width: 18px;
  height: 18px;
  flex-basis: 18px;
}

.catalog-type-tabs {
  border-color: var(--line);
  background: #eef4fb;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.catalog-type-tab {
  color: #475467;
}

.catalog-type-tab.is-active {
  background: #ffffff;
  color: var(--primary-dark);
  box-shadow: 0 6px 16px rgba(16, 24, 40, 0.08);
}

.panel,
.metric-card,
.modal-panel {
  border-color: rgba(215, 224, 234, 0.9);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-soft);
}

.panel {
  padding: 20px;
}

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

.panel-header p {
  color: #667085;
}

.metric-card {
  position: relative;
  overflow: hidden;
  padding: 18px;
}

.metric-card::before {
  content: "";
  position: absolute;
  inset-inline: 0;
  top: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--teal), #f59e0b);
}

.metric-card strong {
  color: #0f172a;
  letter-spacing: 0;
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: inset 0 1px 0 rgba(16, 24, 40, 0.02);
}

.table-wrap .empty-state {
  border: 0;
  border-radius: 0;
  background: #fbfdff;
}

table {
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  padding: 13px 12px;
  border-bottom-color: #e4eaf1;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: #475467;
  font-weight: 900;
  letter-spacing: 0;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: #f8fbff;
}

tr.is-selected-row td {
  background: #eef6ff;
}

.queue-number {
  background: linear-gradient(135deg, #111827, #24304c);
  box-shadow: 0 8px 18px rgba(16, 24, 40, 0.16);
}

.mini-button {
  min-height: 34px;
  border-color: #cfd8e3;
  background: #ffffff;
  color: #344054;
}

.mini-button.primary {
  border-color: rgba(37, 99, 235, 0.22);
  background: #eff6ff;
  color: var(--primary-dark);
}

.mini-button.warn {
  border-color: #fed7aa;
  background: #fff7ed;
  color: var(--amber);
}

.mini-button.danger {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--red);
}

.status-pill,
.metric-chip {
  min-height: 30px;
  border: 1px solid transparent;
  letter-spacing: 0;
}

.status-ok {
  border-color: #bbf7d0;
  background: #ecfdf3;
  color: #067647;
}

.status-warn {
  border-color: #fedf89;
  background: #fffaeb;
  color: #b54708;
}

.status-bad {
  border-color: #fecdca;
  background: #fef3f2;
  color: #b42318;
}

.metric-chip {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.list-row,
.history-row,
.med-row,
.patient-profile-card,
.current-patient,
.radio-card {
  border-color: #dce5ef;
  background: #ffffff;
  box-shadow: 0 6px 16px rgba(16, 24, 40, 0.04);
}

.list-row:hover,
.history-row:hover,
.med-row:hover {
  border-color: #bfd0e4;
  background: #f8fbff;
}

.current-patient,
.patient-profile-card {
  background: linear-gradient(135deg, #eff6ff, #f0fdfa);
}

.empty-state {
  border-color: #b8c5d6;
  background: #f8fafc;
}

.soft-alert {
  border-color: #fedf89;
  background: #fffaeb;
}

.toast {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: #0f172a;
  box-shadow: 0 18px 42px rgba(16, 24, 40, 0.22);
}

.modal-backdrop {
  background: rgba(15, 23, 42, 0.62);
  backdrop-filter: blur(8px);
}

.modal-panel,
.archive-modal-panel {
  border-radius: 8px;
}

.icon-button {
  border-color: #d0d9e6;
  background: #ffffff;
}

.archive-hero {
  border-radius: 8px;
  background: linear-gradient(135deg, #1d4ed8 0%, #0f766e 100%);
  box-shadow: 0 14px 34px rgba(37, 99, 235, 0.18);
}

.archive-hero-icon,
.archive-stat-pill,
.archive-refresh-btn,
.prescription-archive-card,
.archive-avatar,
.archive-card-meta span,
.archive-modal-summary > div,
.archive-modal-diagnosis,
.archive-modal-item,
.archive-item-index,
.archive-empty-state,
.archive-empty-icon {
  border-radius: 8px;
}

.prescription-archive-card {
  box-shadow: var(--shadow-soft);
}

.archive-card-stripe {
  background: linear-gradient(90deg, var(--primary), var(--teal), #f59e0b);
}

.archive-card-meta small,
.modal-kicker,
.archive-modal-summary span,
.archive-modal-diagnosis strong,
.archive-reference-pill {
  letter-spacing: 0;
}

.archive-modal-header {
  background: linear-gradient(135deg, #1d4ed8 0%, #0f766e 100%);
}

.offline-settings {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

#tab-prescriptions .archive-hero {
  padding: 0 0 14px;
  border-radius: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  box-shadow: none;
}

#tab-prescriptions .archive-hero-icon {
  width: 44px;
  height: 44px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: var(--primary-dark);
}

#tab-prescriptions .archive-hero-title {
  color: #111827;
}

#tab-prescriptions .archive-hero-sub {
  color: var(--muted);
}

#tab-prescriptions .archive-stat-pill {
  border: 1px solid var(--line);
  background: #ffffff;
  color: #111827;
  backdrop-filter: none;
}

#tab-prescriptions .archive-stat-pill svg,
#tab-prescriptions .archive-stat-value {
  color: var(--primary-dark);
}

#tab-prescriptions .archive-stat-label {
  color: var(--muted);
}

#tab-prescriptions .archive-refresh-btn {
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: var(--primary-dark);
}

#tab-prescriptions .archive-refresh-btn:hover {
  background: #dbeafe;
}

@media (max-width: 1100px) {
  .app-shell,
  .two-column-layout,
  .reception-action-bar,
  .doctor-layout,
  .medicament-layout,
  .patients-management-layout,
  .caisse-grid,
  .finance-grid,
  .finance-filters,
  .finance-layout {
    grid-template-columns: 1fr;
  }

  .side-nav {
    position: sticky;
    top: 0;
    z-index: 10;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }

  .nav-list {
    display: flex;
    min-width: max-content;
  }

  .sync-panel {
    margin-top: 0;
    min-width: 190px;
  }

  .form-grid,
  .catalog-form-grid,
  .prescription-toolbar,
  .finance-filters,
  .inline-form,
  .patient-tools {
    grid-template-columns: 1fr;
  }

  .catalog-search-head {
    grid-template-columns: 1fr;
  }

  .doctor-search-tabs {
    justify-self: stretch;
  }

  .doctor-search-tabs .catalog-type-tab {
    flex: 1;
  }

  .field-wide {
    grid-column: auto;
  }

  .prescription-archive-table {
    min-width: 760px;
  }

  .archive-table-shell {
    overflow-x: auto;
  }
}

@media (max-width: 720px) {
  .main-area {
    padding: 14px;
  }

  .prescription-archive-list,
  .archive-card-meta,
  .archive-modal-summary {
    grid-template-columns: 1fr;
  }

  .archive-card-head {
    flex-wrap: wrap;
  }

  .archive-date-badge {
    align-items: flex-start;
  }

  .archive-hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .archive-hero-stats {
    width: 100%;
  }

  .archive-meta-grid {
    grid-template-columns: 1fr;
  }

  .archive-modal-panel {
    max-height: calc(100vh - 28px);
    border-radius: 14px;
  }

  .archive-modal-actions {
    align-items: stretch;
  }

  .topbar,
  .panel-header,
  .current-patient,
  .patient-profile-card,
  .profile-row,
  .action-row {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 22px;
  }
}

@media (max-width: 1100px) {
  .app-shell {
    display: block;
  }

  .side-nav {
    height: auto;
    padding: 12px;
    border-left: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 12px 28px rgba(16, 24, 40, 0.14);
  }

  .brand-block {
    min-width: 220px;
    min-height: 58px;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
  }

  .nav-item {
    min-width: max-content;
    min-height: 44px;
  }

  .sync-panel {
    min-width: 220px;
  }

  .main-area {
    padding: 20px;
  }
}

@media (max-width: 720px) {
  .side-nav {
    gap: 10px;
  }

  .brand-block,
  .sync-panel {
    min-width: 260px;
  }

  .topbar {
    min-height: 0;
    padding: 16px;
  }

  .date-control {
    min-width: 0;
    width: 100%;
  }

  .panel,
  .metric-card {
    padding: 16px;
  }

  .table-wrap {
    margin-inline: -2px;
  }

  .archive-modal-panel {
    border-radius: 8px;
  }
}

/* Professional clinical operations refresh */
:root {
  --bg: #f5f8f7;
  --surface: #ffffff;
  --surface-soft: #f8fbfa;
  --ink: #16211f;
  --muted: #61716d;
  --line: #d8e2de;
  --primary: #146c63;
  --primary-dark: #0e564f;
  --teal: #297b72;
  --teal-dark: #1f625b;
  --amber: #b7791f;
  --red: #b42318;
  --nav: #0f1e1b;
  --nav-soft: #172a25;
  --ring: rgba(20, 108, 99, 0.18);
  --blue: #146c63;
  --rail: #d49a2a;
  --shadow: 0 18px 40px rgba(22, 33, 31, 0.08);
  --shadow-soft: 0 10px 24px rgba(22, 33, 31, 0.06);
}

html {
  overflow-x: hidden;
  background: var(--bg);
  font-family: "Cairo", "Segoe UI", Tahoma, Arial, sans-serif;
}

body {
  overflow-x: hidden;
  background:
    linear-gradient(180deg, #fbfdfc 0%, var(--bg) 44%, #edf4f1 100%);
  color: var(--ink);
  font-family: "Cairo", "Segoe UI", Tahoma, Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}

button,
input,
select,
textarea {
  font-family: "Cairo", "Segoe UI", Tahoma, Arial, sans-serif;
}

.app-shell {
  width: 100%;
  max-width: 100vw;
  grid-template-columns: 288px minmax(0, 1fr);
  overflow-x: clip;
  background: transparent;
}

.side-nav {
  gap: 16px;
  padding: 20px 16px;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, var(--nav) 0%, var(--nav-soft) 62%, #0b1715 100%);
  box-shadow: -10px 0 28px rgba(22, 33, 31, 0.14);
}

.brand-block {
  min-height: 66px;
  padding: 10px;
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.055);
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-color: rgba(255, 255, 255, 0.18);
  background: #146c63;
  box-shadow: inset 0 -10px 18px rgba(11, 23, 21, 0.16), 0 10px 20px rgba(20, 108, 99, 0.2);
}

.brand-block strong {
  font-size: 15px;
  letter-spacing: 0;
}

.brand-block small,
.sync-panel small {
  color: #adc5bf;
}

.nav-list {
  gap: 5px;
}

.nav-item {
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #d2dfdc;
}

.nav-item:hover {
  border-color: rgba(255, 255, 255, 0.11);
  background: rgba(255, 255, 255, 0.07);
}

.nav-item.is-active {
  border-color: rgba(212, 154, 42, 0.38);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: inset 4px 0 0 var(--rail), 0 12px 24px rgba(7, 14, 13, 0.18);
}

.nav-item.is-active::after {
  content: none;
}

.sync-panel {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.055);
}

.side-nav .secondary-button {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.09);
}

.main-area {
  min-width: 0;
  max-width: 100%;
  gap: 18px;
  padding: 24px;
  overflow-x: clip;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(210px, auto);
  min-height: 84px;
  padding: 18px 20px;
  border-color: rgba(216, 226, 222, 0.92);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-soft);
}

.eyebrow {
  color: var(--primary);
  font-size: 11px;
  letter-spacing: 0;
}

h1 {
  color: var(--ink);
  font-size: 28px;
}

h2 {
  color: #1c2b28;
  font-size: 17px;
}

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

.date-control {
  min-width: 210px;
  border-color: var(--line);
  background: var(--surface-soft);
}

input,
select,
textarea {
  min-height: 42px;
  border-color: #cfdbd7;
  background: #ffffff;
  color: var(--ink);
  box-shadow: none;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #b9cac5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--ring);
}

.primary-button {
  background: var(--primary);
  box-shadow: 0 10px 20px rgba(20, 108, 99, 0.18);
}

.primary-button:hover {
  background: var(--primary-dark);
  box-shadow: 0 12px 22px rgba(20, 108, 99, 0.22);
}

.secondary-button {
  border: 1px solid #cbd9d4;
  background: #ffffff;
  color: #20322e;
}

.secondary-button:hover,
.mini-button:hover,
.posology-bar button:hover {
  border-color: #b5c8c2;
  background: #f7faf9;
}

.danger-button {
  border: 1px solid #f6c6c1;
  background: #fff6f5;
}

.action-button {
  min-height: 46px;
}

.catalog-type-tabs {
  border-color: #cfdbd7;
  background: #eef5f2;
}

.catalog-type-tab {
  min-height: 38px;
  color: #536560;
}

.catalog-type-tab.is-active {
  background: #ffffff;
  color: var(--primary-dark);
  box-shadow: 0 6px 14px rgba(22, 33, 31, 0.08);
}

.tab-view {
  min-width: 0;
  max-width: 100%;
}

.tab-view.is-active {
  min-width: 0;
}

.panel,
.metric-card,
.modal-panel {
  min-width: 0;
  border-color: rgba(216, 226, 222, 0.95);
  background: rgba(255, 255, 255, 0.97);
  box-shadow: var(--shadow-soft);
}

.panel {
  padding: 18px;
}

.panel-header {
  margin-bottom: 14px;
}

.panel-header p {
  color: var(--muted);
  font-size: 13px;
}

.two-column-layout,
.doctor-layout,
.medicament-layout,
.patients-management-layout,
.finance-layout {
  min-width: 0;
}

.medicament-layout {
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.55fr);
}

.catalog-form-grid {
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
}

#appointment-form .form-grid {
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.25fr) minmax(0, 0.75fr);
}

#appointment-form .form-grid input {
  min-width: 0;
}

.form-grid,
.prescription-toolbar,
.caisse-grid,
.finance-grid,
.finance-filters,
.inline-form,
.patient-tools,
.catalog-search-head {
  min-width: 0;
}

.metric-card {
  padding: 16px;
  border-top: 3px solid var(--line);
}

.metric-card::before {
  content: none;
}

.metric-card span {
  color: var(--muted);
  font-size: 12px;
}

.metric-card strong {
  color: var(--ink);
  font-size: 26px;
  font-weight: 900;
}

.finance-grid .metric-card:nth-child(1),
.finance-grid .metric-card:nth-child(2),
.caisse-grid .metric-card:nth-child(1) {
  border-top-color: var(--primary);
}

.finance-grid .metric-card:nth-child(3),
.finance-grid .metric-card:nth-child(4),
.caisse-grid .metric-card:nth-child(2) {
  border-top-color: var(--rail);
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border-color: var(--line);
  background: #ffffff;
  box-shadow: inset 0 1px 0 rgba(22, 33, 31, 0.03);
}

table {
  max-width: none;
}

th,
td {
  padding: 12px 11px;
  border-bottom-color: #e4ebe8;
}

th {
  background: #f5f8f7;
  color: #536560;
  font-size: 11px;
  font-weight: 900;
}

tbody tr:hover td {
  background: #f8fbfa;
}

tr.is-selected-row td {
  background: #edf7f4;
}

.queue-number {
  background: var(--primary);
  box-shadow: 0 8px 16px rgba(20, 108, 99, 0.18);
}

.mini-button {
  border-color: #cbd9d4;
  background: #ffffff;
}

.mini-button.primary {
  border-color: rgba(20, 108, 99, 0.22);
  background: #eef8f5;
  color: var(--primary-dark);
}

.mini-button.warn {
  border-color: #f1d09b;
  background: #fff9ef;
}

.mini-button.danger {
  border-color: #f6c6c1;
  background: #fff6f5;
}

.status-ok {
  border-color: #b9e6cf;
  background: #edf9f2;
  color: #0b6b42;
}

.status-warn,
.soft-alert {
  border-color: #efd39a;
  background: #fff9eb;
  color: #8a4d0f;
}

.status-bad {
  border-color: #f4b7b0;
  background: #fff4f2;
}

.metric-chip {
  border-color: #bdd8d1;
  background: #eef8f5;
  color: var(--primary-dark);
}

.list-row,
.history-row,
.med-row,
.patient-profile-card,
.current-patient,
.radio-card,
.payment-ready-row {
  border-color: #dce7e3;
  background: #ffffff;
  box-shadow: 0 6px 14px rgba(22, 33, 31, 0.04);
}

.list-row:hover,
.history-row:hover,
.med-row:hover,
.payment-ready-row:hover,
.payment-ready-row:focus-visible,
.payment-ready-row.is-selected {
  border-color: #b8cec8;
  background: #f8fbfa;
  box-shadow: 0 10px 22px rgba(22, 33, 31, 0.06);
}

.payment-ready-row:hover,
.payment-ready-row:focus-visible,
.payment-ready-row.is-selected {
  border-color: rgba(183, 121, 31, 0.58);
  background: #fffaf0;
}

.current-patient,
.patient-profile-card {
  background: linear-gradient(135deg, #f2faf7, #ffffff);
}

.empty-state {
  border-color: #cbd9d4;
  background: #f8fbfa;
  color: var(--muted);
}

.toast {
  border-color: rgba(255, 255, 255, 0.12);
  background: #132320;
  box-shadow: 0 18px 36px rgba(22, 33, 31, 0.22);
}

.modal-backdrop {
  background: rgba(15, 30, 27, 0.58);
  backdrop-filter: blur(8px);
}

.modal-panel,
.archive-modal-panel {
  border-color: var(--line);
}

.archive-hero {
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow-soft);
}

#tab-prescriptions .archive-hero {
  border-bottom-color: var(--line);
}

.archive-hero-icon,
#tab-prescriptions .archive-hero-icon {
  border-color: #bdd8d1;
  background: #eef8f5;
  color: var(--primary-dark);
}

.archive-hero-title,
#tab-prescriptions .archive-hero-title {
  color: var(--ink);
}

.archive-hero-sub,
#tab-prescriptions .archive-hero-sub {
  color: var(--muted);
}

.archive-stat-pill,
#tab-prescriptions .archive-stat-pill,
.archive-refresh-btn,
#tab-prescriptions .archive-refresh-btn {
  border-color: var(--line);
  background: #ffffff;
  color: var(--primary-dark);
  backdrop-filter: none;
}

.archive-card-stripe {
  background: var(--primary);
}

.archive-modal-header {
  background: #f2faf7;
  color: var(--ink);
}

.archive-modal-header h2,
.archive-modal-header p,
.archive-modal-header .modal-kicker {
  color: inherit;
}

.offline-settings {
  border-color: var(--line);
  background: #f8fbfa;
}

.file-button input {
  width: 100%;
  height: 100%;
  font-size: 0;
}

@media (max-width: 1100px) {
  .app-shell {
    display: block;
    overflow-x: clip;
  }

  .side-nav {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(160px, auto);
    height: auto;
    gap: 10px;
    padding: 10px 12px;
    overflow: visible;
    border-left: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 12px 24px rgba(22, 33, 31, 0.14);
  }

  .brand-block {
    min-width: 0;
    min-height: 54px;
  }

  .sync-panel {
    min-width: 0;
    margin-top: 0;
    padding: 8px;
  }

  .nav-list {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    min-width: 0;
    overflow: visible;
  }

  .nav-item {
    justify-content: center;
    min-width: 0;
    min-height: 42px;
    padding: 0 8px;
  }

  .nav-item span {
    white-space: normal;
    text-align: center;
    line-height: 1.2;
  }

  .main-area {
    padding: 18px;
  }

  .medicament-layout,
  .two-column-layout,
  .doctor-layout,
  .patients-management-layout,
  .caisse-grid,
  .finance-grid,
  .finance-filters,
  .finance-layout,
  .prescription-toolbar,
  .patient-tools,
  .inline-form,
  .catalog-search-head {
    grid-template-columns: 1fr;
  }

  .catalog-form-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }
}

@media (max-width: 720px) {
  .edit-form-modal-panel {
    width: min(100%, calc(100vw - 20px));
    max-height: calc(100vh - 20px);
  }

  .side-nav {
    position: sticky;
    top: 0;
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .brand-block {
    width: 100%;
  }

  .sync-panel {
    display: none;
  }

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

  .nav-item {
    flex-direction: column;
    gap: 4px;
    min-height: 56px;
    font-size: 11px;
  }

  .nav-icon {
    width: 17px;
    height: 17px;
    flex-basis: 17px;
  }

  .main-area {
    padding: 14px;
  }

  .topbar {
    grid-template-columns: 1fr;
    gap: 12px;
    min-height: 0;
    padding: 15px;
  }

  h1 {
    font-size: 24px;
  }

  .date-control {
    width: 100%;
    min-width: 0;
  }

  .reception-action-bar {
    gap: 8px;
  }

  .panel,
  .metric-card {
    padding: 15px;
  }

  .panel-header,
  .action-row,
  .current-patient,
  .patient-profile-card,
  .profile-row {
    align-items: stretch;
    flex-direction: column;
  }

  .catalog-form-grid,
  .form-grid,
  #appointment-form .form-grid {
    grid-template-columns: 1fr;
  }

  .archive-hero {
    flex-direction: column;
    align-items: stretch;
  }

  .archive-hero-content {
    align-items: flex-start;
  }

  .archive-hero-stats,
  .archive-refresh-btn {
    width: 100%;
  }
}

@media (max-width: 420px) {
  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nav-item {
    min-height: 48px;
    flex-direction: row;
    justify-content: flex-start;
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

.services-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 18px;
  align-items: start;
}

.visit-services-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 92%, var(--canvas));
  padding: 16px;
}

.panel-header.compact {
  margin-bottom: 12px;
}

.service-results {
  position: relative;
  z-index: 5;
}

.service-results-shell {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 8px;
  box-shadow: 0 12px 28px rgba(22, 33, 31, 0.12);
}

.service-result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  padding: 9px 10px;
  text-align: start;
  cursor: pointer;
}

.service-result-row:hover,
.service-result-row:focus-visible {
  background: color-mix(in srgb, var(--primary) 8%, transparent);
  outline: none;
}

.service-result-row span,
.visit-services-table td:first-child,
.finance-service {
  min-width: 0;
}

.service-result-row strong,
.service-result-row small {
  display: block;
}

.service-result-row small {
  color: var(--muted);
}

.workspace-panel .catalog-search-head {
  grid-template-columns: 1fr;
}

.workspace-panel .doctor-search-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
  justify-self: stretch;
}

.workspace-panel .doctor-search-tabs .catalog-type-tab {
  min-width: 0;
}

.workspace-panel .inline-form {
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  align-items: stretch;
}

.workspace-panel .inline-form .secondary-button {
  min-width: 0;
  white-space: normal;
}

.visit-services-table input {
  width: 100%;
  min-width: 0;
}

.visit-services-table .compact-number {
  min-width: 76px;
}

.tabular,
.visit-services-table td:nth-last-child(2),
.finance-amount {
  font-variant-numeric: tabular-nums;
}

tr.is-muted {
  opacity: 0.68;
}

@media (max-width: 980px) {
  .services-layout {
    grid-template-columns: 1fr;
  }

  .visit-services-panel {
    padding: 12px;
  }
}

@media (max-width: 720px) {
  .visit-services-table {
    min-width: 760px;
  }

  .service-result-row {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media print {
  @page {
    size: A4;
    margin: 14mm 13mm;
  }

  html,
  body {
    background: #ffffff;
  }

  body > .app-shell {
    display: none;
  }

  .print-sheet {
    display: block;
    padding: 0;
    color: #000000;
    direction: ltr;
    font-family: Arial, sans-serif;
    font-size: 10.5pt;
    line-height: 1.35;
  }

  .print-letterhead {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10mm;
    align-items: start;
    direction: ltr;
    border-bottom: 2px solid #a5382f;
    padding-bottom: 5mm;
    margin-bottom: 5mm;
    color: #15211f;
    break-inside: avoid;
  }

  .letterhead-side {
    min-width: 0;
    text-align: center;
  }

  .letterhead-fr {
    direction: ltr;
    font-family: Arial, "Cairo", sans-serif;
  }

  .letterhead-fr .letterhead-kicker {
    font-size: 13.5pt;
    font-style: normal;
    line-height: 1.12;
    white-space: nowrap;
  }

  .letterhead-fr .letterhead-doctor {
    font-size: 19pt;
    line-height: 1.08;
    white-space: nowrap;
  }

  .letterhead-fr .letterhead-lines {
    font-size: 10pt;
    line-height: 1.28;
  }

  .letterhead-fr .letterhead-highlight {
    font-size: 12pt;
  }

  .letterhead-fr .letterhead-role {
    font-size: 9.5pt;
    line-height: 1.28;
  }

  .letterhead-fr .letterhead-contact {
    font-size: 9pt;
    line-height: 1.28;
  }

  .letterhead-ar {
    direction: rtl;
    font-family: Arial, "Cairo", sans-serif;
  }

  .letterhead-kicker {
    margin: 0 0 3mm;
    padding-bottom: 2mm;
    border-bottom: 1px solid #a5382f;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 15pt;
    font-style: italic;
    line-height: 1.1;
  }

  .letterhead-ar .letterhead-kicker {
    font-family: Arial, "Cairo", sans-serif;
    font-style: normal;
  }

  .letterhead-doctor {
    margin: 0 0 2mm;
    color: #1d2f38;
    font-size: 20pt;
    font-weight: 900;
    line-height: 1.1;
  }

  .letterhead-lines p,
  .letterhead-role p,
  .letterhead-contact p {
    margin: 0.7mm 0;
  }

  .letterhead-lines {
    font-size: 10.5pt;
    font-weight: 700;
  }

  .letterhead-highlight {
    margin: 2.5mm 0 2mm;
    color: #a5382f;
    font-size: 12.5pt;
    font-weight: 900;
  }

  .letterhead-role {
    margin-top: 1mm;
    font-size: 10pt;
    font-style: italic;
  }

  .letterhead-ar .letterhead-role {
    font-style: normal;
  }

  .letterhead-contact {
    margin-top: 3mm;
    padding-top: 2mm;
    border-top: 1px solid #a5382f;
    font-size: 9.5pt;
    font-weight: 700;
    overflow-wrap: anywhere;
  }

  .print-document-meta {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8mm;
    direction: ltr;
    border-bottom: 1px solid #000000;
    padding-bottom: 4mm;
    margin-bottom: 6mm;
    break-inside: avoid;
  }

  .print-document-meta h1 {
    margin: 0;
    font-size: 18pt;
    line-height: 1.1;
  }

  .print-meta-rows {
    min-width: 55mm;
    text-align: left;
  }

  .print-meta-rows p,
  .print-block p {
    margin: 0 0 1.5mm;
  }

  .print-block {
    margin-bottom: 5mm;
    break-inside: avoid;
  }

  .print-block h2,
  .print-sheet h2 {
    margin: 0 0 2.5mm;
    font-size: 13pt;
  }

  .print-sheet table {
    width: 100%;
    min-width: 0;
    margin-top: 5mm;
    border-collapse: collapse;
    page-break-inside: auto;
  }

  .print-sheet th,
  .print-sheet td {
    border: 1px solid #000000;
    padding: 2.8mm;
    text-align: center;
    vertical-align: middle;
  }

  .print-sheet tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .print-total {
    margin-top: 5mm;
    text-align: right;
  }

  .invoice-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 3mm;
    margin-bottom: 5mm;
    direction: ltr;
    break-inside: avoid;
  }

  .invoice-summary-grid div {
    min-height: 18mm;
    border: 1px solid #000000;
    padding: 2.8mm;
    overflow-wrap: anywhere;
  }

  .invoice-summary-grid span {
    display: block;
    margin-bottom: 1.5mm;
    color: #333333;
    font-size: 8.5pt;
    font-weight: 700;
    text-transform: uppercase;
  }

  .invoice-summary-grid strong {
    display: block;
    font-size: 11pt;
    line-height: 1.25;
  }

  .invoice-lines th:last-child,
  .invoice-lines td:last-child {
    text-align: right;
    white-space: nowrap;
  }

  .invoice-total-box {
    display: flex;
    justify-content: flex-end;
    align-items: stretch;
    gap: 0;
    margin-top: 5mm;
    break-inside: avoid;
  }

  .invoice-total-box span,
  .invoice-total-box strong {
    border: 1px solid #000000;
    padding: 3mm 4mm;
    line-height: 1.2;
  }

  .invoice-total-box span {
    border-right: 0;
    font-weight: 700;
  }

  .invoice-total-box strong {
    min-width: 42mm;
    text-align: right;
    font-size: 13pt;
  }

  .invoice-note {
    margin-top: 4mm;
    border: 1px solid #000000;
    padding: 2.8mm;
  }
}
