:root {
  --bg: #f5f7fb;
  --bg-soft: #eef2f8;
  --ink: #1c2434;
  --ink-soft: #6b778c;
  --primary: #2f6fed;
  --primary-2: #4b86f7;
  --primary-soft: #e8f0fe;
  --accent: #ef8a2c;
  --accent-soft: #fff1e0;
  --ok: #1f9d63;
  --ok-soft: #e6f7ef;
  --danger: #e14b4b;
  --danger-soft: #fdebec;
  --call: #16a34a;
  --call-soft: #e8f8ee;
  --card: #ffffff;
  --line: #e6ebf3;
  --shadow: 0 10px 30px rgba(28, 36, 52, 0.06);
  --shadow-sm: 0 4px 14px rgba(28, 36, 52, 0.05);
  --radius: 20px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --nav-h: 70px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: 'ALKATIPTorTom', 'Segoe UI', Tahoma, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 100% -8%, rgba(47, 111, 237, 0.10), transparent 55%),
    radial-gradient(700px 360px at 0% 100%, rgba(239, 138, 44, 0.08), transparent 50%),
    linear-gradient(180deg, #f8fafc 0%, var(--bg) 40%, #f3f6fb 100%);
  direction: rtl;
}

body { overflow-x: hidden; }

button, input, textarea, select { font-family: inherit; }

#app {
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

a { color: inherit; text-decoration: none; }

/* ---------- Login (light) ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 22px calc(36px + var(--safe-b));
  gap: 28px;
}

.brand-block {
  text-align: center;
  animation: rise 0.55s ease both;
}

.brand-mark {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 24px;
  display: grid;
  place-items: center;
  font-size: 2rem;
  color: var(--primary);
  background: linear-gradient(145deg, #ffffff, var(--primary-soft));
  border: 1px solid #dfe8fb;
  box-shadow: var(--shadow);
}

.brand-name {
  font-size: 2.1rem;
  line-height: 1.3;
  margin: 0 0 8px;
  color: var(--ink);
}

.brand-sub {
  margin: 0 auto;
  color: var(--ink-soft);
  font-size: 1rem;
  max-width: 16em;
}

.login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 26px 22px 22px;
  box-shadow: var(--shadow);
  animation: rise 0.65s 0.08s ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 0.92rem;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 13px 14px;
  font-size: 1.05rem;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(47, 111, 237, 0.12);
}

.field textarea {
  min-height: 88px;
  resize: vertical;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 14px;
  padding: 13px 18px;
  font-size: 1.05rem;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s, background 0.2s, box-shadow 0.2s;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  box-shadow: 0 10px 22px rgba(47, 111, 237, 0.28);
}

.btn-soft {
  background: var(--primary-soft);
  color: var(--primary);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-accent {
  background: var(--accent-soft);
  color: #b86310;
}

.btn-sm {
  padding: 8px 12px;
  font-size: 0.9rem;
  border-radius: 12px;
  width: auto;
}

.search-btn {
  width: auto;
  padding: 0 16px;
  white-space: nowrap;
}

.btn-icon-danger {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

/* ---------- Shell ---------- */
.shell {
  min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 14px);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 14px 16px 12px;
  background: rgba(245, 247, 251, 0.88);
  backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid transparent;
}

