:root {
  --brand: #193973;
  --brand-2: #DFDFDF;
  --brand-light: #2b528f;
  --brand-soft: #3d6ab0;
  --bg: #DFDFDF;
  --bg-accent: #d4d4d4;
  --surface: #ffffff;
  --ink: #121a2e;
  --muted: #5a667a;
  --line: #c8c8c8;
  --line-soft: #d8d8d8;
  --accent: #193973;
  --accent-2: #122a56;
  --accent-soft: rgba(25, 57, 115, 0.12);
  --danger: #b42318;
  --ok: #067647;
  --warn: #b54708;
  --sidebar: #0c1838;
  --sidebar-2: #132850;
  --shadow: 0 12px 32px rgba(18, 26, 46, 0.07);
  --radius: 16px;
  --font: "Vazirmatn", "IRANSans", Tahoma, sans-serif;
  --sidebar-w: 272px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  max-width: 100%;
  overflow-x: hidden;
}
body, .app-body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 0% 0%, rgba(25, 57, 115, 0.1), transparent 55%),
    linear-gradient(180deg, #f5f5f5 0%, var(--brand-2) 55%, #d8d8d8 100%);
  overflow-x: hidden;
}
img, svg, video { max-width: 100%; height: auto; }


a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }

/* ===== App shell: fixed sidebar, scroll only main ===== */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.sidebar {
  height: 100vh;
  height: 100dvh;
  background:
    linear-gradient(180deg, rgba(255,255,255,.05), transparent 28%),
    radial-gradient(420px 280px at 0% 0%, rgba(61, 106, 176, .28), transparent 65%),
    linear-gradient(165deg, var(--sidebar) 0%, var(--sidebar-2) 55%, #193973 140%);
  color: #e8eef8;
  overflow: hidden;
  position: relative;
  z-index: 5;
  border-left: 1px solid rgba(255,255,255,.06);
}

.sidebar-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1rem;
  gap: 1.25rem;
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-shrink: 0;
}
.brand-text { display: grid; gap: .1rem; min-width: 0; }
.brand strong {
  font-size: .95rem;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-text span,
.brand-text > span {
  color: rgba(232, 238, 248, .65);
  font-size: .75rem;
}
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: linear-gradient(145deg, var(--brand-light), var(--brand));
  color: #fff;
  font-weight: 700;
  font-size: .9rem;
  flex-shrink: 0;
  box-shadow: 0 8px 20px rgba(0,0,0,.22);
  overflow: hidden;
}
.brand-mark-img {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  object-fit: contain;
  object-position: center;
  flex-shrink: 0;
  box-shadow: 0 8px 20px rgba(0,0,0,.18);
  background: transparent;
}
.brand-light { color: #fff; }
.brand-center { justify-content: center; margin-bottom: 1rem; }

.nav {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
.nav a {
  color: #c5d2e8;
  padding: .72rem .85rem;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: .55rem;
  transition: background .15s ease, color .15s ease;
}
.nav a:hover, .nav a.active {
  background: rgba(255,255,255,.09);
  color: #fff;
}
.nav a.active {
  background: rgba(61, 106, 176, .28);
  box-shadow: inset 0 0 0 1px rgba(61, 106, 176, .4);
}
.nav-ico {
  width: 1.1rem;
  text-align: center;
  opacity: .8;
  font-size: .75rem;
}

.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: .75rem;
  flex-shrink: 0;
  padding-top: .5rem;
  border-top: 1px solid rgba(255,255,255,.08);
}
.user-chip {
  background: rgba(255,255,255,.07);
  padding: .7rem .8rem;
  border-radius: 14px;
  display: grid;
  gap: .15rem;
}
.user-chip .user-role {
  font-size: .7rem;
  color: #9db6e0;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.user-chip strong { font-size: .9rem; }
.user-chip small {
  color: rgba(231,243,240,.65);
  font-size: .78rem;
  direction: ltr;
  text-align: right;
}

.main {
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.35rem 1.6rem 2.2rem;
  scroll-behavior: smooth;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.15rem;
}
.topbar-start {
  display: flex;
  align-items: flex-end;
  gap: .75rem;
  min-width: 0;
}
.menu-toggle {
  display: none;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  cursor: pointer;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  gap: 0;
}
.menu-toggle-bars {
  display: grid;
  gap: 4px;
  width: 18px;
}
.menu-toggle-bars span {
  display: block;
  height: 2px;
  border-radius: 2px;
  background: var(--ink);
}
.sidebar-backdrop {
  display: none;
}
.eyebrow {
  margin: 0 0 .2rem;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 500;
}
.topbar h1 {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -.01em;
}
.date-pill {
  display: inline-flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .4rem .8rem;
  color: var(--muted);
  font-size: .88rem;
  box-shadow: var(--shadow);
}

.content { display: grid; gap: 1rem; }

.panel, .stat-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel { padding: 1.15rem 1.25rem; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}
.panel-head h2 { margin: 0; font-size: 1.05rem; font-weight: 700; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}
.stat-card {
  padding: 1.15rem 1.25rem;
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: "";
  position: absolute;
  inset-inline-end: -20px;
  top: -20px;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: var(--accent-soft);
}
.stat-label { color: var(--muted); font-size: .88rem; position: relative; }
.stat-value {
  display: block;
  margin-top: .4rem;
  font-size: 1.85rem;
  font-weight: 700;
  position: relative;
}
.stat-value-sm { font-size: 1.2rem; }
.stat-sub {
  margin-top: .35rem;
  font-size: .8rem;
  position: relative;
}

.filters {
  display: grid;
  grid-template-columns: 2fr 1.2fr auto;
  gap: .75rem;
  align-items: end;
  margin-bottom: .85rem;
}
.filters.compact {
  grid-template-columns: 1fr auto;
  margin: 0;
}
.filter-actions { display: flex; gap: .5rem; }

label {
  display: grid;
  gap: .35rem;
  font-size: .88rem;
  color: var(--muted);
  font-weight: 500;
}
label.grow { min-width: 0; }
input, select, textarea, button { font: inherit; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .7rem .85rem;
  background: #fff;
  color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-light);
  box-shadow: 0 0 0 3px rgba(25, 57, 115, .14);
}
textarea { resize: vertical; }
.check {
  display: flex;
  align-items: center;
  gap: .5rem;
  color: var(--ink);
}
.check input { width: auto; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .9rem 1rem;
}
.span-2 { grid-column: span 2; }
.stack { display: grid; gap: .9rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 12px;
  padding: .58rem 1rem;
  cursor: pointer;
  white-space: nowrap;
  font-weight: 600;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
}
.btn:hover { border-color: #a8b6cc; transform: translateY(-1px); }
.btn-primary {
  background: linear-gradient(180deg, var(--brand-light), var(--accent));
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 8px 18px rgba(25, 57, 115, .28);
}
.btn-primary:hover {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: #fff;
}
.btn-danger { color: var(--danger); border-color: #f3c1bc; background: #fff5f4; }
.btn-ghost {
  background: transparent;
  border-color: rgba(255,255,255,.18);
  color: #e8f4f1;
}
.btn-ghost:hover { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.28); }
.btn-block { width: 100%; }
.btn-sm { padding: .38rem .7rem; font-size: .84rem; border-radius: 10px; }
.btn-lg { padding: .8rem 1rem; font-size: 1rem; }

.actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.row-actions { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.inline { display: inline; margin: 0; }

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
}
.table-wrap > table,
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
  table-layout: fixed;
}
.table-wrap th,
.table-wrap td,
.data-table th,
.data-table td {
  text-align: right;
  padding: .78rem .7rem;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.table-wrap th,
.data-table th {
  color: var(--muted);
  font-weight: 600;
  background: #f0f0f0;
  font-size: .82rem;
}
.table-wrap tr:last-child td,
.data-table tr:last-child td { border-bottom: none; }
.table-wrap tbody tr:hover td,
.data-table tbody tr:hover td { background: #f9fcfb; }
.empty { text-align: center; color: var(--muted); padding: 1.4rem !important; }
.num,
.col-num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  direction: ltr;
  text-align: left !important;
  unicode-bidi: isolate;
  white-space: nowrap;
}
.col-text {
  text-align: right !important;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.col-action {
  text-align: center !important;
  white-space: nowrap;
}
.col-num-strong {
  font-weight: 700;
}
.portal-table .col-period { width: 22%; }
.portal-table .col-month { width: 16%; }
.portal-table .col-money { width: 16%; }
.portal-table .col-action { width: 14%; }

.badge {
  display: inline-block;
  padding: .18rem .55rem;
  border-radius: 999px;
  font-size: .78rem;
  margin-inline-start: .35rem;
  font-weight: 600;
}
.badge-draft { background: #fff7ed; color: var(--warn); }
.badge-final { background: #ecfdf3; color: var(--ok); }

.alert {
  padding: .9rem 1rem;
  border-radius: 14px;
  margin-bottom: 1rem;
  border: 1px solid;
  font-weight: 500;
}
.alert-success { background: #ecfdf3; border-color: #abefc6; color: var(--ok); }
.alert-error { background: #fef3f2; border-color: #fecdca; color: var(--danger); }

.muted { color: var(--muted); }
.callout {
  background: linear-gradient(180deg, #f3f3f3, var(--brand-2));
  border: 1px solid #c9c9c9;
  border-radius: 14px;
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}
.callout p { margin: .35rem 0; }

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-top: 1rem;
}
.pagination a {
  min-width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
}
.pagination a.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.log-list { margin: 0; padding-inline-start: 1.1rem; color: var(--muted); }
.log-list li { margin-bottom: .4rem; }

/* ===== Auth / Login ===== */
.auth-page {
  min-height: 100vh;
  margin: 0;
  background: #0c1838;
  display: flex;
  flex-direction: column;
}
.auth-shell {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  background:
    radial-gradient(520px 300px at 80% 15%, rgba(25, 57, 115, .08), transparent 55%),
    linear-gradient(180deg, #f2f2f2 0%, var(--brand-2) 50%, #d0d0d0 100%);
}
.auth-hero {
  padding: 2.5rem;
  background:
    radial-gradient(640px 380px at 18% 12%, rgba(61, 106, 176, .42), transparent 58%),
    radial-gradient(520px 320px at 90% 80%, rgba(25, 57, 115, .55), transparent 55%),
    linear-gradient(160deg, #0a142e 0%, #132850 42%, #193973 100%);
  color: #eaf0f8;
  display: grid;
  align-items: center;
  justify-items: center;
}
.auth-hero-inner {
  max-width: 440px;
  width: 100%;
  text-align: center;
}
.auth-logo-wrap {
  display: grid;
  place-items: center;
  margin: 0 auto 1.35rem;
}
.auth-logo {
  width: min(220px, 68vw);
  height: auto;
  display: block;
  border-radius: 18px;
  background: transparent;
  box-shadow: 0 18px 46px rgba(0, 0, 0, .28);
}
.auth-logo-mobile {
  display: none;
  width: 108px;
  height: auto;
  margin: 0 auto 1rem;
  border-radius: 14px;
  background: transparent;
  box-shadow: 0 10px 28px rgba(18, 26, 46, .12);
}
.auth-hero h2 {
  margin: 0 0 .7rem;
  font-size: clamp(1.35rem, 2.2vw, 1.85rem);
  line-height: 1.4;
}
.auth-hero p {
  margin: 0 auto;
  max-width: 34ch;
  color: rgba(234, 240, 248, .8);
  line-height: 1.85;
  font-size: .95rem;
}
.auth-footer {
  flex-shrink: 0;
  text-align: center;
  padding: .85rem 1rem;
  font-size: .82rem;
  color: rgba(234, 240, 248, .72);
  background: rgba(0, 0, 0, .22);
  border-top: 1px solid rgba(255,255,255,.06);
}
.auth-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.auth-card-wide {
  margin: auto;
  width: min(440px, calc(100% - 2.5rem));
  padding: 1.6rem 1.5rem 1.7rem;
  border-radius: 20px;
}
.auth-card h1 {
  margin: .9rem 0 .35rem;
  font-size: 1.35rem;
  text-align: right;
}
.auth-hint {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: .88rem;
}
.login-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .35rem;
  background: var(--brand-2);
  padding: .3rem;
  border-radius: 14px;
}
.login-tab {
  text-align: center;
  padding: .65rem .5rem;
  border-radius: 11px;
  color: var(--muted);
  font-weight: 600;
  font-size: .9rem;
}
.login-tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 4px 14px rgba(18, 26, 46, .08);
}

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .filter-actions { grid-column: 1 / -1; }
  .preview-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 960px) {
  .app-shell {
    display: block;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  .menu-toggle { display: inline-flex; }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(12, 24, 56, .45);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
    z-index: 40;
  }
  body.nav-open {
    overflow: hidden;
  }
  body.nav-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: auto;
    right: 0;
    width: min(300px, 88vw);
    max-width: 100%;
    height: 100vh;
    height: 100dvh;
    z-index: 50;
    /* Always slide from the physical right (matches RTL hamburger) */
    transform: translate3d(105%, 0, 0);
    transition: transform .24s ease;
    box-shadow: -12px 0 40px rgba(0,0,0,.28);
    border-left: none;
    pointer-events: none;
    visibility: hidden;
  }
  body.nav-open .sidebar {
    transform: translate3d(0, 0, 0);
    pointer-events: auto;
    visibility: visible;
  }

  .sidebar-inner {
    height: 100%;
    gap: 1rem;
    padding: 1rem;
    overflow: hidden;
  }
  .nav {
    flex-direction: column;
    flex-wrap: nowrap;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar-foot {
    border-top: 1px solid rgba(255,255,255,.08);
    padding-top: .75rem;
    grid-template-columns: 1fr;
  }

  .main {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem .9rem 1.5rem;
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
    -webkit-overflow-scrolling: touch;
  }

  .content,
  .panel,
  .table-wrap {
    max-width: 100%;
    min-width: 0;
  }

  .topbar {
    align-items: center;
    gap: .75rem;
    margin-bottom: .95rem;
  }
  .topbar h1 { font-size: 1.25rem; }
  .date-pill {
    font-size: .78rem;
    padding: .35rem .65rem;
    white-space: nowrap;
  }

  .stats-grid,
  .filters,
  .form-grid,
  .auth-shell,
  .template-grid,
  .preview-summary,
  .profile-grid { grid-template-columns: 1fr; }
  .span-2,
  .profile-card.span-2 { grid-column: auto; }

  .panel-head {
    flex-direction: column;
    align-items: stretch;
  }
  .panel-head .filters.compact {
    grid-template-columns: 1fr;
  }
  .filter-actions {
    flex-wrap: wrap;
  }
  .filter-actions .btn { flex: 1 1 auto; }

  .table-wrap > table,
  .data-table {
    table-layout: auto;
    min-width: 640px;
  }
  .settings-items-table { min-width: 560px; }
  /* Never force payslip tables wide */
  .payslip-body table,
  .ps-table {
    min-width: 0 !important;
    width: 100% !important;
    table-layout: auto !important;
  }

  /* Portal: card rows instead of wide table */
  .portal-table {
    display: block;
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100%;
    table-layout: auto;
    border-collapse: separate;
    border-spacing: 0;
  }
  .portal-table colgroup { display: none; }
  .portal-table thead { display: none; }
  .portal-table tbody {
    display: grid;
    gap: .75rem;
    width: 100%;
  }
  .portal-table tr {
    display: grid;
    gap: .55rem;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: .9rem .85rem;
    background: #f8f9fb;
    border: 1px solid var(--line-soft);
    border-radius: 14px;
    overflow: hidden;
  }
  .portal-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 0;
    border: 0;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    font-size: .9rem;
  }
  .portal-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: .78rem;
    font-weight: 600;
    flex: 0 1 auto;
    max-width: 45%;
  }
  .portal-table td > :not(::before) {
    min-width: 0;
  }
  .portal-table td.col-text,
  .portal-table td.col-num {
    overflow: visible;
    text-overflow: unset;
    white-space: normal;
  }
  .portal-table .col-action,
  .portal-table td.col-action {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    margin-top: .25rem;
    padding-top: .7rem;
    border-top: 1px solid var(--line-soft);
    text-align: center !important;
    white-space: normal;
    overflow: visible;
  }
  .portal-table td.col-action::before { display: none !important; content: none !important; }
  .portal-table td.col-action .btn,
  .portal-table td.col-action .portal-slip-btn {
    display: flex;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    justify-content: center;
    align-items: center;
    white-space: nowrap;
    text-align: center;
    line-height: 1.35;
    min-height: 44px;
    padding: .65rem .75rem;
    overflow: visible;
    margin: 0;
    float: none;
    position: static;
  }
  .portal-table .empty {
    display: block;
    text-align: center;
    padding: 1rem !important;
  }
  .portal-table .empty::before { display: none; }

  .auth-hero { display: none; }
  .auth-logo-mobile { display: block; }
  .auth-page {
    min-height: 100vh;
    min-height: 100dvh;
    background:
      radial-gradient(520px 280px at 50% -10%, rgba(25, 57, 115, .1), transparent 60%),
      linear-gradient(180deg, #f5f5f5 0%, var(--brand-2) 100%);
  }
  .auth-shell {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem .85rem 1rem;
  }
  .auth-footer {
    color: var(--muted);
    background: transparent;
    border-top: 1px solid var(--line-soft);
    padding-inline: .85rem;
    line-height: 1.6;
  }
  .auth-card-wide {
    width: min(440px, 100%);
    margin: 0;
    padding: 1.25rem 1.1rem 1.35rem;
  }
}

@media (max-width: 960px) {
  .portal-panel .table-wrap {
    border: 0;
    overflow: visible;
  }
  .portal-panel {
    padding: 1rem;
  }
}

@media (max-width: 720px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-value { font-size: 1.55rem; }
  .topbar-meta .date-pill { display: none; }
  .btn-lg { width: 100%; }
  .pagination { justify-content: center; }
  .login-tab { font-size: .84rem; padding: .7rem .4rem; }
  .auth-card h1 { font-size: 1.2rem; }
  .auth-hint { font-size: .82rem; }
}

@media (max-width: 480px) {
  .main { padding: .85rem .7rem 1.25rem; }
  .panel { padding: 1rem; }
  .brand-text strong { font-size: .88rem; }
  .auth-card-wide { border-radius: 16px; }
  .auth-logo-mobile { width: 96px; }
  input, select, textarea, .btn {
    min-height: 44px;
  }
  .menu-toggle {
    width: 44px;
    height: 44px;
  }
}

@media (max-width: 360px) {
  .topbar h1 { font-size: 1.1rem; }
  .login-tabs { gap: .25rem; }
  .auth-footer { font-size: .74rem; }
}


/* ===== Payslip settings ===== */
.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: .85rem;
}
.settings-tabs a {
  padding: .55rem .9rem;
  border-radius: 999px;
  background: var(--brand-2);
  color: var(--muted);
  font-weight: 600;
  font-size: .88rem;
}
.settings-tabs a.active {
  background: var(--accent);
  color: #fff;
}
.template-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.template-card {
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  padding: 1rem;
  background: #fff;
  display: grid;
  gap: .85rem;
}
.template-card.is-active {
  border-color: #8aa4d0;
  box-shadow: 0 0 0 3px rgba(25, 57, 115, .1);
}
.template-card-top { display: flex; gap: .85rem; }
.template-card h3 { margin: 0 0 .25rem; font-size: 1rem; }
.template-card p { margin: 0; color: var(--muted); font-size: .88rem; line-height: 1.6; }
.template-swatch {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  flex-shrink: 0;
  border: 1px solid var(--line);
}
.tpl-swatch-classic { background: linear-gradient(145deg, #122a56, #2b528f); }
.tpl-swatch-compact { background: linear-gradient(145deg, #334155, #94a3b8); }
.tpl-swatch-formal { background: linear-gradient(145deg, #111827, #6b7280); }
.tpl-swatch-modern { background: linear-gradient(125deg, #0c1838, #193973 55%, #3d6ab0); }
.template-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
  color: var(--muted);
  font-size: .82rem;
}
.bulk-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-bottom: 1rem;
}
.item-group { margin-bottom: 1.25rem; }
.item-group-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: .5rem;
}
.item-group-head h3 { margin: 0; font-size: 1rem; }
.settings-items-table .center { text-align: center; }
.settings-items-table code {
  font-size: .78rem;
  background: #f1f5f6;
  padding: .15rem .35rem;
  border-radius: 6px;
  direction: ltr;
  display: inline-block;
}
.preview-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .85rem;
}
.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.profile-card {
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  padding: 1.1rem 1.15rem;
  background: #fbfcfd;
}
.profile-card h3 {
  margin: 0 0 .85rem;
  font-size: 1rem;
}
.profile-card.span-2 { grid-column: span 2; }
.profile-dl {
  margin: 0;
  display: grid;
  gap: .65rem;
}
.profile-dl div {
  display: grid;
  gap: .15rem;
}
.profile-dl dt {
  color: var(--muted);
  font-size: .8rem;
}
.profile-dl dd {
  margin: 0;
  font-weight: 600;
}
a.user-chip-link {
  color: inherit;
  text-decoration: none;
}
a.user-chip-link:hover {
  background: rgba(255,255,255,.12);
}
