:root {
  --portal-line: #d7e1de;
  --portal-paper: #f7f8f5;
  --portal-teal: #087f78;
  --portal-ink: #17202a;
  --portal-muted: #62727a;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-width: 320px;
  background: var(--portal-paper);
}

.hidden,
[hidden] {
  display: none !important;
}

.brand {
  color: inherit;
  text-decoration: none;
}

.hero {
  gap: 24px;
}

.hero-action {
  margin-top: 20px;
}

.android-download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
  padding: 10px 18px;
  border: 1px solid #bce2d6;
  background: transparent;
  color: #fff;
  text-decoration: none;
}

.android-download-link:hover {
  background: #ffffff1a;
}

.platform-intro {
  margin-top: 18px;
}

.platform-intro h3 {
  margin: 0 0 12px;
}

.platform-intro p {
  margin: 8px 0 0;
  color: var(--portal-muted);
  line-height: 1.9;
}

.benefit-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0;
}

.benefit-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
  padding: 18px;
  border: 1px solid #dce9e4;
  border-radius: 14px;
  background: #f2f7f4;
}

.benefit-card:nth-child(2) {
  border-color: #dce5ed;
  background: #f2f6fa;
}

.benefit-card:nth-child(3) {
  border-color: #eee4d8;
  background: #faf6f0;
}

.benefit-icon {
  display: grid;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 10px;
  background: #e1eee7;
  color: #287767;
  font-weight: 800;
}

.benefit-card:nth-child(2) .benefit-icon {
  background: #e3ebf2;
  color: #456c8d;
}

.benefit-card:nth-child(3) .benefit-icon {
  background: #f1e8dc;
  color: #926a3f;
}

.benefit-card h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.benefit-card p {
  margin: 0;
  color: var(--portal-muted);
  font-size: 12px;
  line-height: 1.8;
}

.union-admin-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
  border: 1px solid #bce2d6;
  background: transparent;
  color: #fff;
  text-decoration: none;
}

.union-admin-link:hover {
  background: #ffffff1a;
}

.auth-panel {
  width: min(100%, 620px);
  margin-inline: auto;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  margin: 20px 0;
  padding: 4px;
  border: 1px solid var(--portal-line);
  border-radius: 8px;
  background: #eef3f0;
}

.segmented button,
.secondary {
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--portal-ink);
  font: inherit;
  cursor: pointer;
}

.segmented button.active {
  border-color: var(--portal-line);
  background: #fff;
  color: var(--portal-teal);
  font-weight: 700;
}

.form-grid,
.portal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.portal-grid {
  align-items: start;
  margin: 20px 0;
}

.portal-panel {
  min-width: 0;
}

.stack-form {
  display: grid;
  gap: 14px;
}

.stack-form label,
#auth-form label {
  min-width: 0;
}

.stack-form input,
.stack-form select,
.stack-form textarea,
#auth-form input {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 48px;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid #cbd7d3;
  border-radius: 7px;
  background: #fff;
  color: var(--portal-ink);
  font: inherit;
  font-size: 16px;
}

.stack-form textarea {
  min-height: 92px;
  resize: vertical;
}

.stack-form input:focus,
.stack-form select:focus,
.stack-form textarea:focus,
#auth-form input:focus {
  border-color: var(--portal-teal);
  outline: 3px solid rgb(8 127 120 / 14%);
}

.stack-form .check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}

.stack-form .check input {
  width: 20px;
  min-height: 20px;
  margin: 0;
  accent-color: var(--portal-teal);
}

.primary,
.secondary {
  min-height: 48px;
  padding: 10px 16px;
  font: inherit;
  cursor: pointer;
}

.primary:disabled,
.secondary:disabled {
  cursor: wait;
  opacity: 0.65;
}

.secondary {
  border-color: var(--portal-line);
  background: #fff;
  color: var(--portal-teal);
}

.account-heading,
.invoice-row,
.record-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.account-heading h2 {
  margin: 0;
  font-size: 22px;
}

.account-heading p {
  margin: 4px 0 0;
}

.account-stats {
  margin-top: 22px;
}

.record-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.record-row,
.invoice-row {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--portal-line);
  border-radius: 7px;
  background: #fff;
}

