:root {
  --ink: #162a27;
  --muted: #6e7d7a;
  --line: #e4ebe8;
  --canvas: #f5f7f6;
  --surface: #ffffff;
  --brand: #174e45;
  --brand-dark: #103c35;
  --brand-soft: #e8f2ef;
  --accent: #e0a34a;
  --accent-soft: #fbf0dd;
  --danger: #b64d4d;
  --danger-soft: #f9eaea;
  --info: #4676a7;
  --info-soft: #eaf1f8;
  --success: #2f8064;
  --shadow: 0 7px 28px rgba(24, 51, 45, .07);
  --sidebar-width: 250px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: "Tajawal", Arial, sans-serif; color: var(--ink); background: var(--canvas); font-size: 15px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: var(--sidebar-width); padding: 26px 18px 18px; display: flex; flex-direction: column; background: linear-gradient(160deg, #123f38 0%, #174d44 55%, #133a35 100%); color: white; z-index: 40; box-shadow: -8px 0 30px rgba(12, 42, 36, .08); }
.brand { display: flex; gap: 12px; align-items: center; padding: 0 10px 24px; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand-mark { width: 43px; height: 43px; display: grid; place-items: center; border-radius: 13px; background: rgba(255,255,255,.11); color: #f4c574; }
.brand-mark svg { width: 29px; fill: none; stroke: currentColor; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }
.brand h1 { font-size: 24px; line-height: 1; margin: 0 0 5px; letter-spacing: .2px; }
.brand p { margin: 0; font-size: 12px; color: rgba(255,255,255,.62); }
.main-nav { display: grid; gap: 7px; padding-top: 25px; }
/* Short screens: the sidebar scrolls so the backup/restore/password tools at the bottom stay reachable. */
.sidebar { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.25) transparent; }
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.25); border-radius: 3px; }
.sidebar-footer { padding-top: 16px; }
@media (max-height: 760px) { .nav-item { padding-block: 8px; } .main-nav { gap: 4px; padding-top: 16px; } .brand { padding-bottom: 16px; } }
.nav-item { width: 100%; border: 0; border-radius: 11px; padding: 12px 13px; display: flex; align-items: center; gap: 12px; color: rgba(255,255,255,.72); background: transparent; text-align: right; transition: .18s ease; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.07); transform: translateX(-2px); }
.nav-item.active { background: rgba(255,255,255,.13); color: #fff; font-weight: 700; box-shadow: inset -3px 0 #f1bd65; }
.nav-icon { width: 22px; height: 22px; display: grid; place-items: center; font-size: 19px; color: #f1c370; }
.sidebar-footer { margin-top: auto; display: grid; gap: 8px; }
.sidebar-tool { border: 0; color: rgba(255,255,255,.7); background: transparent; text-align: right; padding: 8px 11px; display: flex; align-items: center; gap: 9px; border-radius: 8px; }
.sidebar-tool:hover { background: rgba(255,255,255,.07); color: #fff; }
.file-label { cursor: pointer; }
.file-label input { display: none; }
.profile-card { display: flex; align-items: center; gap: 10px; margin-top: 10px; border-radius: 12px; background: rgba(0,0,0,.12); padding: 11px; }
.profile-avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: #e8b761; color: #143e37; font-weight: 800; }
.profile-card strong, .profile-card small { display: block; }
.profile-card strong { font-size: 13px; }
.profile-card small { font-size: 10px; color: rgba(255,255,255,.55); margin-top: 2px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #62d29e; margin-right: auto; box-shadow: 0 0 0 3px rgba(98,210,158,.12); }
.status-dot.syncing { background: #e0a34a; box-shadow: 0 0 0 3px rgba(224,163,74,.15); animation: pulse 1s infinite; }
.status-dot.error { background: #e16b6b; box-shadow: 0 0 0 3px rgba(225,107,107,.15); }
@keyframes pulse { 50% { opacity: .45; } }

.main-area { margin-inline-start: var(--sidebar-width); min-height: 100vh; }
.topbar { height: 88px; padding: 0 34px; display: flex; align-items: center; justify-content: space-between; background: rgba(255,255,255,.92); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 25; backdrop-filter: blur(12px); }
.topbar-title { display: flex; align-items: center; gap: 13px; }
.topbar-title h2 { margin: 0; font-size: 21px; }
.topbar-title p { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.date-chip { border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; display: flex; align-items: center; gap: 8px; line-height: 1; color: var(--muted); font-size: 13px; background: var(--surface); }
.icon-button { width: 39px; height: 39px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--brand); font-size: 21px; }
.icon-button:hover { border-color: #c4d3ce; background: var(--brand-soft); }
.menu-toggle { display: none; }

main { padding: 28px 34px 48px; max-width: 1560px; margin: 0 auto; }
.view { display: none; animation: rise .24s ease; }
.view.active { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.welcome-card { min-height: 148px; padding: 27px 30px; border-radius: 18px; display: flex; justify-content: space-between; align-items: center; gap: 24px; color: white; overflow: hidden; position: relative; background: linear-gradient(120deg, #164b43, #246559); box-shadow: var(--shadow); }
.welcome-card::before, .welcome-card::after { content: ""; position: absolute; border: 1px solid rgba(255,255,255,.1); border-radius: 50%; }
.welcome-card::before { width: 210px; height: 210px; left: -35px; top: -115px; }
.welcome-card::after { width: 140px; height: 140px; left: 65px; bottom: -115px; }
.welcome-card > * { position: relative; z-index: 1; }
.eyebrow { color: #f4c975; font-size: 12px; font-weight: 700; }
.welcome-card h3 { font-size: 23px; margin: 8px 0 6px; }
.welcome-card p { margin: 0; color: rgba(255,255,255,.7); }

.primary-btn, .secondary-btn, .ghost-btn { border-radius: 10px; padding: 10px 15px; border: 1px solid transparent; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 7px; transition: .16s ease; }
.primary-btn { background: var(--brand); color: white; box-shadow: 0 4px 14px rgba(23,78,69,.16); }
.primary-btn:hover { background: var(--brand-dark); transform: translateY(-1px); }
.welcome-card .primary-btn { color: #173e37; background: #f3c66f; box-shadow: none; }
.welcome-card .primary-btn:hover { background: #ffda8d; }
.secondary-btn { background: var(--brand-soft); border-color: #cfe1dc; color: var(--brand); }
.secondary-btn:hover { background: #dcebe7; }
.ghost-btn { background: white; border-color: var(--line); color: var(--muted); }
.ghost-btn:hover { color: var(--brand); border-color: #bcd1cb; }
.text-btn { border: 0; background: none; color: var(--brand); font-weight: 700; font-size: 13px; }
.text-btn:hover { text-decoration: underline; }

.metrics-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 18px 0; }
.metrics-grid.compact { margin-top: 0; }
.metric-card { background: var(--surface); border: 1px solid var(--line); border-radius: 15px; padding: 18px; display: flex; align-items: center; gap: 14px; box-shadow: 0 3px 16px rgba(22,42,39,.035); min-height: 104px; }
.metric-icon { width: 45px; height: 45px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; flex: 0 0 auto; }
.metric-icon.green { background: var(--brand-soft); color: var(--brand); }
.metric-icon.gold { background: var(--accent-soft); color: #a56c1c; }
.metric-icon.blue { background: var(--info-soft); color: var(--info); }
.metric-icon.red { background: var(--danger-soft); color: var(--danger); }
.metric-card small { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.metric-card strong { display: block; font-size: 21px; line-height: 1.2; }
.metric-card em { display: block; margin-top: 5px; color: #8a9895; font-size: 10px; font-style: normal; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 3px 20px rgba(22,42,39,.035); }
.panel-header { min-height: 70px; padding: 17px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.panel-header h3 { margin: 0; font-size: 16px; }
.panel-header p { margin: 4px 0 0; font-size: 11px; color: var(--muted); }
.soft-badge { background: var(--brand-soft); color: var(--brand); border-radius: 20px; padding: 6px 10px; font-size: 10px; }
.dashboard-grid { display: grid; grid-template-columns: 1.45fr 1fr; gap: 18px; margin: 18px 0; }
.chart-panel, .balances-panel { min-height: 326px; }
.bar-chart { height: 230px; padding: 28px 24px 20px; display: flex; align-items: end; gap: 18px; border-radius: 0 0 16px 16px; background: repeating-linear-gradient(to top, transparent 0, transparent 49px, #edf1ef 50px); }
.bar-group { flex: 1; height: 100%; display: flex; align-items: end; justify-content: center; position: relative; }
.bar { width: min(34px, 66%); min-height: 5px; background: linear-gradient(to top, #174e45, #4e8c80); border-radius: 6px 6px 2px 2px; position: relative; transition: height .5s ease; }
.bar:hover { background: linear-gradient(to top, #bf7b21, #efbd67); }
.bar:hover::before { content: attr(data-value); position: absolute; bottom: calc(100% + 7px); left: 50%; transform: translateX(-50%); background: #1b312d; color: white; border-radius: 6px; padding: 4px 6px; font-size: 9px; white-space: nowrap; }
.bar-label { position: absolute; bottom: -19px; color: var(--muted); font-size: 10px; }
.balance-list { padding: 10px 20px; }
.balance-row { display: grid; grid-template-columns: 38px 1fr auto; gap: 11px; align-items: center; padding: 12px 0; border-bottom: 1px solid #edf1ef; }
.balance-row:last-child { border-bottom: 0; }
.supplier-avatar { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; background: var(--brand-soft); color: var(--brand); font-weight: 800; }
.balance-row strong { font-size: 13px; display: block; }
.balance-row small { color: var(--muted); font-size: 10px; }
.balance-value { color: var(--danger); font-weight: 700; font-size: 13px; }
.recent-panel { margin-top: 18px; }

.section-toolbar { margin-bottom: 20px; display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.section-toolbar h3 { margin: 0; font-size: 21px; }
.section-toolbar p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.toolbar-actions { display: flex; gap: 8px; }
.data-panel { overflow: hidden; }
.filter-row { padding: 15px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.search-box { flex: 1; max-width: 390px; min-width: 200px; height: 42px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: #fbfcfb; }
.search-box:focus-within { border-color: #9bbab2; box-shadow: 0 0 0 3px rgba(23,78,69,.06); }
.search-box span { color: #899793; font-size: 20px; }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); }
.filter-row select, .filter-row input[type="month"] { height: 42px; min-width: 155px; border: 1px solid var(--line); border-radius: 10px; padding: 0 11px; background-color: white; color: var(--ink); outline: 0; }
.table-wrap { width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th { text-align: right; padding: 13px 17px; background: #fafcfb; color: #7a8885; font-size: 11px; font-weight: 700; border-bottom: 1px solid var(--line); }
td { padding: 15px 17px; border-bottom: 1px solid #edf1ef; font-size: 13px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfdfc; }
.code-cell { color: var(--brand); font-weight: 800; direction: ltr; text-align: right; }
.money { font-weight: 700; direction: ltr; display: inline-block; }
.negative { color: var(--danger); }
.positive { color: var(--success); }
.muted { color: var(--muted); }
.table-title { display: flex; align-items: center; gap: 9px; }
.table-title .supplier-avatar { width: 31px; height: 31px; border-radius: 8px; font-size: 12px; }
.status-badge { display: inline-block; border-radius: 20px; padding: 5px 9px; font-size: 10px; font-weight: 700; }
.status-badge.due { background: var(--accent-soft); color: #94611a; }
.status-badge.paid { background: var(--brand-soft); color: var(--brand); }
.status-badge.overdue { background: var(--danger-soft); color: var(--danger); }
.row-actions { display: flex; justify-content: end; gap: 4px; }
.row-btn { width: 29px; height: 29px; border: 0; border-radius: 7px; background: transparent; color: #758480; }
.row-btn:hover { background: var(--brand-soft); color: var(--brand); }
.row-btn.delete:hover { background: var(--danger-soft); color: var(--danger); }
.empty-state { padding: 50px 20px; text-align: center; color: var(--muted); }
.empty-state > span { width: 54px; height: 54px; margin: auto; display: grid; place-items: center; border-radius: 16px; background: var(--brand-soft); color: var(--brand); font-size: 26px; }
.empty-state h4 { color: var(--ink); margin: 12px 0 5px; }
.empty-state p { margin: 0; font-size: 12px; }

.account-hero { margin-bottom: 18px; padding: 18px 20px; display: flex; align-items: end; gap: 24px; }
.account-summary { flex: 2; display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.summary-cell { border-right: 1px solid var(--line); padding: 3px 18px 3px 6px; }
.summary-cell small { color: var(--muted); display: block; font-size: 11px; margin-bottom: 4px; }
.summary-cell strong { font-size: 19px; }
.statement-panel .panel-header { border-bottom: 1px solid var(--line); }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(11, 29, 26, .58); display: grid; place-items: center; padding: 24px; backdrop-filter: blur(2px); }
.modal { width: min(680px, 100%); max-height: calc(100vh - 48px); overflow: hidden; display: flex; flex-direction: column; background: white; border-radius: 18px; box-shadow: 0 22px 70px rgba(10,36,31,.3); animation: modalIn .2s ease; }
.modal.wide { width: min(1040px, 100%); }
@keyframes modalIn { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
.modal-header { padding: 19px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { margin: 0; font-size: 18px; }
.modal-header p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.modal-close { border: 0; background: #f1f4f3; color: #6e7d7a; border-radius: 9px; width: 34px; height: 34px; font-size: 23px; line-height: 1; }
.modal-close:hover { background: var(--danger-soft); color: var(--danger); }
.modal-content { overflow: auto; padding: 22px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.field { display: grid; gap: 7px; }
.form-grid > .full { grid-column: 1 / -1; }
.field.grow { flex: 1; }
.field label { font-size: 12px; font-weight: 700; color: #4f605d; }
.required::after { content: " *"; color: var(--danger); }
.field input, .field select, .field textarea { width: 100%; border: 1px solid #dfe6e4; border-radius: 10px; padding: 10px 11px; outline: 0; color: var(--ink); background-color: #fff; }

/* Number fields type only: no spinner arrows, and app.js blurs them on wheel so scrolling never changes a value. */
input[type=number] { appearance: textfield; -moz-appearance: textfield; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.field input, .field select { height: 43px; }
.field textarea { resize: vertical; min-height: 80px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: #8eb1a8; box-shadow: 0 0 0 3px rgba(23,78,69,.06); }
.field small { color: var(--muted); font-size: 10px; }
.form-actions { margin-top: 22px; padding-top: 17px; border-top: 1px solid var(--line); display: flex; justify-content: end; gap: 8px; }
.line-items { margin-top: 18px; border: 1px solid var(--line); border-radius: 12px; overflow: auto; }
.line-items table { min-width: 800px; }
.line-items th { padding: 10px; }
.line-items td { padding: 8px 6px; }
.line-items input, .line-items select { width: 100%; height: 37px; border: 1px solid #dfe6e4; border-radius: 8px; padding: 7px; background-color: white; }
.line-items .item-select { min-width: 220px; }
.line-items .item-search { min-width: 280px; direction: ltr; text-align: left; }
.line-items .small-input { width: 85px; direction: ltr; text-align: center; }
.invoice-total { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; padding: 14px 17px; border-radius: 10px; background: var(--brand-soft); }
.invoice-total strong { color: var(--brand); font-size: 20px; }
.discount-row { margin-top: 14px; grid-template-columns: repeat(3, 1fr); }
.discount-row .field strong { display: flex; align-items: center; height: 43px; }
.add-line-btn { margin-top: 10px; border: 1px dashed #a9c5bd; background: #f7fbfa; color: var(--brand); border-radius: 9px; padding: 8px 13px; font-weight: 700; }
.import-drop { border: 2px dashed #bdd0cb; background: #f8fbfa; border-radius: 14px; padding: 28px; text-align: center; }
.import-drop input { display: none; }
.import-drop label { cursor: pointer; display: block; }
.import-icon { width: 55px; height: 55px; margin: auto; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); border-radius: 15px; font-size: 25px; }
.import-drop h4 { margin: 12px 0 5px; }
.import-drop p { margin: 0; color: var(--muted); font-size: 11px; }
.template-note { margin-top: 14px; border-radius: 10px; background: var(--accent-soft); color: #78531f; padding: 12px; font-size: 11px; line-height: 1.8; }
.import-preview { margin-top: 16px; max-height: 250px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }

.permission-guide { margin-bottom: 18px; padding: 18px 20px; display: grid; gap: 14px; border-color: #cfe0dc; background: linear-gradient(135deg, #f6fbf9, #fffdf8); }
.permission-guide strong { color: var(--brand); }
.permission-guide p { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.8; }
.permission-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.permission-chips span { padding: 7px 10px; border-radius: 999px; background: white; border: 1px solid var(--line); color: #435752; font-size: 10px; }
.role-badge { display: inline-flex; align-items: center; padding: 6px 9px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: 10px; font-weight: 800; }
.role-badge.accountant { background: #eaf3ff; color: #326596; }
.role-badge.viewer { background: #f0f1f2; color: #5d676d; }
.role-badge.admin { background: var(--accent-soft); color: #7b5421; }
.connection-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 10px; font-weight: 700; }
.connection-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #a5afad; }
.connection-badge.active::before { background: var(--success); }
.read-only-note { margin-bottom: 14px; padding: 10px 13px; border-radius: 10px; background: #f6f1e7; color: #765528; font-size: 11px; }
.unauthorized-state { max-width: 620px; margin: 70px auto; padding: 34px; text-align: center; }
.unauthorized-state h3 { margin: 0 0 8px; color: var(--danger); }
.unauthorized-state p { margin: 0; color: var(--muted); line-height: 1.8; }

.toast-container { position: fixed; left: 24px; bottom: 24px; z-index: 200; display: grid; gap: 9px; }
.toast { min-width: 280px; max-width: 380px; background: #173d36; color: white; border-radius: 11px; padding: 12px 14px; display: flex; align-items: center; gap: 10px; box-shadow: 0 10px 35px rgba(10,36,31,.2); animation: toastIn .25s ease; }
.toast.error { background: #8e3f3f; cursor: pointer; }
.toast .toast-close { margin-inline-start: auto; background: none; border: 0; color: inherit; font-size: 20px; line-height: 1; cursor: pointer; opacity: .8; padding: 0 2px; }
.toast .toast-close:hover { opacity: 1; }
.toast span { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: rgba(255,255,255,.13); }
@keyframes toastIn { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: none; } }

@media (max-width: 1100px) {
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .account-hero { align-items: stretch; flex-direction: column; }
  .account-summary { width: 100%; }
}

@media (max-width: 780px) {
  .sidebar { transform: translateX(110%); transition: transform .22s ease; box-shadow: -12px 0 40px rgba(5,24,20,.25); }
  .sidebar.open { transform: none; }
  .main-area { margin-inline-start: 0; }
  .menu-toggle { display: grid; }
  .topbar { height: 78px; padding: 0 17px; }
  .topbar-title p { display: none; }
  .date-chip { display: none; }
  main { padding: 18px 14px 38px; }
  .welcome-card { padding: 23px; align-items: stretch; flex-direction: column; }
  .welcome-card h3 { font-size: 20px; }
  .section-toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-actions { flex-wrap: wrap; }
  .toolbar-actions > * { flex: 1; }
  .filter-row { align-items: stretch; flex-direction: column; }
  .search-box { max-width: none; width: 100%; }
  .filter-row select, .filter-row input[type="month"] { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid > .full { grid-column: auto; }
  .account-summary { grid-template-columns: 1fr; }
  .summary-cell { border-right: 0; border-bottom: 1px solid var(--line); padding: 8px 0; }
  .modal-backdrop { padding: 10px; }
  .modal { max-height: calc(100vh - 20px); }
}

@media (max-width: 520px) {
  .metrics-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 88px; }
  .bar-chart { gap: 7px; padding-inline: 12px; }
  .panel-header { align-items: flex-start; }
  .toast-container { inset-inline: 12px; left: 12px; bottom: 12px; }
  .toast { min-width: 0; width: 100%; }
}

.print-only { display: none; } /* must precede the print block so print's display:block wins */

@media print {
  body { background: white; }
  .sidebar, .topbar, .section-toolbar, .account-hero .field, .statement-panel .panel-header button { display: none !important; }
  .main-area { margin: 0; }
  main { padding: 0; }
  .view { display: none !important; }
  .view.active { display: block !important; }
  .print-only { display: block; }
  .filter-row, .metrics-grid, .import-summary, .toolbar-actions { display: none !important; }
  .report-panel table { font-size: 11px; }
  .data-panel, .table-wrap { overflow: visible !important; }
  .report-panel td, .report-panel th { padding: 4px 6px; }
  .report-panel td:nth-child(3), .report-panel td:nth-child(4) { white-space: normal; }
  .panel { box-shadow: none; border-color: #bbb; }
  .account-hero { display: block; }
  .account-summary { display: grid; }
  .settlement { max-width: none; page-break-inside: avoid; }
  /* An open details modal prints alone: the page behind it is hidden and the modal flows as a plain document. */
  body:has(#modalBackdrop:not(.hidden)) .app-shell { display: none !important; }
  .modal-backdrop { position: static; padding: 0; background: none; backdrop-filter: none; display: block; }
  .modal, .modal.wide { width: auto; max-height: none; overflow: visible; box-shadow: none; border-radius: 0; animation: none; }
  .modal-content { overflow: visible; padding: 16px 0; }
  .modal-header { padding: 0 0 12px; }
  .modal-close, .modal .form-actions { display: none !important; }
  .modal .form-grid .field strong { font-size: 14px; }
}

/* Purchase decision report */
.import-summary { margin: 0 0 10px; font-size: 12px; color: var(--muted); }
.report-panel td.qty { direction: ltr; text-align: right; }
.radio-row { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; margin-top: 6px; cursor: pointer; }
.radio-row input { margin-top: 4px; }
.line-items tfoot td { border-top: 2px solid var(--line); background: #f7faf9; }
.report-panel .not-imported { color: var(--muted); font-size: 11px; }
.report-panel .col-sold { display: none; }
.report-panel.settlement-mode .col-sold { display: table-cell; }
.report-panel .qty.negative { color: var(--danger); }
.settlement { margin-top: 18px; border-top: 2px solid var(--line); padding-top: 14px; max-width: 560px; }
.settlement dl { display: grid; grid-template-columns: 1fr auto; gap: 6px 18px; margin: 0; }
.settlement dt { color: var(--muted); }
.settlement dd { margin: 0; font-weight: 700; direction: ltr; text-align: right; }
.settlement .sum { border-top: 1px solid var(--line); padding-top: 6px; }
.settlement .warn { color: var(--danger); margin: 10px 0 0; font-size: 13px; }
.settlement .authorize { margin: 14px 0 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: #f3f7f6; font-weight: 800; font-size: 16px; }
.settlement .authorize small { display: block; font-weight: 400; color: var(--muted); margin-top: 6px; font-size: 12px; }

/* Rebuild: sign-out button inside the profile card (not in the mockup). */
.profile-card .sidebar-tool { padding: 6px 8px; font-size: 12px; white-space: nowrap; }

/* dropdowns: hide native chrome (double border on macOS), draw our own chevron on the inline-end side */
.field select, .filter-row select, .line-items select, select { appearance: none; -webkit-appearance: none; cursor: pointer; padding-inline-end: 32px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%234f605d' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat left 12px center; }
