:root {
  --ink: #202116;
  --olive: #202116;
  --paper: #f5f0df;
  --card: #fffdf5;
  --red: #c84a2f;
  --green: #1d6956;
  --orange: #dfa052;
  --line: #d9d1ba;
  --muted: #716d5e;
  --shadow: 5px 6px 0 #d2c7aa;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: ui-sans-serif, system-ui, sans-serif; }
h1, h2, h3, p { margin-top: 0; }
h1, h2 { font-family: Georgia, serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.overline { margin: 0 0 .45rem; color: var(--orange); font-size: .7rem; font-weight: 850; letter-spacing: .15em; }
.subtext { color: var(--muted); line-height: 1.55; }
.brand-mark { width: 46px; height: 46px; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid #e8b56e; border-radius: 5px; color: var(--olive); background: var(--orange); font: 800 1.55rem Georgia, serif; box-shadow: 3px 3px 0 #4c4d3b; transform: rotate(-2deg); }
.brand-mark.large { width: 64px; height: 64px; margin-bottom: 2.5rem; font-size: 2.1rem; box-shadow: 5px 5px 0 #4c4d3b; }

/* Sign in and shop setup */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, .9fr) minmax(520px, 1.1fr); }
.auth-story { display: flex; flex-direction: column; justify-content: center; padding: clamp(3rem, 7vw, 7rem); color: white; background: var(--olive); }
.auth-story h1 { margin: .8rem 0 1.2rem; font-size: clamp(4.5rem, 9vw, 8rem); line-height: .78; letter-spacing: -.05em; }
.story-copy { color: #eeeadf; font-size: 1.15rem; }
.login-shop-art { display: block; width: min(100%, 440px); height: auto; margin: 1rem 0 .25rem; overflow: visible; animation: scene-arrive .55s ease-out both; }
.login-hanging-board { transform-box: fill-box; transform-origin: 50% 0; animation: sign-sway 5.5s ease-in-out .8s infinite; }
.privacy-note { max-width: 360px; margin-top: 2.5rem; padding: 1rem; border: 1px solid #66624f; color: #ded9ca; line-height: 1.5; }
.auth-window { align-self: center; width: min(620px, calc(100% - 3rem)); margin: 3rem auto; padding: clamp(1.5rem, 4vw, 3rem); border: 1px solid var(--line); background: var(--card); box-shadow: var(--shadow); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 2rem; border: 1px solid var(--line); }
.auth-tab { padding: .8rem; border: 0; color: var(--muted); background: #eee7d4; font-weight: 800; }
.auth-tab.active { color: white; background: var(--olive); }
.auth-panel h2 { margin: .35rem 0 .5rem; font-size: 2.2rem; }
.auth-panel form { display: grid; gap: .9rem; margin-top: 1.5rem; }
label { display: grid; gap: .4rem; color: #48483e; font-size: .8rem; font-weight: 750; }
label > span { color: #928d7d; font-size: .68rem; font-weight: 500; }
input, select, textarea { width: 100%; padding: .8rem; border: 1px solid var(--line); border-radius: 4px; color: var(--ink); background: white; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 2px #1d69561c; }
.password-field { position: relative; display: flex; align-items: center; }
.password-field input { padding-right: 4rem; }
.password-field .password-toggle { position: absolute; right: .65rem; padding: .25rem; border: 0; color: var(--green); background: transparent; font-size: .72rem; font-weight: 800; }
.shop-form { grid-template-columns: 1fr 1fr; }
.shop-form .full { grid-column: 1 / -1; }
.primary { padding: .85rem 1rem; border: 0; border-radius: 4px; color: white; background: var(--red); font-weight: 850; }
.primary:hover { background: #ab3d28; }
.switch-copy { margin: 1.25rem 0 0; color: var(--muted); text-align: center; font-size: .8rem; }
.text-action { padding: 0; border: 0; color: var(--green); background: none; font-weight: 800; }
.error { margin-top: 1rem; padding: .8rem; border-left: 4px solid var(--red); color: #72291e; background: #f7ddd6; font-size: .82rem; }

/* Shop shell */
.app-header { display: grid; grid-template-columns: minmax(260px, 1fr) auto minmax(260px, 1fr); align-items: center; gap: 2rem; padding: 1.2rem max(4vw, 1.5rem); color: white; background: var(--olive); }
.header-shop { display: flex; align-items: center; gap: .9rem; }
.header-shop h1 { margin: 0; font-size: clamp(1.55rem, 3vw, 2.25rem); }
.header-shop p:not(.overline) { margin: .15rem 0 0; color: #d8d4c7; font-size: .75rem; }
.desktop-nav { display: flex; align-items: center; gap: .25rem; }
.desktop-nav a { padding: .55rem .7rem; border-bottom: 2px solid transparent; color: #cbc8bc; text-decoration: none; font-size: .76rem; font-weight: 750; }
.desktop-nav a:hover, .desktop-nav a.active { color: white; border-color: var(--orange); }
.account-menu { display: flex; justify-content: flex-end; align-items: center; gap: .7rem; }
.account-menu > span { display: grid; text-align: right; font-size: .76rem; }
.account-menu small { color: #bdbbad; }
.owner-avatar, .customer-avatar { width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid #ffffff30; border-radius: 50%; color: white; background: #ffffff12; font-weight: 850; }
.outline-button { padding: .5rem .7rem; border: 1px solid #777364; border-radius: 4px; color: white; background: transparent; font-size: .72rem; font-weight: 750; }
.outline-button.dark { color: var(--green); border-color: var(--green); }

.dashboard { max-width: 1240px; margin: auto; padding: 2rem; display: grid; gap: 1.5rem; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; padding: .5rem 0; }
.page-heading h2 { margin: .2rem 0; font-size: clamp(2rem, 4vw, 3rem); }
.page-heading > div > p:last-child { margin: 0; color: var(--muted); }
.privacy-badge { padding: .8rem 1rem; border: 1px solid #9d9a82; color: var(--olive); background: #efecd9; }
.privacy-badge div { display: grid; font-size: .75rem; }
.privacy-badge small { margin-top: .12rem; color: var(--muted); }

/* A small hand drawn kiryana scene anchors the working screen in a real shop. */
.shop-scene { position: relative; overflow: hidden; border: 1px solid #c9c0a7; background: #e8e4cf; box-shadow: 4px 4px 0 #d2c7aa; animation: scene-arrive .55s ease-out both; }
.scene-caption { position: absolute; z-index: 1; top: .65rem; left: .8rem; display: flex; align-items: center; gap: .45rem; color: #5d5848; font-size: .65rem; font-weight: 700; letter-spacing: .035em; }
.scene-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.kirana-art { display: block; width: 100%; height: clamp(118px, 18vw, 205px); }
.kirana-art [fill="#d7b578"] { animation: jar-glint 5s ease-in-out 1s infinite; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); background: var(--card); box-shadow: 4px 4px 0 #d2c7aa; }
.stat-card { padding: 1.15rem 1.25rem; border-right: 1px solid var(--line); }
.stat-card:last-child { border: 0; }
.stat-card p { margin-bottom: .65rem; color: var(--muted); font-size: .74rem; }
.stat-card strong { display: block; margin-bottom: .2rem; font: 800 1.75rem Georgia, serif; }
.stat-card span { color: #918c7c; font-size: .68rem; }
.stat-card.featured { color: white; background: var(--red); }
.stat-card.featured p, .stat-card.featured span { color: #f7dfd8; }
.stat-card.warning strong { color: var(--red); }

.working-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(330px, .75fr); gap: 1.5rem; align-items: start; }
.card { padding: 1.6rem; border: 1px solid var(--line); background: var(--card); box-shadow: var(--shadow); }
.section-title { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; margin-bottom: 1.25rem; }
.section-title h2 { margin: .2rem 0 .35rem; font-size: 1.75rem; }
.section-title p:not(.overline) { margin: 0; color: var(--muted); font-size: .8rem; line-height: 1.5; }
.entry-card form { display: grid; gap: .8rem; }
.record-button { display: flex; align-items: center; gap: .9rem; width: 100%; padding: 1rem; border: 1px solid #b9b39e; border-radius: 4px; color: var(--ink); background: #f2eddd; text-align: left; }
.record-button:hover { border-color: var(--red); }
.record-button .mic { width: 42px; height: 42px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; color: white; background: var(--red); }
.record-copy { display: grid; gap: .15rem; }
.record-button small { color: var(--muted); font-size: .7rem; font-weight: 500; }
.voice-meter { height: 30px; display: flex; align-items: center; gap: 3px; margin-left: auto; opacity: .35; }
.voice-meter i { width: 3px; height: 5px; border-radius: 2px; background: var(--green); transform: scaleY(.7); }
.record-button.is-recording { border-color: var(--red); background: #f7e6df; }
.record-button.is-recording .mic { animation: mic-pulse 1.7s ease-out infinite; }
.record-button.is-recording .voice-meter { opacity: 1; }
.record-button.is-recording .voice-meter i { animation: voice-bar .75s ease-in-out infinite alternate; }
.record-button.is-recording .voice-meter i:nth-child(3n) { animation-duration: .58s; }
.record-button.is-recording .voice-meter i:nth-child(3n + 1) { animation-duration: .92s; }
.record-button.is-recording .voice-meter i:nth-child(4n) { animation-delay: -.35s; }
.record-button.has-recording .voice-meter { opacity: .8; }
.record-button.has-recording .voice-meter i { height: 12px; opacity: .7; }
.file-row { display: flex; align-items: center; gap: 1rem; padding: .7rem .8rem; border: 1px dashed #c8c0a8; color: var(--muted); background: #f7f2e4; }
.file-row > span { min-width: 135px; }
.file-row input { padding: 0; border: 0; background: transparent; font-size: .72rem; }
.divider { display: flex; align-items: center; gap: .7rem; color: #958f7d; font-size: .65rem; text-transform: uppercase; letter-spacing: .07em; }
.divider::before, .divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
textarea { min-height: 100px; resize: vertical; line-height: 1.5; }
.result { margin-top: 1rem; padding: 1rem; color: #eae7d9; background: #25261d; white-space: pre-wrap; font: 12px/1.55 ui-monospace, monospace; }

.brief-list { display: grid; gap: .8rem; }
.brief-item { display: flex; gap: .8rem; padding: .9rem; border-left: 4px solid var(--red); background: #f2eddd; }
.brief-item .priority { width: 24px; height: 24px; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid var(--red); border-radius: 50%; color: var(--red); font-size: .65rem; font-weight: 850; }
.brief-item h3 { display: inline; margin: 0 .35rem 0 0; font-size: .9rem; }
.brief-item b { color: var(--red); font-size: .85rem; }
.brief-item p { margin: .35rem 0 0; color: var(--muted); font-size: .72rem; line-height: 1.45; }
.brief-item .message { color: var(--green); }
.empty-state { padding: 2rem 1rem; border: 1px dashed #c8c0a8; color: var(--muted); text-align: center; }
.empty-state > span { display: none; }
.empty-state b { display: block; color: var(--ink); font-family: Georgia, serif; font-size: 1.1rem; }
.empty-state p { margin: .3rem 0 0; font-size: .74rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .85rem .75rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; font-size: .8rem; }
th { color: var(--muted); font-size: .65rem; letter-spacing: .08em; text-transform: uppercase; }
tbody tr:hover { background: #f5efdf; }
.customer-cell { display: flex; align-items: center; gap: .65rem; }
.customer-avatar { width: 31px; height: 31px; border: 0; color: var(--green); background: #e2eee5; font-size: .72rem; }
.balance, .entry-type { display: inline-block; padding: .28rem .48rem; border-radius: 3px; font-size: .68rem; font-weight: 750; }
.balance.open, .entry-type.credit_given { color: #7a2f20; background: #f3ddd5; }
.balance.settled, .entry-type.credit_paid { color: var(--green); background: #dfede5; }
.money { color: var(--red); font-weight: 850; }
.danger { padding: .35rem .5rem; border: 0; border-radius: 3px; color: #7a2f20; background: #f3ddd5; font-size: .68rem; font-weight: 750; }
.empty-row td { padding: 2rem; text-align: center; }
.empty-row b, .empty-row span { display: block; }
.empty-row span { margin-top: .25rem; color: var(--muted); font-size: .72rem; }
.review-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .9rem; }
.review-item { display: grid; gap: .7rem; padding: 1rem; border-left: 4px solid var(--red); background: #f8e8e1; }
.review-item p { margin: 0; font-size: .77rem; line-height: 1.45; }
.review-actions { display: flex; gap: .5rem; }
footer { padding: 1.8rem; color: #e5e0d2; background: var(--olive); text-align: center; font-size: .76rem; }

@keyframes voice-bar { from { transform: scaleY(.65); } to { transform: scaleY(3.1); } }
@keyframes mic-pulse { 0% { box-shadow: 0 0 0 0 #c84a2f55; } 75%, 100% { box-shadow: 0 0 0 11px #c84a2f00; } }
@keyframes scene-arrive { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes jar-glint { 0%, 85%, 100% { filter: brightness(1); } 90% { filter: brightness(1.12); } }
@keyframes sign-sway { 0%, 84%, 100% { transform: rotate(0); } 89% { transform: rotate(2deg); } 94% { transform: rotate(-1.2deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media (max-width: 1000px) {
  .app-header { grid-template-columns: 1fr auto; }
  .desktop-nav { display: none; }
  .working-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-story { min-height: 280px; padding: 2rem 1.5rem; }
  .auth-story h1 { font-size: 4.6rem; }
  .login-shop-art { width: min(100%, 360px); max-height: 120px; margin-top: .25rem; }
  .privacy-note { display: none; }
  .auth-window { width: calc(100% - 1.5rem); margin: -.8rem auto 1rem; padding: 1.25rem; }
  .app-header { display: flex; flex-wrap: wrap; gap: .8rem; }
  .account-menu { width: 100%; justify-content: flex-start; padding-top: .7rem; border-top: 1px solid #494a3b; }
  .account-menu .outline-button { margin-left: auto; }
  .page-heading { display: grid; }
  .privacy-badge { width: fit-content; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-card:nth-child(2) { border-right: 0; }
  .stat-card:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .dashboard { padding: 1rem; }
  .shop-scene { margin: 0 -.1rem; }
  .kirana-art { height: 125px; }
}

@media (max-width: 520px) {
  .shop-form, .stats-grid { grid-template-columns: 1fr; }
  .shop-form .full { grid-column: auto; }
  .stat-card { border-right: 0; border-bottom: 1px solid var(--line); }
  .section-title { display: grid; }
  .file-row { display: grid; gap: .5rem; }
  .review-actions { display: grid; }
}
