
@font-face {
  font-family: Nazanin;
  src: url('assets/B_Nazanin.ttf');
}

@font-face {
  font-family: Titr;
  src: url('assets/B_Titr_Bold.ttf');
}

* {
  box-sizing: border-box;
}

:root {
  --bg: #f7fafd;
  --blue: #144b91;
  --ink: #1e3246;
  --line: #dce2e8;
  --head: #e5eff9;
}

html {
  direction: rtl;
  height: 100%;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  position: fixed;
  inset: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Nazanin, serif;
  font-size: 17px;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid #bec8d2;
  border-radius: 7px;
  background: #fff;
  color: #19375a;
  padding: 7px 12px;
  min-height: 42px;
  cursor: pointer;
}

button:active {
  background: #eaf2fb;
}

button:disabled {
  cursor: not-allowed;
}

.hidden {
  display: none !important;
}

.screen {
  width: 100%;
  height: 100%;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

/* صفحه ورود */

.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 12px max(16px, env(safe-area-inset-bottom));
  text-align: center;
  overflow-y: auto;
}

.welcome-logo {
  width: min(82vw, 360px);
  height: 105px;
  object-fit: contain;
}

.welcome h1 {
  font: 25px/1.7 Titr, serif;
  color: var(--blue);
  margin: 12px 0 0;
  line-height: 1.65;
}

.welcome-spacer {
  flex: 1;
  min-height: 20px;
}

.credit {
  font: 18px/1.35 Titr, serif;
  margin: 0 0 8px;
  color: #323c46;
}

.primary {
  background: white;
  color: var(--blue);
}

.enter {
  width: min(250px, 85vw);
  min-height: 54px;
  font-size: 18px;
  flex-shrink: 0;
}

/* صفحات اصلی برنامه */

.app-screen {
  padding: 6px 8px max(8px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.small-logo {
  height: 42px;
  width: 100%;
  object-fit: contain;
  flex-shrink: 0;
}

.page-title {
  font: 21px/1.4 Titr, serif;
  color: var(--blue);
  text-align: center;
  direction: rtl;
  margin: 0 0 4px;
  padding: 3px;
  flex-shrink: 0;
}

.top-actions {
  display: flex;
  flex-direction: row;
  direction: rtl;
  gap: 8px;
  flex-shrink: 0;
}

.top-actions button {
  flex: 1;
  min-width: 0;
}

.secondary {
  background: #f5f7fa;
}

/* جستجو ثابت می‌ماند */

input[type="search"] {
  width: 100%;
  height: 48px;
  min-height: 48px;
  flex-shrink: 0;
  border: 1px solid #bec8d2;
  border-radius: 6px;
  background: white;
  padding: 8px 12px;
  text-align: right;
  direction: rtl;
  outline-color: #7aa7d8;
}

/* سرستون ثابت */

.table-head {
  display: flex;
  flex-direction: row;
  direction: rtl;
  align-items: center;
  background: var(--head);
  min-height: 42px;
  flex-shrink: 0;
  font: 14px Titr, serif;
  text-align: center;
}

.code-col {
  width: 70px;
  flex: 0 0 70px;
  text-align: center;
}

.desc-col {
  flex: 1;
  min-width: 0;
  text-align: center;
}

/* فقط ردیف‌های جدول اسکرول می‌خورند */

.service-list {
  flex: 1 1 0;
  height: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  border-radius: 3px;
}

.service-row {
  display: flex;
  flex-direction: row;
  direction: rtl;
  align-items: center;
  background: white;
  border-bottom: 1px solid var(--line);
  min-height: 58px;
  padding: 3px 6px;
  cursor: pointer;
}

.service-row .code-col {
  font: 16px/1.2 Nazanin, serif;
  text-align: center;
  overflow-wrap: anywhere;
}

.service-row .desc-col {
  font: 16px/1.15 Nazanin, serif;
  text-align: right;
  direction: rtl;
  unicode-bidi: plaintext;
  padding: 3px 5px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.empty {
  padding: 20px;
  text-align: center;
  color: #68798a;
}

/* نوار جمع در پایین صفحات */

.sum-bar {
  display: block;
  width: 100%;
  flex: 0 0 auto;
  background: #e6f0fa;
  border-color: #d6e3f0;
  min-height: 46px;
  margin-top: 0;
}

.sum-bar.hidden {
  display: none !important;
}

/* صفحه جزئیات */

#detail {
  direction: rtl;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.detail-nav {
  display: flex;
  flex-direction: row;
  direction: rtl;
  gap: 8px;
  flex-shrink: 0;
}

.detail-nav button:first-child {
  flex: 1;
  text-align: center;
}

.star {
  width: 64px;
  flex: 0 0 64px;
  font-size: 28px;
  padding: 0;
}

#detail .page-title {
  flex-shrink: 0;
}

.detail-card {
  direction: rtl;
  text-align: right;
  background: white;
  border-radius: 5px;
  padding: 8px 10px;
  flex: 1 1 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.pair-head,
.pair-values {
  display: grid;
  direction: rtl;
  grid-template-columns: 1fr 1fr;
  text-align: center;
  align-items: center;
}

.pair-head,
.triple-head {
  background: var(--head);
  font: 14px Titr, serif;
  min-height: 34px;
  align-items: center;
}

.pair-values {
  min-height: 42px;
}

.detail-label {
  font: 14px Titr, serif;
  text-align: right;
  direction: rtl;
  padding: 7px 2px 2px;
}

.detail-description {
  font: 16px/1.5 Nazanin, serif;
  text-align: right;
  direction: rtl;
  unicode-bidi: plaintext;
  min-height: 95px;
  padding: 4px 8px 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.triple-head,
.triple-values {
  display: grid;
  direction: rtl;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  text-align: center;
  align-items: center;
}

.triple-head {
  min-height: 34px;
}

.triple-values {
  min-height: 42px;
}

.franchise {
  display: flex;
  flex-direction: row;
  direction: rtl;
  justify-content: center;
  align-items: center;
  gap: 12px;
  min-height: 54px;
}

.franchise label {
  direction: rtl;
}

.franchise select {
  min-width: 100px;
  padding: 6px;
  background: white;
  border: 1px solid #bec8d2;
  border-radius: 6px;
  direction: rtl;
}

.detail-actions {
  display: flex;
  flex-direction: row;
  direction: rtl;
  gap: 7px;
}

.detail-actions button {
  flex: 1;
  min-width: 0;
  min-height: 52px;
  font-size: 16px;
}

/* نوار جمع صفحه جزئیات */

#detail .sum-bar {
  display: block;
  flex: 0 0 auto;
  width: 100%;
  min-height: 46px;
  margin-top: 0;
}

#detail .sum-bar.hidden {
  display: none !important;
}

/* پیام‌های کوتاه */

#toast {
  position: fixed;
  bottom: calc(18px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translate(-50%, 20px);
  background: #1f354b;
  color: white;
  border-radius: 8px;
  padding: 8px 15px;
  opacity: 0;
  pointer-events: none;
  transition: .2s;
  max-width: 90vw;
  text-align: center;
  z-index: 5;
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (min-width: 700px) {
  .app-screen {
    max-width: 850px;
    width: 100%;
    margin: 0 auto;
  }

  .welcome-logo {
    height: 135px;
  }

  .welcome h1 {
    font-size: 30px;
  }

  .service-row .desc-col {
    font-size: 18px;
  }

  .detail-card {
    padding: 12px 18px;
  }
}
