:root {
  --ink: #153c37;
  --ink-soft: #54716d;
  --cream: #f7f6ee;
  --surface: #ffffff;
  --line: #e4e7df;
  --green: #177a64;
  --green-deep: #115f50;
  --mint: #e8f5ee;
  --orange: #f1a434;
  --orange-soft: #fff4de;
  --blue: #4f89bb;
  --blue-soft: #edf5fb;
  --rose: #c66a6a;
  --rose-soft: #fbeeee;
  --shadow: 0 12px 35px rgba(30, 61, 54, .06);
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; background: var(--cream); color: var(--ink); font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; padding: 76px 0 0 244px; }
.topbar { position: fixed; z-index: 10; inset: 0 0 auto; height: 76px; padding: 0 32px; display: flex; align-items: center; justify-content: space-between; background: rgba(255, 255, 255, .93); border-bottom: 1px solid var(--line); backdrop-filter: blur(14px); }
.brand { display: inline-flex; gap: 10px; align-items: center; color: var(--ink); font-weight: 800; font-size: 21px; text-decoration: none; letter-spacing: -.75px; }
.brand > span:last-child span { color: var(--green); }
.brand-mark { position: relative; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50% 50% 48% 48%; background: var(--green); }
.brand-mark::before, .brand-mark::after, .brand-mark span { content: ""; position: absolute; background: white; }
.brand-mark::before { width: 12px; height: 2px; border-radius: 2px; transform: translateY(-5px); }
.brand-mark::after { width: 12px; height: 2px; border-radius: 2px; transform: translateY(5px); }
.brand-mark span { width: 17px; height: 2px; border-radius: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 18px; }
.today { color: var(--ink-soft); font-size: 13px; }
.profile-button { height: 30px; padding: 0 13px; color: var(--green-deep); background: #dff1e8; border: 0; border-radius: 999px; font-size: 12px; font-weight: 800; }

.sidebar { position: fixed; z-index: 5; inset: 76px auto 0 0; width: 244px; padding: 26px 16px 20px; display: flex; flex-direction: column; background: #fff; border-right: 1px solid var(--line); }
.nav-links { display: grid; gap: 6px; }
.nav-link { display: flex; align-items: center; gap: 13px; width: 100%; padding: 12px 14px; color: #6b817d; background: transparent; border: 0; border-radius: 9px; font-weight: 650; text-align: left; transition: .18s ease; }
.nav-link:hover { color: var(--green); background: #f1f8f4; }
.nav-link.active { color: var(--green-deep); background: #e3f3ea; }
.nav-icon { width: 17px; color: currentColor; font-size: 18px; line-height: 1; text-align: center; }
.side-note { margin-top: auto; padding: 15px 12px; display: flex; gap: 9px; align-items: flex-start; color: var(--ink); background: #f5f8f3; border: 1px solid #e8eee5; border-radius: 10px; }
.side-note strong { display: block; font-size: 11px; }
.side-note small { display: block; max-width: 132px; margin-top: 2px; color: var(--ink-soft); font-size: 10px; line-height: 1.25; }
.status-dot { width: 8px; height: 8px; flex: 0 0 auto; margin-top: 3px; background: #47aa70; border-radius: 50%; box-shadow: 0 0 0 3px #d9f1e1; }

.main-content { max-width: 1540px; margin: 0 auto; padding: 40px 46px 60px; }
.view { display: none; animation: fade .22s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: .5; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.eyebrow { margin: 0 0 7px; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 5px; color: var(--ink); font-size: clamp(25px, 3vw, 32px); letter-spacing: -1.1px; line-height: 1.15; }
h2 { margin-bottom: 3px; color: var(--ink); font-size: 16px; letter-spacing: -.35px; }
.subheading, .panel-heading p { margin-bottom: 0; color: var(--ink-soft); }
.quick-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 11px; min-height: 40px; padding: 0 16px; border: 1px solid transparent; border-radius: 7px; font-size: 13px; font-weight: 750; transition: transform .18s, box-shadow .18s, background .18s; }
.button:hover { transform: translateY(-1px); }
.button.primary { color: #fff; background: var(--green); box-shadow: 0 4px 10px rgba(23, 122, 100, .18); }
.button.primary:hover { background: var(--green-deep); box-shadow: 0 6px 15px rgba(23, 122, 100, .22); }
.button.secondary { color: var(--green-deep); background: #fff; border-color: #b8d2c4; }
.button.secondary:hover { background: var(--mint); }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { min-height: 132px; padding: 20px; display: flex; gap: 13px; align-items: flex-start; background: #fff; border: 1px solid var(--line); border-radius: 11px; box-shadow: 0 5px 16px rgba(29, 60, 52, .025); }
.stat-icon { display: grid; width: 33px; height: 33px; flex: 0 0 auto; place-items: center; border-radius: 9px; font-size: 17px; font-weight: 800; }
.stat-card p { margin-bottom: 7px; color: var(--ink-soft); font-size: 12px; }
.stat-card strong { display: block; margin-bottom: 3px; font-size: 22px; letter-spacing: -.8px; line-height: 1.05; white-space: nowrap; }
.stat-card small { color: #849892; font-size: 10px; }
.stat-card.green .stat-icon { color: var(--green); background: var(--mint); }
.stat-card.orange .stat-icon { color: #bd7a14; background: var(--orange-soft); }
.stat-card.blue .stat-icon { color: var(--blue); background: var(--blue-soft); }
.stat-card.rose .stat-icon { color: var(--rose); background: var(--rose-soft); }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(280px, .85fr); gap: 20px; }
.panel { min-width: 0; padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; box-shadow: var(--shadow); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 20px; }
.panel-heading p { font-size: 12px; }
.text-button { padding: 1px 0; color: var(--green); background: transparent; border: 0; font-size: 12px; font-weight: 750; white-space: nowrap; }
.text-button span { margin-left: 3px; font-size: 15px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th { padding: 0 8px 11px; color: #82918d; border-bottom: 1px solid var(--line); font-size: 10px; font-weight: 800; letter-spacing: .06em; text-align: left; text-transform: uppercase; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
td { padding: 13px 8px; color: #49635e; border-bottom: 1px solid #eff1ec; font-size: 12px; }
tbody tr:last-child td { border-bottom: 0; }
.invoice { color: var(--green-deep); font-weight: 800; }
.customer-name { color: var(--ink); font-weight: 700; }
.amount { color: var(--ink); font-weight: 750; }
.badge { display: inline-flex; padding: 4px 8px; border-radius: 999px; font-size: 10px; font-weight: 800; }
.badge.settled { color: #168253; background: #e2f5e9; }
.badge.pending { color: #b76e0a; background: #fff1d8; }
.empty-row td { padding: 42px 8px; color: #8a9a95; text-align: center; }

.collection-panel { display: flex; flex-direction: column; align-items: center; }
.collection-panel .panel-heading { width: 100%; }
.collection-ring { --value: 0%; position: relative; display: grid; width: 136px; height: 136px; margin: 3px auto 14px; place-items: center; background: conic-gradient(var(--green) var(--value), #e9eeeb 0); border-radius: 50%; }
.collection-ring::before { content: ""; position: absolute; width: 105px; height: 105px; background: #fff; border-radius: 50%; }
.collection-ring span { position: relative; color: var(--ink); font-size: 24px; font-weight: 800; letter-spacing: -1px; }
.collection-copy { display: grid; gap: 3px; margin-bottom: 17px; text-align: center; }
.collection-copy strong { font-size: 13px; }
.collection-copy span { color: var(--ink-soft); font-size: 11px; }
.key { display: flex; align-items: center; gap: 6px; width: 100%; padding-top: 15px; color: var(--ink-soft); border-top: 1px solid var(--line); font-size: 10px; }
.key strong { margin-right: auto; color: var(--ink); font-size: 10px; }
.key strong:last-child { margin-right: 0; }
.key-dot { width: 7px; height: 7px; border-radius: 50%; }
.key-dot.collected { background: var(--green); }.key-dot.due { background: #d9e3df; }

.content-grid { display: grid; gap: 20px; align-items: start; }
.customer-layout { grid-template-columns: minmax(290px, .65fr) minmax(0, 1.45fr); }
.order-layout, .return-layout { grid-template-columns: minmax(290px, .7fr) minmax(0, 1.3fr); }
.form-panel { position: sticky; top: 96px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid label { display: grid; gap: 7px; color: var(--ink); font-size: 12px; font-weight: 750; }
.form-grid label.full, .form-grid .full { grid-column: 1 / -1; }
.optional { color: #91a19c; font-weight: 550; }
input, select, textarea { width: 100%; padding: 10px 11px; color: var(--ink); outline: none; background: #fff; border: 1px solid #dce4df; border-radius: 7px; font-size: 13px; transition: border .16s, box-shadow .16s; }
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: #aab6b1; }
input:focus, select:focus, textarea:focus { border-color: #5ead92; box-shadow: 0 0 0 3px #e5f4ed; }
input[readonly] { color: #708580; background: #f7f9f6; cursor: default; }
.form-hint { margin: -4px 0 0; color: var(--ink-soft); font-size: 11px; }
.submit-button { margin-top: 4px; }
.search-box { display: flex; gap: 6px; align-items: center; width: min(190px, 45%); padding: 0 9px; color: #84938e; border: 1px solid var(--line); border-radius: 7px; }
.search-box input { min-width: 0; padding: 8px 0; border: 0; box-shadow: none; font-size: 11px; }
.search-box input:focus { box-shadow: none; }
.customer-table-wrap, .orders-table-wrap, .returns-table-wrap, .ledger-table-wrap { min-height: 240px; }
.customer-summary { display: grid; gap: 2px; }.customer-summary small { color: #83918d; font-size: 10px; font-weight: 500; }
.negative { color: var(--rose); }.credit { color: var(--green); }
.action-button.pay { color: #fff; background: var(--green); border-color: var(--green); }.action-button.pay:hover { background: var(--green-deep); }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.modal-backdrop { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px; background: rgba(21, 60, 55, .45); backdrop-filter: blur(3px); }
.modal-backdrop[hidden] { display: none; }
.modal { width: min(460px, 100%); max-height: 88vh; overflow-y: auto; }
.modal-close { width: 28px; height: 28px; flex: 0 0 auto; padding: 0; color: var(--ink-soft); background: #f0f4ef; border: 0; border-radius: 50%; font-size: 12px; }
.modal-close:hover { color: var(--ink); background: #e3eae2; }
.payment-history { margin-top: 16px; display: grid; gap: 6px; }
.payment-history h3 { margin: 6px 0 2px; color: var(--ink-soft); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.payment-row { display: grid; grid-template-columns: auto 1fr auto auto; gap: 10px; align-items: center; padding: 8px 10px; color: var(--ink-soft); background: #f7f9f6; border: 1px solid var(--line); border-radius: 7px; font-size: 11px; }
.payment-row strong { color: var(--ink); }
.form-actions { display: flex; gap: 10px; }.form-actions .primary { flex: 1; }.form-actions [hidden] { display: none; }
.action-group { display: flex; gap: 6px; align-items: center; }.action-button { min-height: 28px; padding: 0 8px; color: var(--green-deep); background: #f1f8f4; border: 1px solid #d6e9de; border-radius: 5px; font-size: 10px; font-weight: 800; }.action-button:hover { background: #e3f3ea; }.action-button.delete { color: #ae4a4a; background: #fff4f2; border-color: #f2d8d3; }.action-button.delete:hover { background: #fce7e3; }
.ledger-panel { padding: 0; overflow: hidden; }.ledger-toolbar { padding: 22px; display: flex; align-items: end; justify-content: space-between; gap: 24px; background: linear-gradient(120deg, #fff, #f4faf6); border-bottom: 1px solid var(--line); }.ledger-select { display: grid; gap: 7px; min-width: min(310px, 100%); color: var(--ink); font-size: 12px; font-weight: 750; }.ledger-summary { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 22px; }.ledger-stat { display: grid; gap: 2px; min-width: 102px; }.ledger-stat span { color: var(--ink-soft); font-size: 10px; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; }.ledger-stat strong { color: var(--ink); font-size: 15px; }.ledger-contact { padding: 13px 22px; color: var(--ink-soft); background: #fff; border-bottom: 1px solid var(--line); font-size: 12px; }.ledger-contact strong { color: var(--ink); }.ledger-table-wrap { padding: 22px; }.ledger-description { color: var(--ink); font-weight: 700; }.ledger-balance { color: var(--ink); font-weight: 800; }

.toast { position: fixed; z-index: 20; right: 24px; bottom: 24px; max-width: min(350px, calc(100vw - 40px)); padding: 12px 16px; color: #fff; background: var(--ink); border-radius: 8px; box-shadow: 0 10px 28px rgba(21, 60, 55, .25); font-weight: 650; opacity: 0; pointer-events: none; transform: translateY(12px); transition: .24s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #a94949; }

@media (max-width: 1100px) {
  .app-shell { padding-left: 0; }
  .sidebar { position: fixed; z-index: 9; top: auto; right: 0; width: auto; height: 67px; padding: 7px 14px; flex-direction: row; background: rgba(255,255,255,.97); border-top: 1px solid var(--line); border-right: 0; backdrop-filter: blur(14px); }
  .nav-links { width: 100%; display: flex; justify-content: space-around; gap: 4px; }.nav-link { width: auto; padding: 8px 12px; font-size: 11px; }.nav-icon { font-size: 15px; }.side-note { display: none; }
  .main-content { padding-bottom: 95px; }
}
@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .customer-layout, .order-layout, .return-layout { grid-template-columns: 1fr; }
  .form-panel { position: static; }.dashboard-grid { grid-template-columns: 1fr; }.collection-panel { min-height: auto; }.ledger-toolbar { align-items: stretch; flex-direction: column; }.ledger-summary { justify-content: flex-start; }
}
@media (max-width: 620px) {
  .topbar { height: 64px; padding: 0 18px; }.app-shell { padding-top: 64px; }.sidebar { height: 62px; }.main-content { padding: 28px 16px 85px; }.today { display: none; }.page-heading { display: block; margin-bottom: 22px; }.quick-actions { margin-top: 17px; }.quick-actions .button { flex: 1; }.stat-grid { gap: 10px; margin-bottom: 12px; }.stat-card { min-height: 110px; padding: 14px; gap: 9px; }.stat-card strong { font-size: 18px; }.stat-card small { display: none; }.stat-icon { width: 29px; height: 29px; }.panel { padding: 17px; }.ledger-panel { padding: 0; }.form-grid { gap: 13px; }.form-grid label { grid-column: 1 / -1; }.search-box { width: 45%; }.nav-link { min-width: 0; padding: 7px 4px; gap: 4px; font-size: 9px; flex-direction: column; }.nav-icon { width: auto; }.sidebar { padding: 5px 2px; }.brand { font-size: 19px; }.profile-button { height: 28px; padding: 0 10px; font-size: 11px; }.ledger-toolbar, .ledger-table-wrap { padding: 17px; }.ledger-contact { padding: 12px 17px; }.ledger-summary { gap: 14px; }.ledger-stat { min-width: 82px; }.action-group { gap: 4px; }.action-button { padding: 0 6px; }.toast { right: 16px; bottom: 76px; }
}
