:root {
  --primary: #0758b7;
  --primary-dark: #063f82;
  --primary-soft: #eaf4ff;
  --surface: #ffffff;
  --background: #f4f9ff;
  --text: #12233b;
  --muted: #617188;
  --border: #dbe6f2;
  --success: #138a52;
  --success-soft: #e9f8f0;
  --danger: #cf3f36;
  --danger-soft: #fff0ee;
  --shadow: 0 10px 30px rgba(18, 54, 93, 0.08);
  font-family: Tahoma, Arial, sans-serif;
  color: var(--text);
  background: var(--background);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  direction: rtl;
  background: linear-gradient(180deg, #eef7ff 0, #fff 430px);
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.page-shell {
  width: calc(100% - 28px);
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
  direction: rtl;
}

.page-shell > *, .title-row, .title-row h1, .input-card, .time-fields, .field {
  min-width: 0;
  max-width: 100%;
}

.site-header {
  padding: 30px 4px 22px;
  text-align: center;
}

.brand-logo {
  display: block;
  width: min(170px, 48vw);
  height: auto;
  margin: 0 auto 14px;
  object-fit: contain;
  object-position: center;
  border-radius: 12px;
}

.title-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

h1 { margin: 0; font-size: clamp(1.55rem, 7vw, 2.25rem); line-height: 1.35; }
.intro { max-width: 600px; margin: 10px auto 0; color: var(--muted); line-height: 1.8; font-size: .95rem; }

.info-button {
  border: 0;
  background: transparent;
  color: var(--primary);
  padding: 4px;
  font-size: 1.25rem;
  cursor: pointer;
}

form { display: grid; gap: 14px; }

.input-card, .result-card, .legal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.input-card { padding: 18px; }
.card-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 15px; }
.card-heading h2 { margin: 0; font-size: 1rem; }
.step-number { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; color: #fff; background: var(--primary); font-weight: 700; }

.segmented-control { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.segmented-control label { position: relative; cursor: pointer; }
.segmented-control input { position: absolute; opacity: 0; pointer-events: none; }
.segmented-control span { display: block; padding: 12px; border: 1px solid var(--border); border-radius: 12px; text-align: center; color: var(--muted); font-weight: 700; transition: .15s ease; }
.segmented-control input:checked + span { color: #fff; border-color: var(--primary); background: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.segmented-control input:focus-visible + span { outline: 3px solid rgba(7, 88, 183, .22); outline-offset: 2px; }

.time-fields { display: grid; gap: 14px; }
.field { display: grid; gap: 7px; color: var(--muted); font-size: .9rem; font-weight: 700; }
.field input { width: 100%; min-width: 0; max-width: 100%; min-height: 48px; padding: 10px 14px; direction: ltr; text-align: center; color: var(--text); background: #fbfdff; border: 1px solid #cbd9e8; border-radius: 11px; font-size: 1.05rem; }
.field input:focus { outline: 3px solid rgba(7, 88, 183, .15); border-color: var(--primary); }

.primary-button, .secondary-button, .community-button { display: inline-flex; align-items: center; justify-content: center; min-height: 50px; border-radius: 13px; font-weight: 700; text-decoration: none; cursor: pointer; }
.primary-button { border: 0; color: #fff; background: var(--primary); box-shadow: 0 8px 18px rgba(7, 88, 183, .22); }
.primary-button:hover, .community-button:hover { background: var(--primary-dark); }
.calculate-button { width: 100%; }
.secondary-button { width: min(100%, 280px); margin: 18px auto 0; border: 1px solid var(--primary); color: var(--primary); background: #fff; }

.error-message { margin: 0; padding: 12px 15px; color: #a92720; background: var(--danger-soft); border: 1px solid #f3c4bf; border-radius: 12px; text-align: center; line-height: 1.6; }

.results { margin-top: 24px; }
.results-title { margin: 0 0 12px; color: var(--text); text-align: center; font-size: 1.2rem; line-height: 1.5; }
.status-card { display: flex; align-items: center; gap: 13px; padding: 20px; border-radius: 18px; border: 1px solid; box-shadow: var(--shadow); }
.status-card.is-success { color: #08693d; background: var(--success-soft); border-color: #b9e6ce; }
.status-card.is-required { color: #a52a23; background: var(--danger-soft); border-color: #f2c1bc; }
.status-dot { flex: 0 0 auto; width: 16px; height: 16px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 5px rgba(255,255,255,.7); }
.eyebrow { margin: 0 0 3px; font-size: .78rem; opacity: .75; }
.status-card h2 { margin: 0; font-size: 1.2rem; }

.result-grid { display: grid; gap: 11px; margin-top: 12px; }
.result-card { display: flex; align-items: center; gap: 13px; padding: 15px; box-shadow: none; }
.result-icon { display: grid; place-items: center; flex: 0 0 38px; height: 38px; border-radius: 11px; color: var(--primary); background: var(--primary-soft); font-weight: 800; }
.result-card h3 { margin: 0 0 5px; color: var(--muted); font-size: .8rem; font-weight: 700; }
.result-card p { margin: 0; line-height: 1.55; font-weight: 700; }
.reason-card { align-items: flex-start; }

.legal-card { margin-top: 12px; padding: 15px; box-shadow: none; background: #fffaf0; border-color: #f0dfb3; }
.legal-card strong { color: #795910; font-size: .9rem; }
.legal-card p { margin: 6px 0 0; color: #6b6045; font-size: .8rem; line-height: 1.7; }

.community-section { padding: 32px 0 22px; text-align: center; }
.community-button { width: min(100%, 330px); padding: 10px 18px; color: #fff; background: var(--primary); text-align: center; font-size: .95rem; line-height: 1.45; white-space: normal; overflow-wrap: anywhere; }

footer { display: flex; flex-direction: column; gap: 5px; padding: 22px 12px calc(30px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); color: var(--muted); text-align: center; font-size: .8rem; line-height: 1.65; }
footer strong { color: var(--text); }
footer p { margin: 5px 0 0; }

.info-dialog { width: min(calc(100% - 28px), 460px); padding: 0; border: 0; border-radius: 18px; color: var(--text); direction: rtl; box-shadow: 0 24px 70px rgba(5, 31, 63, .28); }
.info-dialog::backdrop { background: rgba(8, 25, 46, .58); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; padding: 17px 18px; border-bottom: 1px solid var(--border); }
.dialog-header h2 { margin: 0; font-size: 1.1rem; }
.dialog-header button { width: 34px; height: 34px; border: 0; border-radius: 9px; color: var(--muted); background: var(--primary-soft); font-size: 1.5rem; cursor: pointer; }
.info-list { display: grid; gap: 0; margin: 0; padding: 8px 18px; }
.info-list div { display: flex; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid #edf2f7; }
.info-list dt { color: var(--muted); }
.info-list dd { margin: 0; color: var(--primary-dark); font-weight: 700; text-align: left; }
.dialog-notice { margin: 8px 18px 18px; padding: 13px; border-radius: 12px; background: #fffaf0; }
.dialog-notice strong { color: #795910; font-size: .85rem; }
.dialog-notice p { margin: 5px 0 0; color: #6b6045; font-size: .78rem; line-height: 1.65; }

[hidden] { display: none !important; }

@media (min-width: 620px) {
  .site-header { padding-top: 38px; }
  .time-fields, .result-grid { grid-template-columns: 1fr 1fr; }
  .reason-card { grid-column: 1 / -1; }
  .input-card { padding: 21px; }
}

@media (prefers-reduced-motion: no-preference) {
  .results:not([hidden]) { animation: reveal .25s ease-out; }
  @keyframes reveal { from { opacity: 0; transform: translateY(8px); } }
}
