
/* -------------------------------------------------------
   Minimal MD3-ish tokens (used by date-picker/signature)
-------------------------------------------------------- */
/*
  Local font bundling (IBM Plex Sans Arabic)
  - Ensures identical rendering in Safari/Chrome (desktop + iOS)
  - Avoids relying on Google Fonts (offline-friendly)
  - Keep OFL license at: assets/fonts/OFL.txt
*/
@font-face{
  font-family: "saudi_riyal";
  src: url("../assets/fonts/saudi_riyal.woff2") format("woff2"),
       url("../assets/fonts/saudi_riyal.woff") format("woff");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}
.icon-saudi_riyal::before{
  content: "\e900";
  font-family: "saudi_riyal" !important;
  font-size: inherit;
  color: inherit;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@font-face{
  font-family: 'IBM Plex Sans Arabic';
  src: url('../assets/fonts/IBMPlexSansArabic-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face{
  font-family: 'IBM Plex Sans Arabic';
  src: url('../assets/fonts/IBMPlexSansArabic-Medium.ttf') format('truetype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face{
  font-family: 'IBM Plex Sans Arabic';
  src: url('../assets/fonts/IBMPlexSansArabic-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root{
  --md-sys-spacing-1: 4px;
  --md-sys-spacing-2: 8px;
  --md-sys-spacing-3: 12px;
  --md-sys-spacing-4: 16px;
  --md-sys-spacing-5: 20px;

  --md-sys-shape-corner-extra-small: 4px;
  --md-sys-shape-corner-small: 8px;
  --md-sys-shape-corner-medium: 12px;
  --md-sys-shape-corner-large: 16px;
  --md-sys-shape-corner-full: 999px;

  --md-sys-motion-duration-short2: 150ms;
  --md-sys-motion-duration-short4: 200ms;
  --md-sys-motion-duration-medium2: 260ms;
  --md-sys-motion-easing-standard: cubic-bezier(0.2, 0, 0, 1);
  --md-sys-motion-easing-emphasized: cubic-bezier(0.2, 0, 0, 1);

  --md-sys-typescale-body-medium-font: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --md-sys-typescale-label-large-font: var(--md-sys-typescale-body-medium-font);
  --md-sys-typescale-body-small-size: 12px;
  --md-sys-typescale-body-medium-size: 14px;
  --md-sys-typescale-title-small-size: 16px;
  --md-sys-typescale-title-medium-size: 18px;
  --md-sys-typescale-label-small-size: 11px;
  --md-sys-typescale-label-medium-size: 12px;
  --md-sys-typescale-label-large-size: 13px;
  --md-sys-typescale-title-medium-weight: 600;
  --md-sys-typescale-label-large-weight: 500;

  --easing-standard: var(--md-sys-motion-easing-standard);

  /* Page scale (screen only). JS updates this for phones. */
  --page-scale: 1;

  /* Formal letter layout tokens (kept in sync with js/letter-formal-rules.js). */
  --letter-content-font-size: 14px;
  --letter-content-line-height: 1.4;
  --letter-title-font-size: 16px;
  --letter-to-font-size: 14px;
  --letter-muted-font-size: 12px;
  --letter-date-font-size: 10.5px;

  --letter-margin-top: 44mm;
  --letter-margin-right: 5mm;
  --letter-margin-bottom: 21mm;
  --letter-margin-left: 11mm;

  --letter-signature-width: 60mm;
  --letter-signature-box-height: 28mm;
  --letter-signature-gap-top: 8mm;
  --letter-signature-box-gap-top: 1mm;
  --letter-signature-row-gap: 2mm;
}

:root[data-theme="light"]{
  --md-sys-color-primary: #1e5aa8;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #d6e3ff;
  --md-sys-color-on-primary-container: #001b3f;

  --md-sys-color-surface: #ffffff;
  --md-sys-color-surface-bright: #ffffff;
  --md-sys-color-surface-container-low: #f5f7fb;
  --md-sys-color-surface-container: #eef2f8;
  --md-sys-color-surface-container-high: #e7ecf4;
  --md-sys-color-surface-container-highest: #dfe6f1;
  --md-sys-color-surface-variant: #e2e8f0;

  --md-sys-color-on-surface: #0f172a;
  --md-sys-color-on-surface-variant: #475569;

  --md-sys-color-outline: #94a3b8;
  --md-sys-color-outline-variant: #cbd5e1;

  --toast-success-bg: #166534;
  --toast-success-color: #f0fdf4;
  --toast-error-bg: #991b1b;
  --toast-error-color: #fef2f2;
}

:root[data-theme="dark"]{
  --md-sys-color-primary: #8ab4ff;
  --md-sys-color-on-primary: #001b3f;
  --md-sys-color-primary-container: #10305f;
  --md-sys-color-on-primary-container: #d6e3ff;

  --md-sys-color-surface: #0b1220;
  --md-sys-color-surface-bright: #0f172a;
  --md-sys-color-surface-container-low: #0f172a;
  --md-sys-color-surface-container: #111c33;
  --md-sys-color-surface-container-high: #152044;
  --md-sys-color-surface-container-highest: #1a2a55;
  --md-sys-color-surface-variant: #24324d;

  --md-sys-color-on-surface: #e5e7eb;
  --md-sys-color-on-surface-variant: #cbd5e1;

  --md-sys-color-outline: #64748b;
  --md-sys-color-outline-variant: #334155;

  --toast-success-bg: #15803d;
  --toast-success-color: #f0fdf4;
  --toast-error-bg: #b91c1c;
  --toast-error-color: #fef2f2;
}

html, body{
  height: 100%;
}

body{
  margin: 0;
  font-family: var(--md-sys-typescale-body-medium-font);
  color: var(--md-sys-color-on-surface);
  background: linear-gradient(180deg, var(--md-sys-color-surface-container-low), var(--md-sys-color-surface));
}

*{ box-sizing: border-box; }
[hidden]{ display: none !important; }

/* Accessibility */
.sr-only{
  position:absolute;
  width:1px;
  height:1px;
  padding:0;
  margin:-1px;
  overflow:hidden;
  clip:rect(0,0,0,0);
  white-space:nowrap;
  border:0;
}

.muted{ color: var(--md-sys-color-on-surface-variant); }
.badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border:1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-full);
  padding: 4px 10px;
  font-weight: 600;
  font-size: 12px;
  background: var(--md-sys-color-surface);
}

/* Topbar */
.topbar{
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  background: rgba(255,255,255,0.75);
  backdrop-filter: blur(10px);
}
:root[data-theme="dark"] .topbar{
  background: rgba(15,23,42,0.72);
}

.topbar__title{
  display:flex;
  align-items:center;
  gap: 12px;
}
.title{ font-size: 18px; font-weight: 700; }
.subtitle{ font-size: 12px; color: var(--md-sys-color-on-surface-variant); }
.app-version{
  display: inline-block;
  margin-inline-start: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--md-sys-color-on-surface-variant);
}

.topbar__actions{ display:flex; gap: 8px; flex-wrap: wrap; align-items:center; }

/* Mobile tabs (Form/Preview) */
.mobileTabs{
  display:none;
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface);
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
}
.mobileTabs .tab{
  border: none;
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
}
.mobileTabs .tab.is-active{
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}
@media (max-width: 900px){
  .mobileTabs{ display:inline-flex; }
}

/* Bottom navigation (phones) */
.bottomTabs{
  display:none;
}

