:root {
  --black: #050505;
  --surface: #0d0d0e;
  --surface-raised: #141416;
  --surface-soft: #19191c;
  --red: #d71920;
  --red-bright: #f02b32;
  --red-dark: #78090d;
  --white: #ffffff;
  --ink: #ededee;
  --muted: #96969d;
  --line: #2b2b30;
  --line-strong: #3a3a40;
  --green: #35c889;
  --amber: #e8ac3e;
  --shadow: 0 30px 90px rgba(0, 0, 0, 0.58);
}

* { box-sizing: border-box; }
html { background: var(--black); color-scheme: dark; overflow-x: hidden; }
body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 82% -10%, rgba(190, 11, 17, 0.15), transparent 34rem),
    linear-gradient(180deg, #080809 0%, #050505 46%, #09090a 100%);
  color: var(--ink);
  font-family: "Open Sans", sans-serif;
  line-height: 1.5;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.22;
  background-image: linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.014) 1px, transparent 1px);
  background-size: 44px 44px;
}
button, input, select { font: inherit; }
button, a { transition: border-color .18s ease, background .18s ease, color .18s ease, transform .18s ease, opacity .18s ease; }
h1, h2, h3, .tracker-brand { font-family: "Montserrat", sans-serif; }
.hidden { display: none !important; }
.tracker-shell { width: min(1280px, calc(100% - 48px)); margin-inline: auto; }