.record-row > div,
.invoice-details {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.record-row span,
.record-row small,
.invoice-details p {
  color: var(--portal-muted);
  overflow-wrap: anywhere;
}

.record-row bdi {
  overflow-wrap: anywhere;
}

.qr-copy {
  flex: 0 0 auto;
}

.empty-state {
  margin: 8px 0;
  color: var(--portal-muted);
  line-height: 1.8;
}

.form-message {
  min-height: 1.6em;
  margin: 0;
  color: var(--portal-teal);
  line-height: 1.8;
  overflow-wrap: anywhere;
}

.form-message.is-error {
  color: #a92f24;
}

.mileage-hint {
  min-height: 0;
  margin-top: -8px;
}

.invoice-section {
  margin-top: 20px;
}

.invoice-row {
  align-items: flex-start;
}

.invoice-details {
  flex: 1;
}

.invoice-details p {
  margin: 0;
}

.invoice-items-toolbar,
.invoice-grand-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.invoice-items-toolbar h4 {
  margin: 0;
  font-size: 16px;
}

.add-invoice-item {
  border-color: #e4a16f;
  background: #fff1e6;
  color: #82431d;
}

.add-invoice-item:hover {
  border-color: #d87638;
  background: #fce3d1;
}

.qr-manual-hint {
  min-height: 0;
  margin-top: -8px;
  color: var(--portal-muted);
  font-size: 13px;
}

.invoice-table-scroll {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--portal-line);
  border-radius: 7px;
  background: #fff;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

.invoice-entry-table,
.invoice-view-table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
}

.invoice-entry-table {
  min-width: 690px;
}

.invoice-view-table {
  min-width: 540px;
}

.invoice-entry-table th,
.invoice-entry-table td,
.invoice-view-table th,
.invoice-view-table td {
  padding: 10px;
  border-bottom: 1px solid var(--portal-line);
  vertical-align: middle;
}

.invoice-entry-table th,
.invoice-view-table th {
  background: #eef3f0;
  color: var(--portal-ink);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.invoice-entry-table input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 8px;
  border: 1px solid #cbd7d3;
  border-radius: 6px;
  font: inherit;
  font-size: 16px;
}

.invoice-entry-table td:nth-child(1) {
  width: 32%;
}

.invoice-entry-table td:nth-child(2),
.invoice-entry-table td:nth-child(3) {
  width: 19%;
}

.invoice-entry-table td:nth-child(4) {
  min-width: 110px;
  white-space: nowrap;
}

.invoice-entry-table td:nth-child(5) {
  width: 80px;
}

.invoice-remove-button {
  min-height: 42px;
  padding: 6px 10px;
  color: #a92f24;
}

.invoice-grand-total {
  padding: 12px 4px;
  font-size: 16px;
}

.invoice-grand-total strong {
  color: var(--portal-teal);
}

.invoice-actions {
  display: grid;
  gap: 8px;
  flex: 0 0 150px;
}

.qr-resolve-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
}

.qr-resolve-row input {
  direction: ltr;
}

.muted {
  color: var(--portal-muted);
}

@media (max-width: 760px) {
  .shell {
    display: block;
    min-height: 100vh;
  }

  .sidebar {
    width: 100%;
    padding: 14px 16px 10px;
  }

  .brand {
    margin: 0 2px 12px;
  }

  .sidebar nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .nav-item {
    min-height: 44px;
    margin: 0;
    padding: 8px 10px;
    text-align: center;
    font-size: 14px;
  }

  .sidebar-note {
    margin-top: 8px;
    padding: 5px 8px;
  }

  .content {
    width: 100%;
    max-width: none;
    padding: 20px 16px calc(24px + env(safe-area-inset-bottom));
  }

  .topbar {
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
  }

  .topbar h1,
  .section-head h2 {
    font-size: 22px;
  }

  .hero {
    min-height: 0;
    padding: 24px 20px;
  }

  .hero h2 {
    font-size: 23px;
    line-height: 1.6;
  }

  .hero-orbit {
    display: none;
  }

  .stats,
  .benefit-grid,
  .panel-grid,
  .portal-grid,
  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .stats {
    gap: 10px;
    margin-top: 14px;
  }

  .stats article {
    min-height: 88px;
  }

  .panel-grid,
  .portal-grid {
    gap: 12px;
  }

  .account-heading {
    align-items: flex-start;
  }

  .account-heading .secondary {
    flex: 0 0 auto;
  }

  .invoice-row {
    flex-direction: column;
  }

  .invoice-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    flex-basis: auto;
  }
}