@media (max-width: 768px){
  :root{ --bottom-tabs-h: 62px; }
  #btn-save, #btn-load{ display:none; }

  /* Move view switching to bottom (standard phone pattern) */
  .mobileTabs{ display:none !important; }

  .bottomTabs{
    display:flex;
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    z-index: 100;

    border: 1px solid var(--md-sys-color-outline-variant);
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(10px);
    border-radius: 18px;
    padding: 6px;
    gap: 6px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.12);
  }

  :root[data-theme="dark"] .bottomTabs{
    background: rgba(15,23,42,0.82);
  }

  .bottomTabs .tab{
    flex: 1;
    border: none;
    background: transparent;
    color: var(--md-sys-color-on-surface-variant);
    padding: 12px 10px;
    border-radius: 14px;
    font-weight: 800;
    font-size: 13px;
    cursor: pointer;
  }

  .bottomTabs .tab.is-active{
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
  }

  /* Tablet save/load action buttons in bottom tabs */
  .bottomTabs__action{
    display: inline-flex;
    font-size: 12px;
    padding: 8px 10px;
  }

  /* Make space for bottom tabs */
  body{ padding-bottom: calc(var(--bottom-tabs-h) + 18px + env(safe-area-inset-bottom)); }
}

/* Show save/load in bottom tabs on tablets (768-900px) */
@media (min-width: 768px) and (max-width: 900px){
  .bottomTabs__action{
    display: inline-flex;
    font-size: 12px;
    padding: 8px 10px;
  }
}

/* Tablet portrait (641-768px): tighter spacing, scale page down */
@media (min-width: 641px) and (max-width: 768px){
  .layout{ padding: 12px 10px; gap: 12px; }
  .panel{ border-radius: 14px; }
  .form{ padding: 10px; }
  .section{ padding: 12px 10px; }
  .topbar{ padding: 10px 12px; }
  .topbar__actions .btn{ padding: 8px 10px; font-size: 12px; }
}


/* Buttons */
.btn{
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: transform 120ms var(--md-sys-motion-easing-standard), background 120ms var(--md-sys-motion-easing-standard);
  display:inline-flex;
  align-items:center;
  gap: 8px;
}
.btn:hover{ background: var(--md-sys-color-surface-container-low); }
.btn:active{ transform: scale(0.98); }
.btn--ghost{ background: transparent; }
.btn--primary{
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border-color: transparent;
}
.btn--exporting{
  position: relative;
  pointer-events: none;
  opacity: 0.82;
}
.btn--exporting::after{
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
  margin-inline-start: 6px;
  vertical-align: middle;
}
@keyframes btn-spin{
  to{ transform: rotate(360deg); }
}

/* Layout */
.layout{
  display:grid;
  grid-template-columns: 420px 1fr;
  gap: 16px;
  padding: 16px;
  align-items: start;
}
@media (max-width: 1100px){
  .layout{ grid-template-columns: 1fr; }
}

@media (max-width: 900px){
  body[data-mobile-view="form"] .panel.preview{ display:none; }
  body[data-mobile-view="preview"] .panel.form{ display:none; }
  body[data-mobile-view="preview"] .panel.preview{ display:block; }
  .printRoot{ max-height: calc(100dvh - 240px); }
}

@media (max-width: 768px){
  /* account for bottom navigation */
  .printRoot{ max-height: calc(100dvh - 280px - var(--bottom-tabs-h)); }
}




.panel{
  background: rgba(255,255,255,0.78);
  border:1px solid var(--md-sys-color-outline-variant);
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(2,6,23,0.06);
  overflow: hidden;
}
:root[data-theme="dark"] .panel{
  background: rgba(17,28,51,0.72);
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}

.form{ padding: 12px; }
.section{
  padding: 12px;
  border-top: 1px solid var(--md-sys-color-outline-variant);
}
.section:first-child{ border-top: none; }
.section__title{
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 10px;
}
.small-note .section__title{ margin-bottom: 6px; }
.small-note .muted{ line-height: 1.6; font-size: 13px; }

.grid2{ display:grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3{ display:grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
@media (max-width: 520px){
  .grid2, .grid3{ grid-template-columns: 1fr; }
}

/* Fields */
.field{ display:block; }
.field__label{
  display:block;
  margin-bottom: 6px;
  font-weight: 700;
  font-size: 12px;
  color: var(--md-sys-color-on-surface-variant);
}
.field.field--select .field__label{
  display: flex;
  align-items: center;
  gap: 6px;
}
.field.field--select .field__label::after{
  content: 'قائمة';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-primary);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.6;
}
.field__control{
  width:100%;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  outline: none;
}
:root[data-theme="dark"] .field__control{
  background: var(--md-sys-color-surface-bright);
}
.field__control:focus{
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 3px rgba(30,90,168,0.18);
}
.field__control--textarea{
  resize: vertical;
  min-height: 110px;
  line-height: 1.7;
}
.required-mark{
  color: #dc2626;
  font-weight: 800;
}
.field__hint{
  display:block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--md-sys-color-on-surface-variant);
}
.field__hint--inline{
  font-size: 11px;
  font-weight: 400;
  color: var(--md-sys-color-on-surface-variant);
  margin-right: 4px;
}
.field.is-disabled .field__label,
.field.is-disabled .field__hint{
  opacity: 0.72;
}

