:root {
  --ink: #17130b;
  --muted: #6f685c;
  --line: #e8dfca;
  --surface: #ffffff;
  --canvas: #0a0907;
  --blue: #a66d00;
  --blue-soft: #fff6dc;
  --green: #16a56f;
  --gold: #d7a72c;
}

* { box-sizing: border-box; }
html { background: var(--canvas); }
body {
  margin: 0;
  background:
    radial-gradient(circle at 82% -8%, rgba(225,171,45,.24), transparent 30rem),
    radial-gradient(circle at 5% 28%, rgba(125,82,0,.17), transparent 28rem),
    linear-gradient(155deg, #050505 0%, #11100d 55%, #080706 100%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: Tahoma, Arial, sans-serif;
  font-size: 17px;
}
button, input, textarea { font: inherit; }
select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.app-shell { width: min(1500px, 100%); min-height: 100vh; margin: 0 auto; padding: 28px 34px 24px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.top-actions a { padding: 10px 13px; border: 1px solid rgba(224,178,61,.42); border-radius: 11px; color: #f0d37e; background: rgba(255,255,255,.06); font-size: 13px; font-weight: 800; text-decoration: none; }
.top-actions a.logout-link { color: #ffb6bf; border-color: rgba(255,139,153,.34); }
.brand { display: flex; align-items: center; gap: 16px; color: #fff; }
.brand-logo { width: 104px; height: 68px; object-fit: contain; object-position: center; }
.brand h1 { margin: 0; font-size: 27px; }
.brand p { margin: 5px 0 0; color: #d4b967; font-size: 16px; }
.date-pill { display: flex; align-items: center; gap: 11px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.78); box-shadow: 0 5px 18px rgba(20,33,61,.04); }
.date-pill div { display: flex; flex-direction: column; gap: 3px; }
.date-pill strong { font-size: 13px; }
.date-pill small { color: var(--muted); font-size: 11px; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgba(22,165,111,.12); }

.date-navigator { position: relative; display: flex; align-items: center; gap: 8px; padding: 7px; border: 1px solid rgba(224,178,61,.45); border-radius: 18px; background: rgba(255,255,255,.97); box-shadow: 0 9px 28px rgba(0,0,0,.22); }
.date-navigator > button { min-height: 48px; padding: 0 16px; border: 0; border-radius: 12px; color: #815300; background: var(--blue-soft); font-size: 15px; font-weight: 900; }
.date-navigator > button:disabled { opacity: .35; cursor: default; }
.date-picker { min-width: 270px; text-align: center; }
.date-display { width: 100%; min-height: 48px; padding: 0 14px; border: 0; color: var(--ink); background: transparent; font-size: 17px; font-weight: 900; }
.date-navigator .today-button { color: #191207; background: linear-gradient(135deg,#f1c657,#c68d13); }
.calendar-scrim { position: fixed; inset: 0; z-index: 30; width: 100%; height: 100%; border: 0; background: rgba(0,0,0,.3); cursor: default; }
.calendar-modal { position: fixed; inset: 0; z-index: 40; }
.calendar-modal .calendar-scrim { z-index: 40; }
.calendar-modal .persian-calendar { position: fixed; z-index: 41; top: 50%; left: 50%; transform: translate(-50%,-50%); }
.persian-calendar { position: absolute; z-index: 31; top: calc(100% + 10px); left: 50%; width: min(390px, calc(100vw - 28px)); padding: 18px; transform: translateX(-50%); border: 1px solid #d9bd72; border-radius: 22px; background: #fffdf8; box-shadow: 0 24px 70px rgba(0,0,0,.38); }
.calendar-head { display: grid; grid-template-columns: 1fr 1.2fr 1fr; align-items: center; gap: 8px; margin-bottom: 16px; }
.calendar-head strong { font-size: 18px; white-space: nowrap; }
.calendar-head button { min-height: 42px; padding: 5px 8px; border: 0; border-radius: 11px; color: #815300; background: #fff3cf; font-size: 14px; font-weight: 900; }
.calendar-jump { display: grid; grid-template-columns: 1fr 1.25fr auto; gap: 8px; margin-bottom: 13px; padding: 10px; border-radius: 14px; background: #f7f1e3; }
.calendar-jump label { display: flex; flex-direction: column; gap: 4px; text-align: right; }
.calendar-jump label span { color: #746b5c; font-size: 12px; font-weight: 800; }
.calendar-jump select { width: 100%; min-height: 42px; padding: 0 8px; border: 1px solid #dfcfaa; border-radius: 10px; color: #312b21; background: white; font: inherit; font-size: 15px; font-weight: 900; }
.calendar-jump > button { align-self: end; min-height: 42px; padding: 0 10px; border: 0; border-radius: 10px; color: white; background: #8f6208; font-size: 12px; font-weight: 900; white-space: nowrap; }
.calendar-weekdays, .calendar-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.calendar-weekdays { margin-bottom: 7px; color: #746b5c; font-size: 14px; font-weight: 900; }
.calendar-weekdays span { display: grid; place-items: center; min-height: 32px; }
.calendar-days button { aspect-ratio: 1; min-width: 0; border: 0; border-radius: 12px; color: #312b21; background: #f8f4e9; font-size: 17px; font-weight: 800; }
.calendar-days button.today { box-shadow: inset 0 0 0 2px #d1a333; }
.calendar-days button.selected { color: #171005; background: linear-gradient(135deg,#f3cb62,#c99016); box-shadow: 0 6px 15px rgba(173,117,0,.25); }

.summary-grid { display: grid; grid-template-columns: 1.55fr .8fr 1.1fr; gap: 14px; margin-bottom: 16px; }
.summary-grid.extended { grid-template-columns: 1fr 1fr 1.05fr; }
.summary { min-height: 112px; display: flex; flex-direction: column; justify-content: center; gap: 10px; padding: 20px 24px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); box-shadow: 0 10px 32px rgba(0,0,0,.18); }
.summary > span { color: var(--muted); font-size: 17px; font-weight: 800; }
.summary > strong { font-size: clamp(28px, 2.5vw, 38px); letter-spacing: -1px; }
.summary strong small { font-size: 15px; font-weight: 700; }
.summary.primary { color: white; background: linear-gradient(125deg, #155eef, #0c45b2); border-color: transparent; }
.summary.primary span { color: rgba(255,255,255,.75); }
.summary.dad { border-color: #ebcb75; background: linear-gradient(140deg,#fffaf0,#fff1c8); }
.summary.me { border-color: #bfe5d7; background: linear-gradient(140deg,#f8fffc,#eafaf4); }
.summary.dad strong { color: #8c5d00; }
.summary.me strong { color: #0d8a5e; }
.summary.compact { flex-direction: row; align-items: center; justify-content: space-around; gap: 22px; }
.summary.compact div { display: flex; flex-direction: column; gap: 8px; }
.summary.compact div + div { border-right: 1px solid var(--line); padding-right: 26px; }
.summary.compact span { color: var(--muted); font-size: 16px; font-weight: 800; }
.summary.compact b { font-size: 23px; }

.weekly-report { margin-bottom: 16px; overflow: hidden; border: 1px solid rgba(215,167,44,.6); border-radius: 22px; background: rgba(27,23,15,.94); box-shadow: 0 12px 30px rgba(0,0,0,.22); }
.weekly-report-bar { min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px 20px; color: white; }
.weekly-report-bar > div { display: flex; flex-direction: column; gap: 5px; }
.weekly-report-bar strong { font-size: 20px; }
.weekly-report-bar button,.week-navigation button { min-height: 46px; padding: 0 16px; border: 1px solid #d4a438; border-radius: 12px; color: #21180a; background: linear-gradient(135deg,#f2cc68,#c58a12); font-size: 14px; font-weight: 900; }
.weekly-report-body { padding: 0 16px 16px; }
.week-navigation { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 12px; border-radius: 15px; color: white; background: #0e0c09; }
.week-navigation strong { text-align: center; font-size: 16px; }
.week-navigation button:disabled { opacity: .35; cursor: default; }
.weekly-loading { min-height: 180px; display: grid; place-items: center; color: #ead491; }
.weekly-cards { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px; margin-top: 12px; }
.weekly-cards article { min-width: 0; display: flex; flex-direction: column; gap: 8px; padding: 16px; border-radius: 15px; background: #fffdf8; }
.weekly-cards span { color: var(--muted); font-size: 13px; font-weight: 900; }
.weekly-cards strong { overflow-wrap: anywhere; color: #815300; font-size: 21px; }
.weekly-cards strong.negative { color: #c23b52; }
.weekly-cards small { font-size: 12px; }
.weekly-details { display: grid; grid-template-columns: minmax(300px,.72fr) minmax(0,1.28fr); gap: 12px; margin-top: 12px; }
.weekly-kind-list,.weekly-table-wrap { min-width: 0; padding: 17px; border-radius: 16px; background: #fffdf8; }
.weekly-details h3 { margin: 0 0 13px; font-size: 17px; }
.weekly-kind-list > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid #ece3d1; }
.weekly-kind-list > div > span { display: flex; flex-direction: column; gap: 4px; font-weight: 900; }
.weekly-kind-list small { color: var(--muted); font-size: 12px; }
.weekly-kind-list strong { color: #815300; font-size: 15px; white-space: nowrap; }
.weekly-table-wrap { overflow-x: auto; }
.weekly-table-wrap table { width: 100%; border-collapse: collapse; white-space: nowrap; }
.weekly-table-wrap th,.weekly-table-wrap td { padding: 10px 8px; border-bottom: 1px solid #ece3d1; text-align: right; font-size: 13px; }
.weekly-table-wrap th { color: var(--muted); }
.weekly-table-wrap td:last-child { color: #815300; }
.weekly-insight { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 12px; padding: 13px 16px; border-radius: 14px; color: #f5e4ac; background: #0e0c09; font-size: 14px; }
.weekly-insight b { color: white; }

.workspace { display: grid; grid-template-columns: minmax(430px,.9fr) minmax(500px,1.15fr); gap: 16px; }
.entry-panel, .ledger-panel { border: 1px solid var(--line); border-radius: 26px; background: var(--surface); box-shadow: 0 10px 35px rgba(20,33,61,.045); }
.entry-panel { padding: 25px; }
.ledger-panel { overflow: hidden; display: flex; flex-direction: column; min-height: 575px; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; }
.section-head h2 { margin: 5px 0 0; font-size: 27px; }
.eyebrow { color: var(--blue); font-size: 15px; font-weight: 900; letter-spacing: .02em; }
.step { display: grid; place-items: center; width: 31px; height: 31px; color: white; background: var(--blue); border-radius: 10px; font-weight: 800; }
.cancel-edit { padding: 8px 12px; border: 0; border-radius: 10px; color: #bf3148; background: #fff0f2; font-size: 11px; font-weight: 800; }
.kind-tabs { display: grid; grid-template-columns: repeat(4,1fr); gap: 7px; padding: 5px; margin-bottom: 14px; border-radius: 15px; background: #f1f3f7; }
.kind-tabs button { min-height: 54px; border: 0; border-radius: 11px; color: #5f5a51; background: transparent; font-size: 17px; font-weight: 900; }
.kind-tabs button.active { color: var(--blue); background: white; box-shadow: 0 3px 12px rgba(20,33,61,.08); }
.kind-tabs button.active.refund { color: #c8384f; }

.search-box { display: flex; align-items: center; gap: 10px; padding: 0 17px; height: 66px; border: 2px solid #ded4bd; border-radius: 16px; background: #fffdfa; transition: .2s ease; }
.search-box:focus-within { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(21,94,239,.08); }
.search-box span { font-size: 25px; color: var(--muted); transform: rotate(-20deg); }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 21px; font-weight: 700; }
.search-box input::placeholder { color: #a2aabd; }
.product-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 9px; margin-top: 14px; }
.product { min-height: 60px; padding: 10px 8px; border: 1px solid var(--line); border-radius: 14px; color: #403a30; background: #fff; font-size: 16px; font-weight: 800; }
.product:hover, .product.active { border-color: var(--blue); color: var(--blue); background: var(--blue-soft); }

.form-row { display: grid; grid-template-columns: 1.65fr .75fr; gap: 14px; margin-top: 23px; }
.field > span, .payment-row > span { display: block; margin-bottom: 9px; color: #514b41; font-size: 16px; font-weight: 800; }
.money-input { height: 66px; display: flex; align-items: center; border: 1px solid var(--line); border-radius: 15px; overflow: hidden; }
.money-input input { min-width: 0; flex: 1; height: 100%; padding: 0 16px; border: 0; outline: 0; direction: ltr; text-align: right; font-size: 27px; font-weight: 900; color: var(--ink); }
.money-input b { align-self: stretch; display: grid; place-items: center; padding: 0 14px; background: #faf6ed; border-right: 1px solid var(--line); color: var(--muted); font-size: 15px; }
.price-field small { display: block; margin-top: 8px; color: var(--blue); font-size: 15px; }
.price-field .price-words { min-height: 31px; line-height: 1.7; font-weight: 700; }
.stepper { display: grid; grid-template-columns: 1fr 1fr 1fr; height: 66px; border: 1px solid var(--line); border-radius: 15px; overflow: hidden; }
.stepper button { border: 0; background: #f5f7fb; color: var(--blue); font-size: 21px; }
.stepper strong { display: grid; place-items: center; font-size: 23px; }
.payment-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 18px; }
.payment-row > span { margin: 0; }
.selectors-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 18px; }
.selectors-row > div > span { display: block; margin-bottom: 9px; color: #514b41; font-size: 16px; font-weight: 800; }
.selectors-row .segmented { display: grid; grid-template-columns: 1fr 1fr; }
.selectors-row .segmented button { min-width: 0; }
.segmented { display: flex; padding: 4px; border-radius: 13px; background: #f1f3f7; }
.segmented button { min-width: 88px; min-height: 49px; padding: 10px 14px; border: 0; border-radius: 10px; color: var(--muted); background: transparent; font-size: 17px; font-weight: 900; }
.segmented button.active { color: var(--blue); background: white; box-shadow: 0 2px 8px rgba(20,33,61,.08); }
.repair-locked { border: 1px solid #e0c477; background: #fff5d9; }
.repair-locked button:first-child { color: #795000; background: transparent; box-shadow: none; }
.repair-locked button:last-child { display: none; }
.submit-sale { width: 100%; min-height: 68px; display: flex; align-items: center; justify-content: space-between; margin-top: 20px; padding: 0 20px; border: 0; border-radius: 17px; color: white; background: linear-gradient(135deg,#18a874,#0d865b); box-shadow: 0 10px 23px rgba(22,165,111,.21); }
.submit-sale span { font-size: 20px; font-weight: 900; }
.submit-sale b { font-size: 19px; }
.submit-sale:active { transform: translateY(1px); }
.submit-sale:disabled { opacity: .6; cursor: wait; }
.refund-mode { border-color: #f0cbd1; }
.refund-submit { background: linear-gradient(135deg,#e15568,#b92942); box-shadow: 0 10px 23px rgba(190,45,67,.18); }
.form-message { margin: 13px 2px -6px; color: var(--blue); font-size: 15px; font-weight: 800; }
.form-message:empty { display: none; }
.error-text { color: #bd263e !important; }

.ledger-head { padding: 25px 25px 0; }
.more { border: 0; background: transparent; color: var(--muted); font-weight: 900; letter-spacing: 3px; }
.count-badge { padding: 8px 12px; border-radius: 10px; color: var(--blue); background: var(--blue-soft); font-size: 14px; font-weight: 900; }
.sales-list { flex: 1; padding: 0 14px 12px; }
.sale-row { display: grid; grid-template-columns: 36px 1fr auto auto; align-items: center; gap: 11px; padding: 14px 10px; border-bottom: 1px solid #edf0f5; }
.sale-row.is-refund { background: #fffafb; }
.sale-row.is-refund .sale-price strong { color: #c8384f; }
.sale-index { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 11px; background: #f1f5ff; color: var(--blue); font-size: 12px; font-weight: 800; }
.sale-main { display: flex; flex-direction: column; gap: 6px; }
.sale-main strong { font-size: 18px; }
.sale-main span { color: var(--muted); font-size: 14px; }
.sale-price { display: flex; align-items: baseline; gap: 5px; white-space: nowrap; }
.sale-price strong { font-size: 19px; }
.sale-price span { color: var(--muted); font-size: 13px; }
.remove { width: 29px; height: 29px; border: 0; border-radius: 9px; background: transparent; color: #acb3c1; font-size: 20px; }
.remove:hover { color: #d74055; background: #fff0f2; }
.row-actions { display: flex; gap: 5px; }
.row-actions button { min-height: 40px; padding: 8px 11px; border: 0; border-radius: 9px; color: var(--blue); background: var(--blue-soft); font-size: 14px; font-weight: 900; }
.row-actions button.danger { color: #c8384f; background: #fff0f2; }
.empty-state { display: flex; min-height: 280px; align-items: center; justify-content: center; flex-direction: column; gap: 8px; color: var(--muted); }
.empty-state strong { color: var(--ink); }
.ledger-total { display: flex; align-items: center; justify-content: space-between; padding: 18px 25px; border-top: 1px solid var(--line); background: #f8faff; }
.ledger-total > div { display: flex; flex-direction: column; gap: 5px; }
.ledger-total > div:last-child { align-items: flex-end; }
.ledger-total span { color: var(--muted); font-size: 14px; font-weight: 700; }
.ledger-total b { color: #c8384f; font-size: 18px; }
.ledger-total strong { color: var(--blue); font-size: 28px; }
.ledger-total small { font-size: 14px; }
.daily-note-panel { margin-top: 16px; padding: 22px 24px; border: 1px solid #d9bd72; border-radius: 23px; background: linear-gradient(135deg,#fffdf8,#fff7df); box-shadow: 0 12px 30px rgba(0,0,0,.16); }
.daily-note-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.daily-note-head h2 { margin: 5px 0 0; font-size: 23px; line-height: 1.4; }
.note-count { flex: 0 0 auto; padding: 8px 11px; border-radius: 10px; color: #815300; background: #fff1c7; font-size: 13px; font-weight: 900; }
.daily-note-panel textarea { width: 100%; min-height: 135px; resize: vertical; padding: 16px 18px; border: 2px solid #ded4bd; border-radius: 16px; outline: 0; color: var(--ink); background: white; font-size: 17px; font-weight: 700; line-height: 1.9; }
.daily-note-panel textarea:focus { border-color: #c58a12; box-shadow: 0 0 0 4px rgba(197,138,18,.11); }
.daily-note-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 12px; }
.daily-note-actions p { margin: 0; color: var(--muted); font-size: 14px; font-weight: 800; }
.daily-note-actions button { flex: 0 0 auto; min-height: 50px; padding: 0 20px; border: 0; border-radius: 13px; color: white; background: linear-gradient(135deg,#c99220,#8a5a00); font-size: 15px; font-weight: 900; }
.daily-note-actions button:disabled { opacity: .48; cursor: default; }
.prototype-note { margin: 16px 4px 0; color: #c9b777; font-size: 13px; text-align: center; }
.day-change-toast { position: fixed; z-index: 50; right: 22px; bottom: 22px; display: grid; gap: 6px; width: min(390px,calc(100vw - 30px)); padding: 17px; border: 1px solid #dfb947; border-radius: 18px; color: #2e281e; background: #fff9e9; box-shadow: 0 20px 55px rgba(0,0,0,.32); }
.day-change-toast strong { font-size: 18px; }
.day-change-toast span { color: #6d6455; font-size: 14px; line-height: 1.7; }
.day-change-toast button { min-height: 44px; border: 0; border-radius: 11px; color: #171005; background: linear-gradient(135deg,#f3cb62,#c99016); font-weight: 900; }

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 22px; }
.auth-card { width: min(480px,100%); padding: 28px; border: 1px solid #d9bd72; border-radius: 24px; background: #fff; box-shadow: 0 25px 70px rgba(0,0,0,.4); }
.auth-card > img { display: block; width: 155px; height: 90px; margin: 0 auto 12px; object-fit: contain; }
.auth-card h1 { margin: 0 0 22px; text-align: center; font-size: 26px; }
.auth-card form { display: grid; gap: 14px; }
.auth-card label { display: grid; gap: 7px; color: #4f493e; font-size: 15px; font-weight: 800; }
.auth-card input { width: 100%; min-height: 52px; padding: 0 13px; border: 1px solid #d9d0bd; border-radius: 12px; background: #fffdf9; direction: ltr; }
.auth-card button, .main-link { min-height: 54px; display: grid; place-items: center; border: 0; border-radius: 13px; color: #171005; background: linear-gradient(135deg,#f3cb62,#c99016); font-size: 17px; font-weight: 900; text-decoration: none; }
.secondary-link { color: #5d5140; background: #f3eee3; }
.check-label { display: flex !important; grid-template-columns: auto 1fr; align-items: center; }
.check-label input { width: 22px; min-height: 22px; }
.auth-card hr { width: 100%; border: 0; border-top: 1px solid #e6dfd0; }
.notice, .error { padding: 12px; border-radius: 11px; font-weight: 700; }
.notice { color: #096d4b; background: #e8faf3; }
.error { color: #a91f36; background: #fff0f2; }
.wide-card { width: min(760px,100%); }
.trash-list { display: grid; gap: 10px; margin: 18px 0; }
.trash-list article { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px; border: 1px solid #e4dbc8; border-radius: 13px; }
.trash-list article > div { display: grid; gap: 5px; }
.trash-list article span { color: #6d6455; font-size: 13px; }
.trash-list form { display: block; }
.trash-list button { min-height: 40px; padding: 0 12px; }

@media (max-width: 920px) {
  .app-shell { padding: 18px; }
  .workspace { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: 1.3fr .8fr; }
  .summary-grid.extended { grid-template-columns: 1fr 1fr; }
  .summary.compact { grid-column: 1 / -1; min-height: 78px; }
  .date-navigator label { min-width: 190px; }
  .topbar { flex-wrap: wrap; gap: 14px; }
  .date-navigator { order: 3; width: 100%; }
}
@media (max-width: 560px) {
  .app-shell { padding: 14px; }
  .topbar { align-items: flex-start; }
  .topbar { gap: 14px; flex-direction: column; }
  .top-actions { width: 100%; }
  .top-actions a { flex: 1; text-align: center; }
  .date-navigator { width: 100%; flex-wrap: wrap; }
  .date-picker { flex: 1; min-width: 180px; }
  .date-navigator > button { flex: 1; }
  .persian-calendar { position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); }
  .calendar-jump { grid-template-columns: 1fr 1fr; }
  .calendar-jump > button { grid-column: 1 / -1; }
  .brand-logo { width: 88px; height: 58px; }
  .brand h1 { font-size: 23px; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .summary { min-height: 85px; padding: 14px; }
  .summary.compact { grid-column: 1 / -1; }
  .entry-panel { padding: 18px; }
  .product-grid { grid-template-columns: repeat(2,1fr); }
  .kind-tabs { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .payment-row { align-items: flex-start; flex-direction: column; }
  .selectors-row { grid-template-columns: 1fr; }
  .segmented { width: 100%; }
  .segmented button { flex: 1; }
  .sale-row { grid-template-columns: 32px 1fr auto; }
  .row-actions { grid-column: 2 / -1; }
  .ledger-total strong { font-size: 20px; }
}

/* چیدمان واکنش‌گرای نهایی برای ویندوز، تبلت و موبایل */
html { min-width: 320px; }
body { min-width: 320px; overflow-x: hidden; }
.app-shell { width: min(1680px,100%); padding: 24px clamp(22px,3vw,52px) 30px; }
.topbar { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "brand actions" "date date"; align-items: center; gap: 14px 24px; }
.brand { grid-area: brand; }
.top-actions { grid-area: actions; justify-content: flex-end; }
.date-navigator { grid-area: date; display: grid; grid-template-columns: auto minmax(270px,1fr) auto auto; min-width: 0; }
.date-picker { min-width: 0; }
.summary-grid.extended { grid-template-columns: repeat(3,minmax(0,1fr)); }
.summary { min-width: 0; min-height: 104px; }
.summary > strong,.summary.compact b { overflow-wrap: anywhere; }
.summary.compact { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.summary.compact div { min-width: 0; padding: 0 20px; }
.workspace { grid-template-columns: minmax(0,1.34fr) minmax(360px,.76fr); align-items: start; }
.entry-panel,.ledger-panel,.search-box input,.sales-list,.sale-main { min-width: 0; }
.kind-tabs,.product-grid { grid-template-columns: repeat(4,minmax(0,1fr)); }
.kind-tabs button,.product { min-width: 0; }
.form-row { grid-template-columns: minmax(0,1.7fr) minmax(190px,.65fr); }
.sale-row { grid-template-columns: 34px minmax(0,1fr); align-items: start; }
.sale-price,.row-actions { grid-column: 2; }
.sale-main strong { overflow-wrap: anywhere; }
.ledger-total { display: grid; grid-template-columns: 1fr 1.15fr; gap: 16px; }
.ledger-total > div { min-width: 0; }

@media (max-width: 1100px) {
  .app-shell { padding: 20px; }
  .workspace { grid-template-columns: 1fr; }
  .summary-grid.extended { grid-template-columns: 1fr 1fr; }
  .summary.compact { grid-column: 1 / -1; }
  .sale-row { grid-template-columns: 36px minmax(0,1fr) auto; align-items: center; }
  .sale-price { grid-column: 3; grid-row: 1; }
  .row-actions { grid-column: 2 / -1; }
  .weekly-cards { grid-template-columns: 1fr 1fr; }
  .weekly-details { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .app-shell { padding: 14px; }
  .topbar { grid-template-columns: 1fr; grid-template-areas: "brand" "actions" "date"; }
  .brand { justify-content: flex-start; }
  .top-actions { width: 100%; justify-content: stretch; }
  .top-actions a { flex: 1 1 calc(33% - 8px); text-align: center; }
  .date-navigator { grid-template-columns: 1fr 1fr; }
  .date-picker { grid-column: 1 / -1; grid-row: 1; border-bottom: 1px solid var(--line); }
  .date-navigator > button { min-width: 0; padding: 0 8px; }
  .summary-grid.extended { grid-template-columns: 1fr 1fr; }
  .kind-tabs,.product-grid { grid-template-columns: 1fr 1fr; }
  .form-row,.selectors-row { grid-template-columns: 1fr; }
  .submit-sale { align-items: flex-start; flex-direction: column; justify-content: center; gap: 5px; }
  .sale-row { grid-template-columns: 32px minmax(0,1fr); align-items: start; }
  .sale-price,.row-actions { grid-column: 2; grid-row: auto; }
  .weekly-report-bar { align-items: stretch; flex-direction: column; }
  .weekly-report-bar button { width: 100%; }
  .week-navigation { grid-template-columns: 1fr 1fr; }
  .week-navigation strong { grid-column: 1 / -1; grid-row: 1; }
  .weekly-cards { grid-template-columns: 1fr 1fr; }
  .weekly-cards article { padding: 13px; }
  .weekly-cards strong { font-size: 18px; }
  .weekly-kind-list,.weekly-table-wrap { padding: 14px; }
  .weekly-insight { align-items: flex-start; flex-direction: column; }
  .daily-note-panel { padding: 18px; border-radius: 20px; }
  .daily-note-head { flex-direction: column; gap: 9px; }
  .daily-note-panel textarea { min-height: 155px; }
  .daily-note-actions { align-items: stretch; flex-direction: column; }
  .daily-note-actions button { width: 100%; }
}

@media (max-width: 430px) {
  .app-shell { padding: 10px; }
  .summary-grid.extended { grid-template-columns: 1fr; }
  .summary.compact { grid-column: auto; }
  .weekly-cards { grid-template-columns: 1fr; }
  .ledger-total { grid-template-columns: 1fr; }
  .ledger-total > div:last-child { align-items: flex-start; text-align: right; }
}