.topbar h1 {
  margin: 0;
  font-size: 1.22rem;
  flex: 1;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--ink);
  font-size: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.icon-btn.accent {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.content { padding: 10px 16px 20px; }

.hero-stats {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
  animation: rise 0.5s ease both;
}

.stat-main {
  background: linear-gradient(145deg, #ffffff, #f3f7ff);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 20px 18px;
  position: relative;
  overflow: hidden;
  min-height: 132px;
  border: 1px solid #dde7fb;
  box-shadow: var(--shadow-sm);
}

.stat-main::after {
  content: "";
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(47, 111, 237, 0.08);
  left: -36px;
  bottom: -48px;
}

.stat-label {
  color: var(--ink-soft);
  font-size: 0.9rem;
  margin-bottom: 10px;
}

.stat-value {
  font-size: 1.7rem;
  line-height: 1.2;
  word-break: break-all;
  color: var(--primary);
}

.stat-foot {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.stat-side { display: grid; gap: 12px; }

.stat-mini {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--shadow-sm);
}

.stat-mini .n {
  font-size: 1.3rem;
  color: var(--ink);
  margin-top: 4px;
  font-weight: 600;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 2px 12px;
}

.section-head.compact { margin-top: 4px; }

.section-head h2 {
  margin: 0;
  font-size: 1.08rem;
}

.search-box {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.search-box input {
  flex: 1;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 1rem;
  outline: none;
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(47, 111, 237, 0.1);
}

.list { display: grid; gap: 10px; }

.customer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 10px;
  box-shadow: var(--shadow-sm);
  animation: rise 0.4s ease both;
}

.customer-main {
  display: flex;
  gap: 12px;
  align-items: center;
  flex: 1;
  min-width: 0;
  color: inherit;
}

.customer-main:active { opacity: 0.85; }

.avatar {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  object-fit: cover;
  background: linear-gradient(135deg, #e8f0fe, #d7e5ff);
  flex-shrink: 0;
  display: grid;
  place-items: center;
  color: var(--primary);
  font-size: 1.2rem;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ci-body { flex: 1; min-width: 0; }

.ci-name {
  font-size: 1.05rem;
  margin-bottom: 4px;
}

.ci-meta {
  color: var(--ink-soft);
  font-size: 0.86rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ci-debt {
  text-align: left;
  color: var(--accent);
  font-size: 0.95rem;
  white-space: nowrap;
  font-weight: 600;
}

.call-fab {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--call-soft);
  color: var(--call);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border: 1px solid #cdeed9;
  transition: transform 0.15s;
}

.call-fab:active { transform: scale(0.94); }

.call-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--call);
  color: #fff !important;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.92rem;
  box-shadow: 0 8px 18px rgba(22, 163, 74, 0.25);
}

.call-btn-sm {
  padding: 6px 12px;
  font-size: 0.85rem;
  box-shadow: none;
}

.phone-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 6px;
}

.phone-num {
  color: var(--ink);
  font-size: 1rem;
  direction: ltr;
  unicode-bidi: plaintext;
}

.addr-line { color: var(--ink-soft); }

.empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--ink-soft);
}

.empty .emoji {
  width: 72px;
  height: 72px;
  margin: 0 auto 12px;
  border-radius: 24px;
  background: var(--primary-soft);
  display: grid;
  place-items: center;
  font-size: 1.8rem;
  color: var(--primary);
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(480px, 100%);
  height: calc(var(--nav-h) + var(--safe-b));
  padding: 8px 18px var(--safe-b);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  z-index: 30;
  box-shadow: 0 -8px 24px rgba(28, 36, 52, 0.04);
}

.nav-item {
  border: none;
  background: transparent;
  color: var(--ink-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.8rem;
  cursor: pointer;
}

.nav-item.active { color: var(--primary); }

.nav-item .ni {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
}

.nav-item.active .ni {
  background: var(--primary-soft);
  border-radius: 10px;
}

/* ---------- Detail / Forms ---------- */
.profile-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px 16px;
  text-align: center;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  border: 1px solid var(--line);
  animation: rise 0.45s ease both;
}