.tracker-header { position: sticky; top: 0; z-index: 20; border-bottom: 1px solid rgba(255,255,255,.08); background: rgba(5,5,6,.92); backdrop-filter: blur(18px); }
.header-inner { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.tracker-brand { display: flex; align-items: center; gap: 12px; color: var(--white); text-decoration: none; }
.tracker-brand strong { display: block; text-transform: uppercase; letter-spacing: .055em; font-size: 1.05rem; }
.tracker-brand small { display: block; margin-top: -3px; color: #d94a4f; text-transform: uppercase; letter-spacing: .13em; font-size: .64rem; font-weight: 700; }
.hammer-mark { width: 37px; height: 45px; color: var(--red-bright); filter: drop-shadow(0 0 13px rgba(215,25,32,.25)); }
.hammer-mark svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 6; }
.account-actions { display: flex; align-items: center; gap: 10px; }
.account-label { max-width: 260px; overflow: hidden; color: var(--muted); font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.text-button, .link-button { border: 0; background: none; color: #f3f3f4; cursor: pointer; text-decoration: none; font-weight: 700; padding: 9px 12px; }
.text-button { border: 1px solid transparent; border-radius: 7px; }
.text-button:hover { border-color: var(--line-strong); background: var(--surface-raised); color: var(--white); }
.link-button:hover { color: #ff5d62; }

.auth-stage { min-height: calc(100vh - 76px); display: grid; place-items: center; padding: 48px 20px; }
.auth-panel { width: min(520px, 100%); padding: clamp(26px, 5vw, 48px); border: 1px solid var(--line); border-radius: 22px; background: linear-gradient(145deg, #171719, #0b0b0c); box-shadow: var(--shadow); }
.eyebrow { margin: 0 0 8px; color: #ef3a40; font-weight: 800; font-size: .69rem; letter-spacing: .16em; text-transform: uppercase; }
.auth-panel h1, .dashboard h1 { margin: 0; color: var(--white); text-transform: uppercase; line-height: 1.04; }
.auth-panel h1 { font-size: clamp(2rem, 8vw, 3.3rem); }
.auth-panel > p:not(.eyebrow), .dashboard-heading p:last-child { color: var(--muted); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; margin: 24px 0; padding: 4px; border: 1px solid var(--line); border-radius: 9px; }
.auth-tab { border: 0; border-radius: 6px; padding: 10px; background: none; color: var(--muted); font-weight: 800; cursor: pointer; }
.auth-tab.active { background: var(--red-dark); color: var(--white); }

.stack-form, .form-grid { display: grid; gap: 16px; }
.form-grid { grid-template-columns: 1fr 1fr; }
.field { display: grid; gap: 7px; min-width: 0; }
.field-wide, .schedule-fields, .toggle-field { grid-column: 1 / -1; }
.field label, .schedule-fields legend { color: #f3f3f4; font-size: .81rem; font-weight: 700; }
.field label span, .field small { color: var(--muted); font-weight: 400; }
.field small { margin-top: -2px; font-size: .75rem; }
.field input, .field select {
  width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 7px;
  background: #09090a; color: var(--white);
}
input[type="number"] { appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { appearance: none; margin: 0; }
.field input:focus, .field select:focus, button:focus-visible, a:focus-visible { outline: 3px solid rgba(240,43,50,.28); outline-offset: 2px; border-color: var(--red-bright); }
.primary-button, .secondary-button { min-height: 46px; border-radius: 7px; padding: 0 18px; font-weight: 800; text-transform: uppercase; letter-spacing: .035em; cursor: pointer; }
.primary-button { border: 1px solid #ef3036; background: linear-gradient(180deg, #de1c23, #a3090e); color: var(--white); box-shadow: 0 10px 28px rgba(180,10,16,.22); }
.primary-button:hover { transform: translateY(-1px); filter: brightness(1.1); }
.primary-button:disabled { opacity: .52; cursor: wait; transform: none; }
.secondary-button { border: 1px solid var(--line-strong); background: #151517; color: var(--white); }
.secondary-button:hover { background: #202024; }
.form-message { min-height: 1.45em; margin: 0; color: #ff9ca0; font-size: .84rem; }
.form-message.success { color: #78dfae; }

.dashboard { padding: clamp(38px, 5.5vw, 72px) 0 40px; }
.dashboard-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 27px; }
.dashboard-heading h1 { font-size: clamp(2rem, 4.4vw, 3.8rem); letter-spacing: -.035em; }
.dashboard-heading p:last-child { max-width: 650px; margin: 10px 0 0; font-size: .94rem; }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.summary-card { min-height: 94px; display: flex; align-items: center; gap: 14px; padding: 17px 18px; border: 1px solid var(--line); border-radius: 11px; background: linear-gradient(145deg, rgba(24,24,27,.94), rgba(12,12,14,.98)); box-shadow: 0 12px 35px rgba(0,0,0,.18); }
.summary-icon { width: 42px; height: 42px; flex: 0 0 auto; display: grid; place-items: center; border: 1px solid rgba(240,43,50,.27); border-radius: 9px; background: rgba(134,7,12,.18); color: #f1484e; }
.summary-icon svg { width: 21px; height: 21px; }
.summary-card strong { display: block; color: var(--white); font: 800 clamp(1.25rem, 2.4vw, 1.85rem) "Montserrat", sans-serif; line-height: 1.05; }
.summary-card small { display: block; margin-top: 5px; color: var(--muted); font-size: .68rem; font-weight: 700; letter-spacing: .075em; text-transform: uppercase; }
.dashboard-toolbar { display: flex; margin: 22px 0 18px; }
.add-product-button { min-width: 174px; }
.add-product-button span { margin-right: 5px; font-size: 1.25rem; line-height: 0; }
.page-message { margin-bottom: 18px; padding: 11px 14px; border: 1px solid #783236; border-radius: 8px; background: #281113; }
.page-message.success { border-color: rgba(53,200,137,.38); background: rgba(20,87,60,.2); color: #8de7bb; }

.product-list-header { display: grid; grid-template-columns: minmax(230px, 1.25fr) minmax(135px, .7fr) minmax(125px, .65fr) minmax(110px, .55fr) minmax(350px, 1.7fr); gap: 16px; padding: 0 18px 10px; color: #77777f; font-size: .64rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.product-list-header span:last-child { text-align: right; }
.product-grid { display: grid; gap: 10px; }
.tracker-card { position: relative; display: grid; grid-template-columns: minmax(230px, 1.25fr) minmax(135px, .7fr) minmax(125px, .65fr) minmax(110px, .55fr) minmax(350px, 1.7fr); gap: 16px; align-items: center; padding: 20px 18px; overflow: hidden; border: 1px solid var(--line); border-radius: 11px; background: linear-gradient(110deg, rgba(20,20,23,.98), rgba(10,10,12,.98)); box-shadow: 0 12px 40px rgba(0,0,0,.19); }
.tracker-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--status-color, #777); }
.tracker-card:hover { border-color: #414148; transform: translateY(-1px); }
.product-main { min-width: 0; }
.product-title-line { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.product-title-line h2 { max-width: 100%; margin: 0; overflow: hidden; color: var(--white); font-size: 1.05rem; line-height: 1.18; text-overflow: ellipsis; white-space: nowrap; }
.status-badge { display: inline-flex; align-items: center; min-height: 22px; padding: 3px 8px; border: 1px solid color-mix(in srgb, var(--status-color) 58%, transparent); border-radius: 999px; background: color-mix(in srgb, var(--status-color) 12%, transparent); color: var(--status-color); font-size: .58rem; font-weight: 800; letter-spacing: .075em; text-transform: uppercase; }
.product-spec, .product-added { margin: 5px 0 0; color: var(--muted); font-size: .75rem; }
.product-spec span { margin-inline: 3px; color: #54545a; }
.product-added { font-size: .68rem; }
.product-metric strong, .stock-metric strong { display: block; color: var(--white); font: 700 .94rem "Montserrat", sans-serif; }
.product-metric > span, .stock-metric span { display: block; margin-top: 3px; color: var(--muted); font-size: .67rem; }
.days-metric strong { font-size: 1.24rem; }
.stock-metric strong { color: var(--status-color); }
.progress { width: min(130px, 100%); height: 4px; margin-top: 9px; overflow: hidden; border-radius: 999px; background: #303036; }
.progress span { display: block; width: var(--remaining); height: 100%; background: var(--status-color); }
.product-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
.product-actions button, .product-actions a { min-height: 34px; display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 0 9px; border: 1px solid var(--line-strong); border-radius: 7px; background: #151517; color: #c9c9cd; cursor: pointer; text-decoration: none; font-size: .65rem; font-weight: 800; line-height: 1; white-space: nowrap; }
.product-actions button:hover, .product-actions a:hover { border-color: #66666e; background: #242428; color: var(--white); transform: translateY(-1px); }
.product-actions .primary-action { border-color: #ac1319; background: #8e0c11; color: var(--white); }
.product-actions .delete-action { color: #ef686d; }
.product-actions svg { width: 14px; height: 14px; flex: 0 0 auto; }
.product-actions .action-icon { display: inline-flex; }
.product-details { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; margin: 0 -18px -20px; border-top: 1px solid #25252a; background: rgba(0,0,0,.14); }
.detail { min-width: 0; padding: 12px 18px; border-right: 1px solid #25252a; }
.detail:last-child { border-right: 0; }
.detail span { display: block; color: #77777f; font-size: .59rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.detail strong { display: block; margin-top: 3px; overflow: hidden; color: #d9d9dc; font-size: .73rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.card-warning { grid-column: 1 / -1; margin: 0; padding: 9px 12px; border: 1px solid #8b561b; border-radius: 7px; background: rgba(139,86,27,.13); color: #ffd89b; font-size: .77rem; }

.empty-state { padding: 78px 22px; text-align: center; border: 1px dashed #414147; border-radius: 14px; background: rgba(255,255,255,.018); }
.empty-rune { color: #9e0c11; font-size: 4rem; line-height: 1; }
.empty-state h2 { margin: 18px 0 0; color: var(--white); }
.empty-state p { color: var(--muted); }
.disclaimer { max-width: 900px; margin: 35px auto 0; padding-top: 20px; border-top: 1px solid #252529; color: #77777d; font-size: .74rem; text-align: center; }

.tracker-dialog { width: min(760px, calc(100% - 28px)); max-height: 90vh; overflow: auto; padding: 25px; border: 1px solid #44444b; border-radius: 15px; background: #101012; color: var(--ink); box-shadow: var(--shadow); }
.tracker-dialog::backdrop { background: rgba(0,0,0,.74); backdrop-filter: blur(3px); }
.tracker-dialog[open] { animation: dialog-in .2s ease both; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.product-panel { position: fixed; inset: 0 0 0 auto; width: min(430px, 100%); min-width: 0; max-width: none; height: 100dvh; max-height: none; margin: 0; padding: 28px 26px 22px; border-width: 0 0 0 1px; border-radius: 0; background: linear-gradient(180deg, #121214, #09090a); }
.product-panel[open] { animation: panel-in .24s ease both; }
@keyframes panel-in { from { opacity: 0; transform: translateX(36px); } to { opacity: 1; transform: translateX(0); } }
.compact-dialog { width: min(520px, calc(100% - 28px)); }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.dialog-heading h2 { margin: 0; color: var(--white); font-size: 1.6rem; text-transform: uppercase; }
.panel-description { margin: 7px 0 0; color: var(--muted); font-size: .8rem; }
.icon-button { width: 38px; height: 38px; flex: 0 0 auto; border: 1px solid var(--line-strong); border-radius: 50%; background: #18181b; color: var(--white); font-size: 1.35rem; cursor: pointer; }
.schedule-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; min-width: 0; padding: 15px; border: 1px solid #323237; border-radius: 9px; }
.schedule-fields legend { padding: 0 6px; }
.weekday-picker { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.weekday-picker label input { position: absolute; opacity: 0; }
.weekday-picker span { min-height: 38px; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--muted); font-size: .72rem; cursor: pointer; }
.weekday-picker input:checked + span { border-color: #d51b22; background: #830b10; color: var(--white); }
.weekday-picker input:focus-visible + span { outline: 3px solid rgba(255,65,70,.32); outline-offset: 2px; }
.custom-schedule { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.toggle-field { display: flex; align-items: center; gap: 10px; color: #ededee; font-size: .82rem; font-weight: 700; }
.toggle-field input { width: 19px; height: 19px; accent-color: var(--red); }
.helper-note, .privacy-note { color: var(--muted); font-size: .74rem; }
.reminder-choice-card { padding: 16px; border: 1px solid #323237; border-radius: 10px; background: linear-gradient(145deg, rgba(142,12,17,.09), rgba(255,255,255,.018)); }
.reminder-choice-card .field small { display: block; margin-top: 7px; color: #929299; font-size: .72rem; line-height: 1.45; }
.reminder-choice-card .helper-note { margin: 0; padding-top: 13px; border-top: 1px solid #2c2c31; }
.privacy-note { margin: 18px 0 0; text-align: center; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1.35fr; gap: 9px; margin-top: 18px; }
.history-list { display: grid; gap: 10px; }
.history-row { display: grid; grid-template-columns: 1fr auto auto; gap: 15px; align-items: center; padding: 13px; border: 1px solid #333338; border-radius: 8px; }
.history-row small { color: var(--muted); }
.history-actions { display: flex; gap: 7px; }
.history-actions button { border: 1px solid #44444a; border-radius: 6px; padding: 7px 10px; background: #19191b; color: var(--white); cursor: pointer; }
.history-actions .delete { color: #ff9da0; }
.history-empty { padding: 30px; color: var(--muted); text-align: center; }
.inventory-history { margin-top: 24px; padding-top: 20px; border-top: 1px solid #333338; }
.inventory-history h3 { font-size: 1rem; }
.inventory-entry { display: flex; justify-content: space-between; gap: 20px; padding: 7px 0; color: var(--muted); font-size: .8rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 1080px) {
  .product-list-header { display: none; }
  .tracker-card { grid-template-columns: minmax(220px, 1.5fr) repeat(3, minmax(110px, .75fr)); }
  .product-actions { grid-column: 1 / -1; justify-content: flex-start; padding-top: 12px; border-top: 1px solid #29292e; }
  .product-details { grid-template-columns: repeat(3, minmax(0,1fr)); }
}

@media (max-width: 820px) {
  .tracker-shell { width: min(100% - 28px, 1280px); }
  .account-label { display: none; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tracker-card { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .product-main { grid-column: 1 / -1; }
  .product-actions { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .product-actions button, .product-actions a { width: 100%; min-height: 42px; justify-content: flex-start; padding-inline: 12px; font-size: .72rem; }
  .product-details { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 620px) {
  .tracker-shell { width: min(100% - 20px, 1280px); }
  .header-inner { min-height: 68px; gap: 8px; }
  .hammer-mark { width: 30px; height: 38px; }
  .tracker-brand { gap: 8px; }
  .tracker-brand strong { font-size: .82rem; }
  .tracker-brand small { font-size: .49rem; }
  .account-actions { gap: 2px; }
  .text-button { padding: 7px; font-size: .67rem; }
  .dashboard { padding-top: 32px; }
  .dashboard-heading h1 { font-size: clamp(1.75rem, 9vw, 2.45rem); }
  .dashboard-heading p:last-child { font-size: .82rem; }
  .summary-grid { gap: 8px; }
  .summary-card { min-height: 82px; gap: 10px; padding: 13px 12px; }
  .summary-icon { width: 34px; height: 34px; }
  .summary-icon svg { width: 17px; height: 17px; }
  .summary-card strong { font-size: 1.05rem; }
  .summary-card small { font-size: .56rem; }
  .dashboard-toolbar { margin-top: 16px; }
  .add-product-button { width: 100%; }
  .tracker-card { grid-template-columns: 1fr 1fr; padding: 18px 15px; border-radius: 10px; }
  .product-title-line h2 { font-size: 1rem; white-space: normal; }
  .product-metric, .stock-metric { padding: 11px; border: 1px solid #29292e; border-radius: 7px; background: rgba(0,0,0,.13); }
  .product-actions { gap: 8px; }
  .product-actions button, .product-actions a { min-height: 44px; }
  .product-details { grid-template-columns: 1fr; margin-inline: -15px; }
  .detail { border-right: 0; border-bottom: 1px solid #25252a; }
  .form-grid, .schedule-fields, .custom-schedule { grid-template-columns: 1fr; }
  .weekday-picker { grid-template-columns: repeat(4, 1fr); }
  .product-panel { width: 100%; padding: 22px 16px 18px; border-left: 0; }
  .compact-dialog { padding: 20px 16px; }
  .history-row { grid-template-columns: 1fr; }
  .history-actions { justify-content: flex-start; }
  .inventory-entry { display: grid; gap: 2px; }
}

@media (max-width: 360px) {
  .tracker-brand small { display: none; }
  .summary-grid { grid-template-columns: 1fr; }
  .tracker-card { grid-template-columns: 1fr; }
  .product-main, .product-actions { grid-column: 1; }
  .dialog-actions { grid-template-columns: 1fr; }
}

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