@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Playfair+Display:ital,wght@1,600&display=swap');

:root {
  --ink: #20231f;
  --muted: #6e716b;
  --paper: #f5f0e8;
  --card: #fffdf8;
  --coral: #d65c45;
  --coral-dark: #ad4030;
  --green: #344b3d;
  --line: #ddd7cc;
  --soft: #e9e3d9;
  --shadow: 0 24px 70px rgba(59, 49, 38, .13);
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: 'DM Sans', system-ui, sans-serif; min-height: 100vh; }
button, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-shell { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.brand-block { position: relative; overflow: hidden; padding: clamp(3rem, 8vw, 8rem); display: flex; flex-direction: column; justify-content: center; background: var(--green); color: #f7f0e5; }
.brand-block::before { content: ''; position: absolute; width: 32rem; height: 32rem; border: 1px solid rgba(255,255,255,.16); border-radius: 50%; right: -12rem; bottom: -15rem; box-shadow: 0 0 0 6rem rgba(255,255,255,.025), 0 0 0 12rem rgba(255,255,255,.02); }
.brand-block h1 { margin: 1rem 0; font-size: clamp(4rem, 9vw, 8.5rem); line-height: .8; letter-spacing: -.07em; }
.brand-block h1 em { font-family: 'Playfair Display', serif; font-weight: 600; color: #e98269; }
.brand-block p { font-size: 1.1rem; color: #d3d7d0; }
.eyebrow { letter-spacing: .18em; font-size: .72rem; font-weight: 700; color: var(--coral); }
.brand-block .eyebrow { color: #e9a08d; }
.login-card { align-self: center; width: min(460px, calc(100% - 3rem)); margin: auto; background: var(--card); border: 1px solid var(--line); padding: clamp(2rem, 5vw, 4rem); box-shadow: var(--shadow); }
.card-heading { display: flex; gap: 1rem; align-items: flex-start; margin-bottom: 2.25rem; }
.card-heading h2 { font-size: 2rem; margin: 0 0 .35rem; }
.card-heading p { margin: 0; color: var(--muted); }
.step { color: var(--coral); font-size: .75rem; font-weight: 700; padding-top: .45rem; }
label { display: grid; gap: .55rem; font-weight: 600; font-size: .86rem; margin: 1.15rem 0; }
input { width: 100%; border: 1px solid var(--line); background: #fff; padding: .9rem 1rem; color: var(--ink); outline: none; border-radius: 0; }
input:focus { border-color: var(--coral); box-shadow: 0 0 0 3px rgba(214,92,69,.12); }
.primary-button, .secondary-button, .text-button { border: 0; }
.primary-button { width: 100%; margin-top: .5rem; padding: 1rem 1.1rem; background: var(--coral); color: white; font-weight: 700; display: flex; justify-content: space-between; align-items: center; }
.primary-button:hover { background: var(--coral-dark); }
.login-link { text-decoration: none; }
.primary-button.compact { width: auto; margin: 0; padding: .8rem 1.15rem; }
.secondary-button { background: transparent; border: 1px solid var(--line); padding: .75rem 1rem; color: var(--ink); }
.text-button { background: transparent; color: var(--muted); padding: .5rem; }
.text-button:hover { color: var(--coral); }
.form-error { color: #b2352c; font-size: .84rem; min-height: 1.2rem; }

.topbar { height: 78px; display: flex; align-items: center; justify-content: space-between; padding: 0 clamp(1.25rem, 5vw, 5rem); border-bottom: 1px solid var(--line); background: rgba(245,240,232,.88); backdrop-filter: blur(10px); }
.wordmark { text-decoration: none; color: var(--ink); display: flex; align-items: baseline; gap: .65rem; }
.wordmark strong { letter-spacing: .16em; }
.wordmark span { color: var(--muted); font-size: .8rem; }
.dashboard { width: min(1200px, calc(100% - 2.5rem)); margin: 0 auto; padding: 4rem 0; }
.hero-row { display: flex; justify-content: space-between; align-items: end; gap: 2rem; margin-bottom: 2.5rem; }
.hero-row h1 { font-size: clamp(2.5rem, 5vw, 4.7rem); letter-spacing: -.055em; margin: .5rem 0 .25rem; }
.hero-row p { color: var(--muted); margin: 0; text-transform: capitalize; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--green); color: white; margin-bottom: 1.5rem; }
.stats article { padding: 1.5rem 1.75rem; border-right: 1px solid rgba(255,255,255,.15); display: grid; grid-template-columns: 1fr auto; align-items: end; gap: .25rem 1rem; }
.stats article:last-child { border: 0; }
.stats span { color: #ccd4ce; font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; }
.stats strong { font-size: 2.5rem; line-height: 1; grid-row: span 2; }
.stats small { color: #aab6ae; }
.stats .value-stat strong { font-size: clamp(1.2rem, 2vw, 1.9rem); }
.inventory-panel { background: var(--card); border: 1px solid var(--line); }
.panel-heading { min-height: 92px; padding: 1.25rem 1.75rem; display: flex; align-items: center; justify-content: space-between; gap: 2rem; border-bottom: 1px solid var(--line); }
.panel-heading > div { display: flex; gap: .85rem; align-items: baseline; }
.panel-heading h2 { margin: 0; font-size: 1.5rem; }
.search { position: relative; margin: 0; width: min(330px, 100%); }
.search span { position: absolute; left: 1rem; top: .78rem; font-size: 1.15rem; color: var(--muted); }
.search input { padding-left: 2.5rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 1080px; }
th { color: var(--muted); font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; text-align: left; padding: .9rem 1.75rem; border-bottom: 1px solid var(--line); }
td { padding: 1.15rem 1.75rem; border-bottom: 1px solid var(--soft); }
tbody tr:hover { background: #faf6ef; }
tbody tr:last-child td { border-bottom: 0; }
.number { text-align: right; }
td.code { font-weight: 700; letter-spacing: .04em; }
.count-badge { display: inline-flex; min-width: 3rem; justify-content: center; padding: .35rem .6rem; background: #e5eee8; color: var(--green); font-weight: 700; }
.count-badge.low { background: #f8ddd6; color: #a53e2e; }
.positive { color: #2f6848; font-weight: 700; }
.negative { color: #a53e2e; font-weight: 700; }
.row-actions { display: flex; justify-content: flex-end; gap: .4rem; }
.icon-button { background: transparent; border: 1px solid transparent; color: var(--muted); padding: .45rem .65rem; }
.icon-button:hover { border-color: var(--line); color: var(--ink); }
.icon-button.danger:hover { color: #a52e26; }
.empty-state { text-align: center; padding: 5rem 1rem; color: var(--muted); }
.empty-state div { font-size: 2rem; color: var(--coral); }
.empty-state h3 { color: var(--ink); margin-bottom: .3rem; }
.empty-state p { margin: 0; }

dialog { border: 0; padding: 0; width: min(520px, calc(100% - 2rem)); background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(23,29,25,.62); backdrop-filter: blur(3px); }
dialog form { padding: 2.25rem; position: relative; }
dialog h2 { margin: .55rem 0 1.75rem; font-size: 2rem; }
.close-button { position: absolute; right: 1.2rem; top: 1rem; border: 0; background: transparent; color: var(--muted); font-size: 1.8rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .75rem; margin-top: 1.5rem; }
.toast { position: fixed; right: 1.5rem; bottom: 1.5rem; transform: translateY(150%); background: var(--green); color: white; padding: .9rem 1.25rem; box-shadow: var(--shadow); transition: transform .25s ease; }
.toast.show { transform: translateY(0); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

@media (max-width: 760px) {
  .login-shell { grid-template-columns: 1fr; }
  .brand-block { min-height: 38vh; padding: 2.5rem 1.5rem; }
  .brand-block h1 { font-size: 4.2rem; }
  .login-card { margin: -2rem auto 2rem; position: relative; }
  .dashboard { padding: 2.5rem 0; }
  .hero-row { align-items: stretch; flex-direction: column; }
  .hero-row .primary-button { width: 100%; justify-content: center; }
  .stats { grid-template-columns: 1fr; }
  .stats article { border-right: 0; border-bottom: 1px solid rgba(255,255,255,.15); }
  .panel-heading { align-items: stretch; flex-direction: column; }
  .search { width: 100%; }
}