@media (max-width: 380px) {
  .content {
    padding-inline: 12px;
  }

  .panel,
  .form-panel {
    padding: 18px 14px;
  }

  .record-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .qr-resolve-row {
    grid-template-columns: minmax(0, 1fr);
  }
}
/* ==================== یکسان‌سازی فرم‌ها ==================== */

.stack-form input,
.stack-form select,
.stack-form textarea,
#auth-form input,
#auth-form select {
  font-family: Vazirmatn, Tahoma, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 46px;
  padding: 10px 14px;
  border: 1px solid #cbd7d3;
  border-radius: 8px;
  background: #fff;
  color: var(--portal-ink);
  width: 100%;
  box-sizing: border-box;
}

.stack-form select,
#auth-form select {
  appearance: none;
  -webkit-appearance: none;
  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 fill='%2362727a' d='M1.41 0L6 4.58 10.59 0 12 1.41l-6 6-6-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 14px center;
  padding-left: 38px;
}

.stack-form select:disabled,
#auth-form select:disabled {
  background-color: #f5f7f5;
  color: #71808b;
  cursor: not-allowed;
}

.stack-form label,
#auth-form label {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--portal-ink);
}

button.primary,
button.secondary,
.segmented button {
  font-family: Vazirmatn, Tahoma, sans-serif;
  font-size: 14.5px;
  min-height: 46px;
}

/* انتخاب نوع حساب — جمع‌وجور و هم‌سبک با تب ورود/ثبت‌نام */
.account-type-picker {
  display: grid;
  gap: 8px;
  margin: 4px 0 2px;
}

.account-type-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted, #71808b);
}

.account-type-segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 3px;
  background: #eef3f2;
  border-radius: 10px;
  border: 1px solid #e3e9e9;
}

.account-type-option {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  color: #5f7270;
  border-radius: 8px;
  padding: 8px 10px;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.account-type-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.account-type-option span {
  line-height: 1.2;
}

.account-type-option:has(input:checked) {
  background: #fff;
  color: var(--navy, #163c4a);
  box-shadow: 0 1px 3px rgba(22, 60, 74, 0.12);
}

.account-type-option:hover {
  color: var(--navy, #163c4a);
}

/* چیدمان ورود / ثبت‌نام */
.auth-layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(320px, 440px);
  gap: 28px;
  align-items: stretch;
  justify-content: center;
  max-width: 900px;
  margin: 0 auto;
  padding: 12px 0 32px;
}

.auth-aside {
  background: linear-gradient(160deg, #163c4a 0%, #087f78 100%);
  color: #e9f3ef;
  border-radius: 16px;
  padding: 28px 26px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 10px 30px rgba(22, 60, 74, 0.18);
}

.auth-aside .eyebrow.light {
  color: #bce2d6;
  margin-bottom: 0;
}

.auth-aside h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.45;
  color: #fff;
}

.auth-aside-lead {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.9;
  color: #cbe7df;
}

.auth-aside-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.auth-aside-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  line-height: 1.7;
  color: #e4f2ee;
}

.auth-check {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #9fe0c8;
  font-size: 11px;
  flex-shrink: 0;
  margin-top: 2px;
}

.auth-aside-actions {
  margin-top: auto;
  display: grid;
  gap: 8px;
  padding-top: 16px;
}

.auth-aside-actions .secondary {
  display: block;
  text-align: center;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
}

.auth-aside-actions .secondary:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* فرم کمی جمع‌وجورتر در این چیدمان */
.auth-layout .auth-panel {
  margin: 0;
  width: 100%;
  max-width: none;
}

/* موبایل: کارت بالا، فرم پایین */
@media (max-width: 800px) {
  .auth-layout {
    grid-template-columns: 1fr;
    gap: 18px;
    max-width: 440px;
    padding: 8px 0 24px;
  }

  .auth-aside {
    padding: 22px 20px;
  }

  .auth-aside h2 {
    font-size: 19px;
  }
}

.membership-panel {
  margin-bottom: 18px;
  border: 1px solid #e3e9e9;
}

.membership-panel.is-required {
  border-color: #eb8957;
  background: #fff8f4;
}

.membership-panel.is-active {
  border-color: #b7e0d4;
  background: #f3fbf8;
}

.membership-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.membership-actions .primary,
.membership-actions .secondary {
  min-width: 140px;
}