.profile-avatar {
  width: 88px;
  height: 88px;
  border-radius: 28px;
  margin: 0 auto 12px;
  overflow: hidden;
  background: linear-gradient(135deg, #e8f0fe, #d7e5ff);
  display: grid;
  place-items: center;
  font-size: 1.8rem;
  color: var(--primary);
  box-shadow: 0 10px 24px rgba(47, 111, 237, 0.12);
  border: 3px solid #fff;
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-name {
  font-size: 1.35rem;
  margin: 0 0 10px;
}

.profile-meta {
  font-size: 0.92rem;
  line-height: 1.6;
}

.money-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-top: 16px;
}

.money-cell {
  background: var(--bg-soft);
  border-radius: 14px;
  padding: 10px 6px;
}

.money-cell .l {
  font-size: 0.76rem;
  color: var(--ink-soft);
}

.money-cell .v {
  margin-top: 4px;
  font-size: 0.95rem;
  color: var(--ink);
  word-break: break-all;
  font-weight: 600;
}

.money-cell.debt .v { color: var(--accent); }

.actions-row {
  display: flex;
  gap: 8px;
  margin: 14px 0;
  flex-wrap: wrap;
}

.credit-item {
  background: var(--card);
  border-radius: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  animation: rise 0.35s ease both;
}

.credit-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.credit-title { font-size: 1.05rem; }

.credit-sub {
  margin-top: 4px;
  font-size: 0.85rem;
  color: var(--ink-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.credit-date {
  color: var(--ink-soft);
  font-size: 0.85rem;
  white-space: nowrap;
}

.item-table {
  background: var(--bg-soft);
  border-radius: 14px;
  padding: 8px 10px;
  margin-bottom: 10px;
}

.item-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr auto;
  gap: 6px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px dashed #dde3ee;
  font-size: 0.9rem;
}

.item-row:last-child { border-bottom: none; }

.item-name { color: var(--ink); }

.item-meta {
  color: var(--ink-soft);
  font-size: 0.82rem;
  text-align: center;
}

.item-sum {
  color: var(--ink);
  font-weight: 600;
  white-space: nowrap;
}

.credit-amounts {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.92rem;
  color: var(--ink-soft);
}

.credit-amounts.order-total {
  padding: 4px 2px 0;
  color: var(--ink);
}

.credit-amounts.order-total strong {
  color: var(--accent);
  font-size: 1.05rem;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
}

.badge-warn {
  background: var(--accent-soft);
  color: #b86310;
}

.badge-ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.credit-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.note-line {
  margin: 8px 0 0 !important;
}

.form-page { padding-bottom: 24px; }

.customer-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.customer-chip .call-btn,
.customer-chip .call-btn-sm {
  margin-inline-start: auto;
}

.chip-label {
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.avatar-picker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 8px 0 18px;
}

.avatar-preview {
  width: 96px;
  height: 96px;
  border-radius: 28px;
  overflow: hidden;
  background: linear-gradient(135deg, #e8f0fe, #d7e5ff);
  display: grid;
  place-items: center;
  color: var(--primary);
  font-size: 2rem;
  border: 3px solid #fff;
  box-shadow: var(--shadow);
  cursor: pointer;
  position: relative;
}

.avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-preview input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.hint {
  color: var(--ink-soft);
  font-size: 0.85rem;
  margin-top: -6px;
  margin-bottom: 12px;
}

.product-list {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.product-row {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 12px 6px;
  box-shadow: var(--shadow-sm);
  animation: rise 0.25s ease both;
}

.product-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.product-index {
  font-size: 0.88rem;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 4px 10px;
  border-radius: 999px;
}

.total-preview {
  background: linear-gradient(135deg, #eef4ff, #fff6eb);
  border: 1px solid #e4ebf8;
  border-radius: 16px;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.total-preview strong {
  color: var(--accent);
  font-size: 1.3rem;
}

.total-label {
  font-size: 0.95rem;
  color: var(--ink);
}

.total-count {
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-top: 2px;
}

.sticky-total {
  position: sticky;
  bottom: calc(var(--nav-h) + var(--safe-b) + 8px);
  z-index: 5;
  box-shadow: var(--shadow);
}

.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  background: rgba(28, 36, 52, 0.92);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.95rem;
  max-width: 88%;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  animation: rise 0.25s ease;
}

.settings-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.settings-card .user-line {
  font-size: 1.2rem;
  margin-bottom: 6px;
}

.settings-card .tip {
  color: var(--ink-soft);
  margin-bottom: 20px;
}

.form-error {
  background: var(--danger-soft);
  color: var(--danger);
  padding: 10px 12px;
  border-radius: 12px;
  margin-bottom: 14px;
  font-size: 0.95rem;
}

.pay-inline {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 1;
}

.pay-inline input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #fff;
}

.toast-error { background: rgba(225, 75, 75, 0.95); }
.toast-ok { background: rgba(31, 157, 99, 0.95); }

.admin-list {
  display: grid;
  gap: 8px;
}

.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  background: var(--bg-soft);
  border-radius: 14px;
}

.admin-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  align-items: center;
}

.copy-bar {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 10px;
}

.copy-btn {
  width: auto;
}

.ledger {
  margin-top: 4px;
}

.seg-tabs {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: #e9eef6;
  border-radius: 16px;
  margin-bottom: 14px;
  box-shadow: inset 0 1px 2px rgba(28, 36, 52, 0.04);
}

.seg-tab {
  position: relative;
  z-index: 1;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  border-radius: 13px;
  padding: 11px 8px;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: color 0.2s;
}

.seg-tab.is-active {
  color: var(--ink);
  font-weight: 600;
}

.seg-count {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(47, 111, 237, 0.12);
  color: var(--primary);
  font-size: 0.75rem;
  display: inline-grid;
  place-items: center;
}

.seg-count.paid {
  background: rgba(31, 157, 99, 0.14);
  color: var(--ok);
}

.seg-glider {
  position: absolute;
  top: 4px;
  left: 0;
  height: calc(100% - 8px);
  width: calc(50% - 6px);
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 4px 12px rgba(28, 36, 52, 0.1);
  transition: transform 0.25s ease, width 0.25s ease;
  z-index: 0;
}

.tab-panel[hidden] {
  display: none;
}

.tab-panel.is-active {
  animation: rise 0.28s ease;
}

.pay-ledger {
  position: relative;
  display: grid;
  gap: 0;
  padding-right: 6px;
}

.pay-ledger::before {
  content: "";
  position: absolute;
  top: 12px;
  bottom: 12px;
  right: 20px;
  width: 2px;
  background: linear-gradient(#d8e4d8, #cfe8d8);
}

.pay-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px 14px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 10px;
  position: relative;
}

.pay-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(31, 157, 99, 0.16);
  flex-shrink: 0;
}

.pay-body {
  flex: 1;
  min-width: 0;
}

.pay-title {
  font-size: 1rem;
}

.pay-date {
  margin-top: 3px;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.pay-amount {
  color: var(--ok);
  font-weight: 600;
  white-space: nowrap;
  font-size: 1.02rem;
}

.paid-card {
  border-color: #d8e9de;
  background: linear-gradient(180deg, #ffffff 0%, #f7fcf8 100%);
}

.paid-money {
  margin-top: 10px;
}

.pay-subhead {
  margin: 12px 2px 8px;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

.pay-mini-list {
  background: var(--bg-soft);
  border-radius: 12px;
  padding: 6px 10px;
}

.pay-mini-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dashed #dde3ee;
  font-size: 0.9rem;
}

.pay-mini-row:last-child {
  border-bottom: none;
}

.empty.compact {
  padding: 28px 12px;
}

.admin-name {
  font-size: 1.02rem;
}

.admin-meta {
  margin-top: 2px;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(20, 28, 40, 0.42);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-mask.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: min(480px, 100%);
  background: #fff;
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -12px 40px rgba(28, 36, 52, 0.18);
  transform: translateY(24px);
  transition: transform 0.25s ease;
  padding-bottom: var(--safe-b);
}

.modal-mask.is-open .modal-card {
  transform: translateY(0);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 18px 18px 8px;
}

.modal-head h3 {
  margin: 0;
  font-size: 1.15rem;
}

.modal-close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 12px;
  background: var(--bg-soft);
  color: var(--ink-soft);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.modal-body {
  padding: 8px 18px 18px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

@media (min-width: 480px) {
  .modal-mask {
    align-items: center;
    padding: 20px;
  }
  .modal-card {
    border-radius: 22px;
    max-width: 400px;
  }
}

@media (max-width: 380px) {
  .row-3 { grid-template-columns: 1fr; }
  .item-row {
    grid-template-columns: 1fr auto;
  }
  .item-meta {
    grid-column: 1 / -1;
    text-align: right;
  }
}