/* Multi-select dropdown (نسخة إلى) */
.cc-multi{
  position: relative;
}
.cc-multi__trigger{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  text-align: right;
  padding-inline-end: 36px;
  padding-inline-start: 12px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23475569' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  background-size: 12px 8px;
}
.cc-multi__summary{
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.cc-multi__summary.is-placeholder{
  color: var(--md-sys-color-on-surface-variant);
  font-weight: 500;
}
.cc-multi.is-open .cc-multi__trigger{
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 3px rgba(30,90,168,0.18);
}
.cc-multi__menu{
  position: absolute;
  top: calc(100% + 6px);
  inset-inline: 0;
  z-index: 45;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 12px;
  background: var(--md-sys-color-surface);
  box-shadow: 0 14px 34px rgba(2,6,23,0.16);
  max-height: 240px;
  overflow: auto;
  padding: 6px;
}
.cc-multi__option{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.cc-multi__option:hover{
  background: var(--md-sys-color-surface-container-low);
}
.cc-multi__checkbox{
  inline-size: 16px;
  block-size: 16px;
  margin: 0;
  accent-color: var(--md-sys-color-primary);
  flex: 0 0 auto;
}
.cc-multi__text{
  font-size: 13px;
  line-height: 1.5;
}
:root[data-theme="dark"] .cc-multi__trigger{
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23a8b6ca' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
:root[data-theme="dark"] .cc-multi__menu{
  background: var(--md-sys-color-surface-bright);
  border-color: var(--md-sys-color-outline);
}
@media (max-width: 520px){
  .cc-multi__menu{
    max-height: 210px;
  }
}

/* Codes */
.codes{
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px dashed var(--md-sys-color-outline-variant);
  border-radius: 12px;
  background: var(--md-sys-color-surface-container-low);
}
.codeRow{
  display:flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
}
.codeLabel{ font-weight: 700; color: var(--md-sys-color-on-surface-variant); }
.codeValue{ font-weight: 800; }

/* Zoom bar (segmented pill) */
.zoom-bar{
  display: inline-flex;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 10px;
  overflow: hidden;
  background: var(--md-sys-color-surface);
}
.zoom-bar__btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  transition: background 120ms var(--md-sys-motion-easing-standard);
  position: relative;
}
.zoom-bar__btn:not(:last-child)::after{
  content: '';
  position: absolute;
  inset-inline-start: 0;
  top: 6px;
  bottom: 6px;
  width: 1px;
  background: var(--md-sys-color-outline-variant);
}
.zoom-bar__btn:hover{
  background: var(--md-sys-color-surface-container-low);
}
.zoom-bar__btn:active{
  background: var(--md-sys-color-surface-container);
}
.zoom-bar__btn svg{
  display: block;
  pointer-events: none;
}

/* Preview */
.preview__header{
  display:flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  gap: 12px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.preview__title{ font-weight: 900; font-size: 14px; }
.preview__meta{ font-size: 12px; }
.printRoot{
  padding: 14px;
  overflow:auto;
  max-height: calc(100dvh - 160px);
}

.preview__footer{
  padding: 10px 14px;
  border-top: 1px solid var(--md-sys-color-outline-variant);
  font-size: 12px;
}

/* A4 page (screen) */
.a4-page,
.a4-page-image{
  position: relative;
  width: 210mm;
  height: 297mm;
  /* Compensate for CSS transform not reducing layout size:
     when --page-scale < 1, pull the next page up to match the visual bottom. */
  margin: 0 auto calc(297mm * (var(--page-scale, 1) - 1) + 16px) auto;
  background: #fff;
  box-shadow: 0 12px 30px rgba(2,6,23,0.12);
  border-radius: 8px;
  overflow: hidden;
  transform: scale(var(--page-scale));
  transform-origin: top center;
}

.a4-page-image{
  display: block;
  object-fit: cover;
}

/* Background image */
.a4-bg{
  position:absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events:none;
  user-select:none;
}

/* Header overlay: values for الرقم/التاريخ/المشفوعات */
.headerOverlay{
  position:absolute;
  inset: 0;
  pointer-events:none;
  user-select:none;
  font-size: 11px;
  color: #1f2a44;
}
.ov{
  position:absolute;
  white-space:nowrap;
  font-weight: 700;
}

/* Overlay positions (tunable) — measured from your existing template coordinates */
:root{

  --ov-hijri-top: 21.2mm;
  --ov-hijri-left: 4.5mm;

  --ov-greg-top: 21.4mm;
  --ov-greg-left: 27.5mm;

  --ov-att-top: 27.5mm;
  --ov-att-left: 27mm;

  --ov-num-top: 13.1mm;
  --ov-num-left: 27mm;
  --ov-num-width: 77mm;

  /* Fine-tune: shift header dates slightly left to avoid overlapping the printed label */
  --ov-date-shift-x: -5px;
}

.ov-hijri{ top: var(--ov-hijri-top); left: var(--ov-hijri-left); }
.ov-greg{ top: var(--ov-greg-top); left: var(--ov-greg-left); }
.ov-att{ top: var(--ov-att-top); left: var(--ov-att-left); }
.ov-num{ top: var(--ov-num-top); left: var(--ov-num-left); text-align: left; direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; font-weight: 700; }

/* Make dual dates crisp and consistent in both preview and PDF */
.ov-hijri, .ov-greg{
  direction: ltr;
  unicode-bidi: isolate;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.2px;
  font-weight: 600;
  font-size: var(--letter-date-font-size);
  transform: translateX(var(--ov-date-shift-x));
}

/* Content box with requested margins (logical props for RTL) */
.letterContent{
  position:absolute;
  inset-block-start: var(--letter-margin-top);
  inset-block-end: var(--letter-margin-bottom);
  inset-inline-start: var(--letter-margin-right);  /* right in RTL */
  inset-inline-end: var(--letter-margin-left);   /* left in RTL */
  direction: rtl;
  text-align: justify;
  font-family: "IBM Plex Sans Arabic", Arial, sans-serif;
  padding-inline: 3mm;
  font-size: var(--letter-content-font-size);
  line-height: var(--letter-content-line-height);
  color: #0f172a;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  word-break: break-word;
  overflow: hidden;
}

/* Inside letter content */
.letterTitle{
  font-size: var(--letter-title-font-size);
  font-weight: 800;
  text-align: center;
  margin: 0 0 8mm 0;
}
.letterTo{
  font-size: var(--letter-to-font-size);
  margin: 0 0 3mm 0;
  font-weight: 700;
  text-align: right;
}
.letterPara{
  margin: 0 0 3mm 0;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.letterLabel{ font-weight: 800; }
.letterPara--center{ text-align: center; margin-block: 3mm; }
.letterPara--meta{ font-size: 11px; color: rgba(15,23,42,0.55); text-align: right; }
.letterPara--cc{ font-size: 11px; color: rgba(15,23,42,0.70); margin-top: 4mm; padding-top: 2mm; border-top: 0.3mm solid rgba(15,23,42,0.15); }
.letterPara--subject{ font-size: 15px; font-weight: 700; }
.letterPara--subject .letterLabel{ font-weight: 700; }
.letterPara--details-ph{ font-size: 10pt; color: rgba(15,23,42,0.22); text-align: right; }
.letterRef{ font-size: 0.65em; vertical-align: super; opacity: 0.65; font-weight: 400; letter-spacing: 0; }

.inlineCode{
  direction:ltr;
  unicode-bidi: isolate;
  font-weight: 800;
}

/* Signature block */
.sigBlock{
  display:flex;
  flex-direction: column;
  align-items: flex-end;
  margin-top: var(--letter-signature-gap-top);
  width: var(--letter-signature-width);
  margin-right: auto;
  margin-left: 0;
}
.sigMeta{
  width: 100%;
  text-align: center;
  padding: 0 2mm;
}
.sigMetaRow{
  margin: 0 0 var(--letter-signature-row-gap) 0;
  padding: 1mm 0;
}
.sigMetaRow--placeholder{ color: rgba(15,23,42,0.20); }
.sigBox{
  width: 100%;
  height: var(--letter-signature-box-height);
  margin-top: var(--letter-signature-box-gap-top);
  border: none;
  border-bottom: 1px solid rgba(15,23,42,0.18);
  border-radius: 0;
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
  background: transparent;
}
.sigBox--filled{
  border: none;
  background: transparent;
}
.sigImg{
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* Page number */
.pageNo{
  position:absolute;
  left: 32.6mm;
  top: 285.9mm; /* from px=1081 */
  font-size: 12px;
  font-weight: 700;
  color: #111827;
  pointer-events:none;
  user-select:none;
}

/* Print: ONLY printRoot pages */
@media print{
  /* Hide non-print UI by targeting specific containers */
  .topbar,
  .panel.form,
  .bottomTabs,
  .mobileTabs,
  .toast-container,
  .login-overlay,
  .preview__header,
  .preview__footer,
  .mobilePreview,
  .zoom-bar,
  .signature-toolbar,
  .signature-helper-text{
    display: none !important;
  }
  .layout{
    display: block !important;
    padding: 0 !important;
  }
  .panel.preview{
    border: none !important;
    box-shadow: none !important;
    background: none !important;
    overflow: visible !important;
  }
  #printRoot{
    position: static;
    padding: 0 !important;
    max-height: none !important;
    overflow: visible !important;
  }
  .a4-page,
  .a4-page-image{
    transform: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    page-break-after: always;
    break-after: page;
  }
  .a4-page:last-child,
  .a4-page-image:last-child{
    page-break-after: auto;
    break-after: auto;
  }
  @page { size: A4; margin: 0; }
  html, body { margin: 0; padding: 0; }
  /* Ensure colors/graphics print */
  *{
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}



/* -----------------------------
   Mobile Preview Viewer (v16)
   ----------------------------- */

.mobilePreview{ display:none; }

.viewerViewport{
  position: relative;
  flex: 1;
  min-height: 0;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 16px;
  background: rgba(255,255,255,0.8);
  overflow: hidden;
  touch-action: none; /* enable custom pinch/pan */
  overscroll-behavior: contain;
}
:root[data-theme="dark"] .viewerViewport{
  background: rgba(7,10,18,0.55);
}

.viewerStage{
  position:absolute;
  top:0; left:0;
  transform-origin: 0 0;
  will-change: transform;
}
#viewerImg{
  display:block;
  max-width:none; /* we scale via transform */
  height:auto;
  user-select:none;
  -webkit-user-drag:none;
  pointer-events:none; /* gestures handled on viewport */
  box-shadow: 0 8px 24px rgba(2,6,23,0.18);
  border-radius: 10px;
}

.viewerLoading{
  position:absolute;
  inset:0;
  display:none;
  place-items:center;
  gap: 10px;
  background: rgba(255,255,255,0.75);
  color: var(--md-sys-color-on-surface);
  font-weight: 700;
}
:root[data-theme="dark"] .viewerLoading{
  background: rgba(0,0,0,0.35);
}
.spinner{
  width: 24px;
  height: 24px;
  border: 3px solid color-mix(in srgb, var(--md-sys-color-primary) 22%, transparent);
  border-top-color: var(--md-sys-color-primary);
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
}

.viewerPager{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  padding: 10px 2px 0;
}
.viewerIndicator{
  font-weight: 800;
  letter-spacing: 0.2px;
}

.viewerHint{
  padding: 6px 2px 0;
  font-size: 12px;
  line-height: 1.45;
}

/* Show the mobile preview only on phones */
@media (max-width: 640px){
  #printRoot{ display:none; }
  .mobilePreview{ display:flex; flex-direction:column; gap: 8px; flex: 1; min-height: 0; }
  .panel.preview{ display:flex !important; flex-direction:column; }
  .preview__footer{ display:none; }

  /* Give preview panel a height so the flex chain (panel → mobilePreview → viewerViewport) works.
     Without this, viewerViewport (flex:1) collapses to 0 because no ancestor has a defined height. */
  body[data-mobile-view="preview"] .panel.preview{
    min-height: calc(100dvh - 80px - var(--bottom-tabs-h, 62px));
  }

  /* iOS Safari zooms inputs smaller than 16px */
  .field__control{ font-size: 16px; }
}


/* -------------------------------------------------------
   Toast / Snackbar Notifications
-------------------------------------------------------- */
.toast-container{
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9500;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
@media (max-width: 768px){
  .toast-container{
    bottom: calc(var(--bottom-tabs-h, 62px) + 24px + env(safe-area-inset-bottom));
  }
}
.toast{
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  animation: toast-in var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-emphasized) forwards;
  white-space: nowrap;
}
.toast.toast--dismiss{
  animation: toast-out var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard) forwards;
}
.toast--success{
  background: var(--toast-success-bg, #166534);
  color: var(--toast-success-color, #f0fdf4);
}
.toast--error{
  background: var(--toast-error-bg, #991b1b);
  color: var(--toast-error-color, #fef2f2);
}
@keyframes toast-in{
  to{ opacity:1; transform: translateY(0) scale(1); }
}
@keyframes toast-out{
  from{ opacity:1; transform: translateY(0) scale(1); }
  to{ opacity:0; transform: translateY(-8px) scale(0.96); }
}


/* -------------------------------------------------------
   Button Focus & Hover Improvements
-------------------------------------------------------- */
.btn:focus-visible{
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}
.btn--ghost:hover{
  background: var(--md-sys-color-surface-container-low);
}
.btn--ghost:focus-visible{
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}
.btn--primary:hover{
  filter: none;
  background: color-mix(in srgb, var(--md-sys-color-primary) 88%, white);
}
.btn--primary:focus-visible{
  outline: 2px solid var(--md-sys-color-on-primary-container);
  outline-offset: 2px;
}


/* -------------------------------------------------------
   Custom Select Dropdown Styling
-------------------------------------------------------- */
select.field__control{
  appearance: none;
  -webkit-appearance: none;
  border-width: 2px;
  border-color: color-mix(in srgb, var(--md-sys-color-primary) 40%, var(--md-sys-color-outline-variant));
  padding-inline-end: 36px;
  background-color: color-mix(in srgb, var(--md-sys-color-primary-container) 18%, var(--md-sys-color-surface));
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23475569' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  background-size: 12px 8px;
  font-weight: 600;
  transition: border-color var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard),
              box-shadow var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard),
              background-color var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard),
              color var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard),
              opacity var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
  cursor: pointer;
}
select.field__control:hover:not(:disabled){
  border-color: var(--md-sys-color-outline);
  background-color: color-mix(in srgb, var(--md-sys-color-surface) 88%, var(--md-sys-color-primary-container));
}
select.field__control:focus,
select.field__control:focus-visible{
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 3px rgba(30,90,168,0.24);
}
select.field__control:disabled{
  color: var(--md-sys-color-on-surface-variant);
  background-color: var(--md-sys-color-surface-container-low);
  border-color: var(--md-sys-color-outline-variant);
  border-style: dashed;
  opacity: 0.72;
  cursor: not-allowed;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2394a3b8' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
:root[data-theme="dark"] select.field__control{
  background-color: color-mix(in srgb, var(--md-sys-color-primary-container) 24%, var(--md-sys-color-surface-bright));
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23a8b6ca' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
:root[data-theme="dark"] select.field__control:disabled{
  background-color: var(--md-sys-color-surface-container);
  border-color: var(--md-sys-color-outline-variant);
  color: color-mix(in srgb, var(--md-sys-color-on-surface-variant) 86%, var(--md-sys-color-surface));
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2364748b' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}


/* -------------------------------------------------------
   Readonly Field Visual Distinction
-------------------------------------------------------- */
.field__control:read-only,
.field__control[readonly]{
  background: var(--md-sys-color-surface-container-low);
  border-style: dashed;
  cursor: default;
  color: var(--md-sys-color-on-surface-variant);
}
:root[data-theme="dark"] .field__control:read-only,
:root[data-theme="dark"] .field__control[readonly]{
  background: var(--md-sys-color-surface-container);
}
/* Exclude the date display from readonly styling since it opens a picker */
.md3-text-field__input--date[readonly]{
  border-style: solid;
  cursor: pointer;
  color: var(--md-sys-color-on-surface);
  background: var(--md-sys-color-surface);
}
:root[data-theme="dark"] .md3-text-field__input--date[readonly]{
  background: var(--md-sys-color-surface-bright);
}


/* -------------------------------------------------------
   Smooth Section Transitions
-------------------------------------------------------- */
.section-animated{
  overflow: hidden;
  transition: max-height var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-emphasized),
              opacity var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-emphasized);
  max-height: 600px;
  opacity: 1;
}
.section-animated.is-hidden{
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin: 0;
  border: none;
  visibility: hidden;
}


/* -------------------------------------------------------
   Theme Transition
-------------------------------------------------------- */
html.theme-transitioning,
html.theme-transitioning *,
html.theme-transitioning *::before,
html.theme-transitioning *::after{
  transition: background-color 300ms ease, color 300ms ease, border-color 300ms ease, box-shadow 300ms ease !important;
}

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


/* -------------------------------------------------------
   Input Placeholder Styling
-------------------------------------------------------- */
.field__control::placeholder{
  color: var(--md-sys-color-on-surface-variant);
  opacity: 0.72;
}
:root[data-theme="dark"] .field__control::placeholder{
  color: var(--md-sys-color-on-surface-variant);
  opacity: 0.72;
}


/* -------------------------------------------------------
   Section Visual Hierarchy
-------------------------------------------------------- */
.section{
  padding: 14px 12px;
}
.section__title{
  position: relative;
  padding-inline-start: 10px;
}
.section__title::before{
  content: '';
  position: absolute;
  inset-inline-start: 0;
  top: 2px;
  bottom: 2px;
  width: 3px;
  border-radius: 2px;
  background: var(--md-sys-color-primary);
}
.field + .field{
  margin-top: 10px;
}
.grid2 + .field,
.field + .grid2{
  margin-top: 10px;
}


/* -------------------------------------------------------
   Topbar Responsive Polish (900-1100px)
-------------------------------------------------------- */
@media (max-width: 1100px) and (min-width: 901px){
  .topbar__actions{
    gap: 6px;
  }
  .topbar__actions .btn{
    padding: 8px 10px;
    font-size: 12px;
  }
}
@media (max-width: 900px){
  .topbar{
    flex-wrap: wrap;
    gap: 8px;
  }
  .topbar__actions{
    width: 100%;
    justify-content: center;
  }
}


/* -------------------------------------------------------
   A4 Page Preview Hover Elevation
-------------------------------------------------------- */
.a4-page,
.a4-page-image{
  transition: box-shadow var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
}
.a4-page:hover,
.a4-page-image:hover{
  box-shadow: 0 16px 40px rgba(2,6,23,0.18);
}


/* -------------------------------------------------------
   .muted Dark Mode Readability
-------------------------------------------------------- */
:root[data-theme="dark"] .muted{
  color: var(--md-sys-color-on-surface-variant);
  opacity: 0.92;
}


/* -------------------------------------------------------
   Signature Helper Icon (replace emoji with CSS)
-------------------------------------------------------- */
.sig-helper-icon{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
  line-height: 1;
}


/* -------------------------------------------------------
   Agreement Checkbox & Conditions (Form)
-------------------------------------------------------- */
.agreement-check{
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.6;
  margin-bottom: 10px;
}
.agreement-check input[type="checkbox"]{
  margin-top: 4px;
  width: 18px;
  height: 18px;
  accent-color: var(--md-sys-color-primary);
  flex-shrink: 0;
  cursor: pointer;
}
.agreement-list{
  padding-inline-start: 20px;
  margin: 0;
  font-size: 12px;
  line-height: 1.75;
  color: var(--md-sys-color-on-surface-variant);
}
.agreement-list li{
  margin-bottom: 4px;
}
.agreement-list li b{
  color: var(--md-sys-color-on-surface);
}
.financial-cost-toggle{
  margin-bottom: 12px;
  padding: 8px 10px;
  border: 1px dashed var(--md-sys-color-outline-variant);
  border-radius: 12px;
  background: var(--md-sys-color-surface-container-low);
}
:root[data-theme="dark"] .financial-cost-toggle{
  background: var(--md-sys-color-surface-container);
}

/* -------------------------------------------------------
   Login Overlay
-------------------------------------------------------- */
.login-overlay{
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9000;
  place-items: center;
  background: rgba(15, 23, 42, 0.55);
  background: color-mix(in srgb, var(--md-sys-color-surface) 55%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.login-overlay.is-active{
  display: grid;
}
.login-auto-restoring{
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  padding: 12px 0 8px;
}
.login-auto-restoring__spinner{
  width: 36px; height: 36px;
  border: 3px solid var(--md-sys-color-outline-variant);
  border-top-color: var(--md-sys-color-primary);
  border-radius: 50%;
  animation: login-spin .7s linear infinite;
}
@keyframes login-spin{ to{ transform: rotate(360deg); } }
.login-auto-restoring__text{
  font-size: 14px; font-weight: 600;
  color: var(--md-sys-color-on-surface-variant);
}
body.login-active .topbar,
body.login-active .layout,
body.login-active .bottomTabs{
  pointer-events: none;
  opacity: 0.3;
  filter: blur(2px);
  user-select: none;
}
.login-card{
  width: 92%;
  max-width: 380px;
  background: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 20px;
  padding: 32px 28px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.2);
  text-align: center;
}
:root[data-theme="dark"] .login-card{
  background: var(--md-sys-color-surface-container);
}
.login-card__header{
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 6px;
}
.login-card__sub{
  font-size: 13px;
  color: var(--md-sys-color-on-surface-variant);
  margin: 0 0 20px 0;
}
.login-card .field{
  text-align: right;
}
.login-card .field__control{
  font-size: 15px;
  font-weight: 500;
}
.login-email-input{
  text-align: left;
  direction: ltr;
  letter-spacing: 0;
}
.login-password-input{
  text-align: left;
  direction: ltr;
  letter-spacing: 0;
}
.login-field-hidden{
  display: none !important;
}
.login-error{
  margin-top: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #dc2626;
  text-align: center;
}
:root[data-theme="dark"] .login-error{
  color: #f87171;
}
.login-btn{
  width: 100%;
  margin-top: 16px;
  justify-content: center;
  padding: 12px;
  font-size: 15px;
}
.login-actions{
  margin-top: 10px;
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.login-success{
  margin-top: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #166534;
  text-align: center;
  display: none;
}
:root[data-theme="dark"] .login-success{
  color: #4ade80;
}
.change-password-form{
  padding: 16px 20px;
}
.change-password-form .field + .field{
  margin-top: 10px;
}
/* Section title flex for inline logout button */
.section__title--flex{
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn--logout{
  margin-inline-start: auto;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 8px;
  color: #dc2626;
  border-color: #dc2626;
}
.btn--logout:hover{
  background: rgba(220,38,38,0.08);
}
:root[data-theme="dark"] .btn--logout{
  color: #f87171;
  border-color: #f87171;
}
:root[data-theme="dark"] .btn--logout:hover{
  background: rgba(248,113,113,0.1);
}


/* -------------------------------------------------------
   File Attachments Upload Zone
-------------------------------------------------------- */
.attachment-upload{
  margin-top: 12px;
}
.attachment-upload .field__label{
  display: block;
  margin-bottom: 4px;
}

.attachment-explainer{
  margin: 0 0 10px 0;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--md-sys-color-on-surface-variant);
  background: var(--md-sys-color-surface-container-low);
  border-radius: 10px;
  border-right: 3px solid var(--md-sys-color-primary);
}
:root[data-theme="dark"] .attachment-explainer{
  background: var(--md-sys-color-surface-container);
}

/* Signature privacy note */
.signature-privacy-note{
  margin: 0 0 12px 0;
  padding: 8px 12px;
  font-size: 12px;
  line-height: 1.6;
  color: #166534;
  background: #f0fdf4;
  border-radius: 8px;
  border-right: 3px solid #22c55e;
}
:root[data-theme="dark"] .signature-privacy-note{
  color: #86efac;
  background: rgba(34, 197, 94, 0.12);
}

.file-drop-zone{
  position: relative;
  border: 2px dashed var(--md-sys-color-outline-variant);
  border-radius: 14px;
  padding: 20px 16px;
  text-align: center;
  background: var(--md-sys-color-surface-container-low);
  cursor: pointer;
  transition: border-color 150ms var(--md-sys-motion-easing-standard),
              background 150ms var(--md-sys-motion-easing-standard);
}
.file-drop-zone:hover,
.file-drop-zone:focus-visible{
  border-color: var(--md-sys-color-primary);
  background: var(--md-sys-color-surface-container);
}
.file-drop-zone:focus-visible{
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}
.file-drop-zone.is-dragover{
  border-color: var(--md-sys-color-primary);
  background: var(--md-sys-color-primary-container);
  border-style: solid;
}

:root[data-theme="dark"] .file-drop-zone{
  background: var(--md-sys-color-surface-container);
}
:root[data-theme="dark"] .file-drop-zone:hover,
:root[data-theme="dark"] .file-drop-zone:focus-visible{
  background: var(--md-sys-color-surface-container-high);
}
:root[data-theme="dark"] .file-drop-zone.is-dragover{
  background: var(--md-sys-color-primary-container);
}

.file-drop-zone__content{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.file-drop-zone__icon{
  color: var(--md-sys-color-primary);
  opacity: 0.8;
}
.file-drop-zone__text{
  font-size: 13px;
  font-weight: 600;
  color: var(--md-sys-color-on-surface-variant);
}
.file-drop-zone__btn{
  pointer-events: auto;
  font-size: 12px;
  padding: 8px 14px;
}
.file-drop-zone__hint{
  font-size: 11px;
  color: var(--md-sys-color-on-surface-variant);
  opacity: 0.8;
  margin-top: 4px;
}
.file-drop-zone__input{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* -------------------------------------------------------
   Attachment Previews Grid
-------------------------------------------------------- */
.attachment-previews{
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}
.attachment-previews:empty{
  display: none;
}

.attachment-preview{
  position: relative;
  width: 80px;
  background: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 10px;
  overflow: hidden;
  transition: box-shadow 150ms var(--md-sys-motion-easing-standard);
}
.attachment-preview:hover{
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}
:root[data-theme="dark"] .attachment-preview{
  background: var(--md-sys-color-surface-container);
}
:root[data-theme="dark"] .attachment-preview:hover{
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.attachment-preview__thumb{
  width: 100%;
  height: 70px;
  object-fit: cover;
  display: block;
  background: var(--md-sys-color-surface-container-low);
}

.attachment-preview__info{
  padding: 6px 8px;
  font-size: 10px;
  line-height: 1.3;
  color: var(--md-sys-color-on-surface-variant);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-preview__badge{
  position: absolute;
  top: 4px;
  left: 4px;
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
}

.attachment-preview__remove{
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(220, 38, 38, 0.9);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 150ms var(--md-sys-motion-easing-standard);
}
.attachment-preview:hover .attachment-preview__remove,
.attachment-preview__remove:focus{
  opacity: 1;
}
.attachment-preview__remove:hover{
  background: #dc2626;
}
.attachment-preview__remove:focus-visible{
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
  opacity: 1;
}
@media (hover: none), (pointer: coarse){
  .attachment-preview__remove{
    opacity: 1;
    width: 26px;
    height: 26px;
    font-size: 16px;
  }
}

/* PDF placeholder thumbnail */
.attachment-preview__pdf-icon{
  width: 100%;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

/* Loading state for PDF processing */
.attachment-preview--loading .attachment-preview__thumb,
.attachment-preview--loading .attachment-preview__pdf-icon{
  opacity: 0.5;
}
.attachment-preview--loading::after{
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid var(--md-sys-color-primary);
  border-top-color: transparent;
  border-radius: 50%;
  animation: attachment-spin 0.6s linear infinite;
}
@keyframes attachment-spin{
  to{ transform: rotate(360deg); }
}

/* -------------------------------------------------------
   Initially Hidden Elements (replaces inline style="display:none")
-------------------------------------------------------- */
.login-error{ display: none; }
#no-projects-hint{ display: none; color: var(--md-sys-color-error, #b3261e); }
.btn--logout{ display: none; }
.small-note .muted + .muted{ margin-top: 6px; }
noscript p{ text-align: center; padding: 2rem; font-size: 1.2rem; }


/* -------------------------------------------------------
   Drafts Modal
-------------------------------------------------------- */
.drafts-overlay{
  display: none;
  position: fixed;
  inset: 0;
  z-index: 8500;
  place-items: center;
  background: color-mix(in srgb, var(--md-sys-color-surface) 55%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.drafts-overlay.is-active{
  display: grid;
}

.drafts-card{
  width: 92%;
  max-width: 480px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  background: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.2);
  overflow: hidden;
}
:root[data-theme="dark"] .drafts-card{
  background: var(--md-sys-color-surface-container);
}

.drafts-card__header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.drafts-card__title{
  font-size: 16px;
  font-weight: 800;
}
.drafts-card__title small{
  font-size: 12px;
  font-weight: 600;
  color: var(--md-sys-color-on-surface-variant);
  margin-inline-start: 6px;
}
.drafts-card__close{
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 22px;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms var(--md-sys-motion-easing-standard);
}
.drafts-card__close:hover{
  background: var(--md-sys-color-surface-container);
}

.drafts-card__subtitle{
  display: none;
  padding: 10px 20px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--md-sys-color-on-surface-variant);
}
.drafts-card__subtitle[style*="display: block"]{
  display: block !important;
}

.drafts-card__list{
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
}

.drafts-card__actions{
  padding: 12px 20px;
  border-top: 1px solid var(--md-sys-color-outline-variant);
  text-align: center;
}
.drafts-card__actions .btn{
  width: 100%;
  justify-content: center;
}

/* Draft item */
.draft-item{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 10px;
  border-radius: 12px;
  transition: background 120ms var(--md-sys-motion-easing-standard);
}
.draft-item:hover{
  background: var(--md-sys-color-surface-container-low);
}
:root[data-theme="dark"] .draft-item:hover{
  background: var(--md-sys-color-surface-container-high);
}
.draft-item + .draft-item{
  border-top: 1px solid var(--md-sys-color-outline-variant);
}

.draft-item__info{
  flex: 1;
  min-width: 0;
}
.draft-item__name{
  font-size: 14px;
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.draft-item__name:hover{
  color: var(--md-sys-color-primary);
}
.draft-item__meta{
  font-size: 11px;
  color: var(--md-sys-color-on-surface-variant);
  margin-top: 2px;
}

.draft-item__actions{
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.draft-item__btn{
  font-size: 11px;
  padding: 6px 8px;
  border-radius: 8px;
}
.draft-item__btn--delete{
  color: #dc2626;
  border-color: transparent;
}
.draft-item__btn--delete:hover{
  background: rgba(220,38,38,0.08);
}
:root[data-theme="dark"] .draft-item__btn--delete{
  color: #f87171;
}
:root[data-theme="dark"] .draft-item__btn--delete:hover{
  background: rgba(248,113,113,0.1);
}

/* Inline rename input */
.draft-item__rename-input{
  width: 100%;
  border: 1px solid var(--md-sys-color-primary);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 700;
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  outline: none;
  box-shadow: 0 0 0 3px rgba(30,90,168,0.18);
}
:root[data-theme="dark"] .draft-item__rename-input{
  background: var(--md-sys-color-surface-bright);
}

/* Mobile: stack actions vertically */
@media (max-width: 640px){
  .draft-item{
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .draft-item__actions{
    justify-content: flex-end;
  }
}

/* Print: hide modal */
@media print{
  .drafts-overlay{ display: none !important; }
}


/* -------------------------------------------------------
   Sent Letters Status Badges
-------------------------------------------------------- */
.sent-letter-item{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 10px;
  border-radius: 12px;
  transition: background 120ms var(--md-sys-motion-easing-standard);
}
.sent-letter-item:hover{
  background: var(--md-sys-color-surface-container-low);
}
:root[data-theme="dark"] .sent-letter-item:hover{
  background: var(--md-sys-color-surface-container-high);
}
.sent-letter-item + .sent-letter-item{
  border-top: 1px solid var(--md-sys-color-outline-variant);
}
.sent-letter-item__info{
  flex: 1;
  min-width: 0;
}
.sent-letter-item__subject{
  font-size: 14px;
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sent-letter-item__meta{
  font-size: 11px;
  color: var(--md-sys-color-on-surface-variant);
  margin-top: 2px;
}
.sent-letter-item__actions{
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.sent-letter-item__download{
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 10px;
}
.sent-letter-item__note{
  font-size: 11px;
  color: var(--md-sys-color-on-surface-variant);
  margin-top: 4px;
  font-style: italic;
}

.status-badge{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  white-space: nowrap;
}
.status-badge--pending{
  background: #fef3c7;
  color: #92400e;
}
.status-badge--approved{
  background: #dcfce7;
  color: #166534;
}
.status-badge--rejected{
  background: #fee2e2;
  color: #991b1b;
}
:root[data-theme="dark"] .status-badge--pending{
  background: rgba(251, 191, 36, 0.18);
  color: #fbbf24;
}
:root[data-theme="dark"] .status-badge--approved{
  background: rgba(34, 197, 94, 0.18);
  color: #4ade80;
}
:root[data-theme="dark"] .status-badge--rejected{
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
}
@media (max-width: 640px){
  .sent-letter-item{
    align-items: flex-start;
  }
  .sent-letter-item__actions{
    width: 100%;
    justify-content: flex-end;
  }
}

/* -------------------------------------------------------
   Export Dialog Modal
-------------------------------------------------------- */
.modal-overlay{
  display: none;
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  align-items: center; justify-content: center;
  z-index: 9100;
}
.modal-overlay.is-active{
  display: flex;
}
.modal-card{
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  border-radius: 16px;
  min-width: 320px; max-width: 440px; padding: 24px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
}
.modal-card__header{
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px;
}
.modal-card__title{ font-size: 1.1rem; font-weight: 700; }
.modal-card__close{
  background: none; border: none; cursor: pointer; font-size: 1.4rem;
  color: var(--md-sys-color-on-surface-variant); line-height: 1;
}
.export-dialog__options{ display: flex; flex-direction: column; gap: 12px; }
.export-option{
  display: flex; align-items: center; gap: 14px;
  padding: 16px; border-radius: 12px; border: 1.5px solid var(--md-sys-color-outline);
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  cursor: pointer; text-align: start;
  transition: border-color .15s, background .15s; width: 100%;
  font-family: inherit;
}
.export-option:hover{
  border-color: var(--md-sys-color-primary);
  background: var(--md-sys-color-primary-container);
}
.export-option--draft:hover{
  border-color: var(--md-sys-color-secondary);
  background: var(--md-sys-color-secondary-container);
}
.export-option__icon{ font-size: 1.8rem; flex-shrink: 0; }
.export-option__title{ font-weight: 700; font-size: .95rem; margin-bottom: 4px; }
.export-option__desc{ font-size: .8rem; color: var(--md-sys-color-on-surface-variant); }

/* -------------------------------------------------------
   Admin Panel
-------------------------------------------------------- */
.drafts-card--wide{ max-width: 680px; width: 94vw; }
.admin-letter-item{
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.admin-letter-item__info{ flex: 1; min-width: 0; }
.admin-letter-item__subject{
  font-weight: 600; font-size: .9rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.admin-letter-item__employee{
  font-size: .78rem; color: var(--md-sys-color-on-surface-variant); margin-top: 2px;
}
.admin-letter-item__meta{
  font-size: .78rem; color: var(--md-sys-color-on-surface-variant);
}
.admin-letter-item__actions{ display: flex; gap: 8px; flex-shrink: 0; }
.btn--danger{
  color: #dc2626; border-color: #dc2626;
}
.btn--danger:hover{ background: #fee2e2; }
.sent-letter-item__reuse{ font-size: .82rem; }

/* Admin tabs */
.admin-tabs {
  display: flex; gap: 4px; padding: 8px 16px 0;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.admin-tab {
  padding: 8px 16px; border: none; background: none;
  font-size: .9rem; font-family: inherit; cursor: pointer;
  color: var(--md-sys-color-on-surface-variant);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.admin-tab--active {
  color: var(--md-sys-color-primary);
  border-bottom-color: var(--md-sys-color-primary);
  font-weight: 600;
}
.admin-panel-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* Employee list items */
.admin-employee-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.admin-employee-item__header {
  display: flex; align-items: center; gap: 8px;
}
.admin-employee-item__name {
  flex: 1; font-weight: 600; font-size: .9rem;
  color: var(--md-sys-color-on-surface);
}
.admin-employee-item__count {
  font-size: .78rem; background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  padding: 2px 8px; border-radius: 10px; white-space: nowrap;
}
.admin-employee-item__programs {
  display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px;
}
.admin-program-chip {
  font-size: .72rem; padding: 2px 7px; border-radius: 8px;
  background: var(--md-sys-color-surface-variant);
  color: var(--md-sys-color-on-surface-variant);
}

/* Program management expanded section */
.admin-program-mgmt {
  margin-top: 8px; padding: 10px 12px;
  background: var(--md-sys-color-surface-variant);
  border-radius: 8px; display: none;
}
.admin-program-mgmt.is-open { display: block; }
.admin-program-mgmt__title {
  font-size: .78rem; font-weight: 600; margin-bottom: 8px;
  color: var(--md-sys-color-on-surface-variant);
}
.admin-program-mgmt__group { margin-bottom: 8px; }
.admin-program-mgmt__group-label {
  font-size: .72rem; font-weight: 700; text-transform: uppercase;
  color: var(--md-sys-color-on-surface-variant); margin-bottom: 4px;
}
.admin-program-mgmt__programs {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.admin-program-toggle {
  display: flex; align-items: center; gap: 4px;
  font-size: .78rem; padding: 4px 8px; border-radius: 6px;
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, border-color .15s;
}
.admin-program-toggle.is-assigned {
  background: var(--md-sys-color-primary-container);
  border-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary-container);
}
.admin-program-toggle:disabled { opacity: .6; cursor: default; }

/* Admin: wrapper for program toggle + project list */
.admin-program-wrap {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}
.admin-program-projects {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0 8px;
  border-right: 2px solid var(--md-sys-color-outline-variant, #e0e0e0);
}
.admin-project-toggle {
  display: block;
  width: 100%;
  text-align: right;
  padding: 3px 10px 3px 6px;
  font-size: .75rem;
  font-family: inherit;
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  color: var(--md-sys-color-on-surface-variant);
  margin-top: 2px;
  transition: background .12s;
}
.admin-project-toggle.is-assigned {
  color: var(--md-sys-color-primary);
  font-weight: 600;
}
.admin-project-toggle:hover { background: var(--md-sys-color-surface-variant); }
.admin-project-toggle:disabled { opacity: .6; cursor: default; }

/* Generic centred status message used inside list containers */
.list-msg {
  text-align: center;
  padding: 20px;
  color: var(--md-sys-color-on-surface-variant);
}

/* -------------------------------------------------------
   Admin Full-Page Dashboard
-------------------------------------------------------- */
.admin-page-view {
  position: fixed; inset: 0; background: var(--md-sys-color-surface);
  z-index: 900; overflow-y: auto; padding: 0;
  flex-direction: column;
}
.admin-page-view:not([hidden]) { display: flex; }

.admin-page-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; background: var(--md-sys-color-primary); color: #fff;
  position: sticky; top: 0; z-index: 10;
}
.admin-page-header__brand {
  display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 1.1rem;
}
.admin-page-header__brand .badge {
  background: rgba(255,255,255,.2); color: #fff; border: none;
}
.admin-page-header__user { font-size: .9rem; opacity: .9; flex: 1; }

/* Stats grid */
.admin-stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
  padding: 20px 24px;
}
@media (max-width: 700px) { .admin-stats-grid { grid-template-columns: repeat(2, 1fr); } }
.admin-stat-card {
  background: var(--md-sys-color-surface-variant); border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 12px; padding: 16px 20px; text-align: center;
}
.admin-stat-card__value { font-size: 2rem; font-weight: 700; color: var(--md-sys-color-primary); }
.admin-stat-card__label { font-size: .85rem; color: var(--md-sys-color-on-surface-variant); margin-top: 4px; }

/* Admin tabs (full-page variant) */
.admin-page-view .admin-tabs {
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  padding: 0 24px; flex-shrink: 0;
}
.admin-page-view .admin-panel-content {
  flex: 1; overflow-y: auto; padding: 16px 24px;
}

/* Filter bar */
.admin-filter-bar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.admin-filter-btn {
  padding: 6px 16px; border-radius: 20px; border: 1px solid var(--md-sys-color-outline-variant);
  background: transparent; cursor: pointer; font-size: .85rem;
  color: var(--md-sys-color-on-surface); font-family: inherit;
}
.admin-filter-btn--active {
  background: var(--md-sys-color-primary); color: #fff;
  border-color: var(--md-sys-color-primary);
}

/* Letter review actions */
.admin-review-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.btn--approve { color: #16a34a; border-color: #16a34a; }
.btn--approve:hover { background: #f0fdf4; }
.btn--reject { color: #dc2626; border-color: #dc2626; }
.btn--reject:hover { background: #fef2f2; }
.admin-letter-item__review-note {
  margin-top: 8px; padding: 8px;
  background: #fef2f2; border: 1px solid #fecaca; border-radius: 6px;
  display: none;
}
.admin-letter-item__review-note.is-open { display: block; }
.admin-letter-item__review-note textarea {
  width: 100%; min-height: 60px; margin-bottom: 6px;
  padding: 6px 10px; border: 1px solid #fecaca; border-radius: 4px;
  font-family: inherit; font-size: .85rem; resize: vertical;
  background: #fff; color: #1f2937; box-sizing: border-box;
}

/* Feedback list items */
.feedback-item {
  padding: 14px; border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.feedback-item__header { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.feedback-item__employee { font-weight: 600; }
.feedback-item__category {
  font-size: .8rem; padding: 2px 8px; border-radius: 10px;
  background: var(--md-sys-color-surface-variant);
}
.feedback-item__message { color: var(--md-sys-color-on-surface); margin-bottom: 8px; }
.feedback-item__response {
  background: #f0fdf4; padding: 8px; border-radius: 6px; font-size: .85rem;
}
.feedback-item__actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.feedback-item__response-form { margin-top: 8px; display: none; }
.feedback-item__response-form.is-open { display: block; }
.feedback-item__response-form textarea {
  width: 100%; min-height: 60px; margin-bottom: 6px;
  padding: 6px 10px; border: 1px solid var(--md-sys-color-outline-variant); border-radius: 4px;
  font-family: inherit; font-size: .85rem; resize: vertical;
  background: var(--md-sys-color-surface); color: var(--md-sys-color-on-surface);
  box-sizing: border-box;
}

/* Feedback modal form */
.feedback-form { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.feedback-form .form-label { font-weight: 600; font-size: .9rem; }
.feedback-form .form-select,
.feedback-form .form-textarea {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--md-sys-color-outline-variant); border-radius: 6px;
  background: var(--md-sys-color-surface); color: var(--md-sys-color-on-surface);
  font-size: .95rem; font-family: inherit; box-sizing: border-box;
}
.feedback-form .form-textarea { resize: vertical; }

/* Feedback category badges */
.feedback-badge--bug { background: #fef2f2; color: #dc2626; }
.feedback-badge--suggestion { background: #eff6ff; color: #2563eb; }
.feedback-badge--question { background: #fefce8; color: #d97706; }

/* Feedback status badges */
.feedback-status--open { color: #d97706; font-weight: 600; }
.feedback-status--in_review { color: #2563eb; font-weight: 600; }
.feedback-status--resolved { color: #16a34a; font-weight: 600; }

/* -------------------------------------------------------
   Search bars in admin panels
------------------------------------------------------- */
.admin-search-bar { padding: 8px 16px; }
.admin-search-bar input[type="search"] {
  width: 100%; max-width: 420px;
  padding: 6px 12px; border-radius: 8px;
  border: 1px solid var(--md-sys-color-outline-variant);
  font-family: inherit; font-size: .9rem;
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
}

/* Users tab toolbar */
.admin-users-toolbar {
  display: flex; gap: 12px; align-items: center; padding: 8px 16px;
}

/* Deletion request badge */
.status-badge--deletion-req {
  background: #fff3cd; color: #92400e; border: 1px solid #f59e0b;
}
.admin-letter-item__del-reason {
  font-size: .76rem; color: #92400e; margin-top: 2px;
}

/* -------------------------------------------------------
   Modal box — shared by edit/add employee + deletion request
------------------------------------------------------- */
.modal-overlay[hidden] { display: none !important; }
.modal-overlay:not([hidden]) { display: flex; }
.modal-box {
  background: var(--md-sys-color-surface);
  border-radius: 16px; padding: 24px;
  width: min(420px, 94vw); max-height: 90vh; overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
}
.modal-box__title { margin: 0 0 16px; font-size: 1.1rem; font-weight: 700; }
.modal-box__desc  { margin: 0 0 12px; font-size: .88rem; }
.modal-box__body  { display: flex; flex-direction: column; gap: 12px; }
.modal-box__body label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: .85rem; font-weight: 600;
}
.modal-box__toggle {
  flex-direction: row !important; align-items: center;
  justify-content: space-between;
}
.modal-box__actions {
  display: flex; gap: 10px; margin-top: 18px; justify-content: flex-end;
}

/* Deletion request radio list */
.deletion-reasons { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.deletion-reasons label {
  display: flex; align-items: center; gap: 8px;
  font-size: .9rem; font-weight: 400; cursor: pointer;
}
