:root {
  --navy: #0b3558;
  --navy-2: #092943;
  --blue: #1769aa;
  --teal: #12a594;
  --bg: #f3f6f9;
  --card: #ffffff;
  --text: #17212b;
  --muted: #697887;
  --line: #dce4eb;
  --danger: #c83b3b;
  --warning: #b57908;
  --success: #178365;
  --shadow: 0 14px 34px rgba(11, 53, 88, .08);
  --radius: 16px;
}

* { box-sizing: border-box; }
html { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); }
body { margin: 0; min-height: 100vh; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 10% 10%, rgba(18,165,148,.18), transparent 30%),
    linear-gradient(135deg, var(--navy-2), var(--navy));
}

.login-card {
  width: min(460px, 100%);
  background: white;
  border-radius: 24px;
  padding: 34px;
  box-shadow: 0 24px 80px rgba(0,0,0,.25);
  display: grid;
  gap: 24px;
}

.brand-mark {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--teal);
  color: white;
  font-size: 32px;
  font-weight: 900;
}
.brand-mark.small { width: 42px; height: 42px; border-radius: 12px; font-size: 24px; }

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; }
h2 { margin-bottom: 0; }
h3 { margin-bottom: 4px; }
.eyebrow { font-size: 11px; letter-spacing: .14em; font-weight: 800; color: var(--teal); margin-bottom: 6px; }
.muted { color: var(--muted); }
.stack { display: grid; gap: 16px; }
label { display: grid; gap: 7px; font-weight: 700; font-size: 13px; }
input, select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--text);
  outline: none;
}
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23,105,170,.12); }
input[readonly] { background: #eef3f7; color: #536472; }

.primary, .secondary, .ghost, .danger-button {
  min-height: 42px;
  border-radius: 10px;
  border: 0;
  padding: 10px 16px;
  font-weight: 800;
}
.primary { background: var(--navy); color: white; }
.primary:hover { background: var(--navy-2); }
.secondary { background: #e8f1f8; color: var(--navy); }
.ghost { background: transparent; color: var(--navy); border: 1px solid var(--line); }
.ghost.inverse { color: white; border-color: rgba(255,255,255,.25); }
.danger-button { background: var(--danger); color: white; }
.form-error { color: var(--danger); min-height: 20px; font-size: 13px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 240px 1fr; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--navy);
  color: white;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  z-index: 20;
}
.brand-row { display: flex; align-items: center; gap: 12px; padding: 0 8px 24px; }
.brand-row strong, .brand-row small { display: block; }
.brand-row small { color: rgba(255,255,255,.65); }
.sidebar nav { display: grid; gap: 6px; }
.nav-item {
  border: 0;
  background: transparent;
  color: rgba(255,255,255,.76);
  text-align: left;
  border-radius: 10px;
  padding: 12px 14px;
  font-weight: 750;
}
.nav-item:hover, .nav-item.active { color: white; background: rgba(255,255,255,.12); }
.sidebar-footer { margin-top: auto; display: grid; gap: 12px; }
.user-email { font-size: 11px; color: rgba(255,255,255,.7); overflow-wrap: anywhere; }

.main-content { min-width: 0; padding: 0 26px 40px; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  min-height: 88px;
  display: flex;
  align-items: center;
  gap: 18px;
  justify-content: space-between;
  background: rgba(243,246,249,.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(220,228,235,.8);
  margin-bottom: 24px;
}
.menu-btn { display: none; border: 0; background: transparent; font-size: 24px; }

.view { display: none; }
.view.active { display: block; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}
.kpi span { color: var(--muted); font-size: 13px; font-weight: 700; }
.kpi strong { font-size: 32px; color: var(--navy); }
.kpi.warning strong { color: var(--warning); }
.kpi.danger strong { color: var(--danger); }

.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.panel-header p { color: var(--muted); font-size: 13px; margin-bottom: 0; }
.panel-header.wrap { flex-wrap: wrap; }

.data-list { display: grid; gap: 10px; }
.data-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px;
  display: grid;
  gap: 7px;
}
.data-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.data-card strong { color: var(--navy); }
.meta { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 12px; color: var(--muted); }
.empty-state { color: var(--muted); text-align: center; padding: 28px 10px; }

.receipt-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; align-items: start; }
.form-main { display: grid; gap: 18px; }
.form-side { min-width: 0; }
.sticky-panel { position: sticky; top: 112px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.span-2 { grid-column: span 2; }
.photo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 18px; }
.photo-box {
  min-height: 220px;
  border: 2px dashed #b9c9d6;
  border-radius: 14px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 7px;
  text-align: center;
  padding: 14px;
  overflow: hidden;
  position: relative;
  color: var(--navy);
}
.photo-box input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photo-box img { display: none; max-height: 210px; max-width: 100%; object-fit: contain; border-radius: 10px; }
.photo-box.has-image > :not(input):not(img) { display: none; }
.photo-box.has-image img { display: block; }
.photo-icon { font-size: 32px; }
.photo-box small { color: var(--muted); font-weight: 500; }
.recognition-box { border: 1px solid var(--line); background: #f8fafc; border-radius: 14px; padding: 16px; display: grid; align-content: start; gap: 12px; }
.recognition-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.status-badge { display: inline-flex; align-items: center; padding: 6px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; background: #e7f4ef; color: var(--success); }
.status-badge.neutral { background: #edf1f4; color: var(--muted); }
.status-badge.warning { background: #fff3d8; color: var(--warning); }
.status-badge.danger { background: #fde7e7; color: var(--danger); }
.suggestions { display: grid; gap: 7px; }
.suggestion {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px;
  background: white;
  text-align: left;
}
.suggestion:hover { border-color: var(--blue); }

.summary-list { display: grid; gap: 0; margin: 16px 0; }
.summary-list div { display: flex; justify-content: space-between; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.summary-list dt { color: var(--muted); font-size: 12px; }
.summary-list dd { margin: 0; text-align: right; font-weight: 800; }
.check-row { display: flex; grid-template-columns: auto 1fr; align-items: center; gap: 10px; font-weight: 600; }
.check-row input { width: 18px; min-height: 18px; }
.button-stack { display: grid; gap: 9px; margin-top: 18px; }
.small-note { color: var(--muted); font-size: 11px; margin: 12px 0 0; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; }
.filters input { min-width: 250px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); font-size: 13px; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.status-pill { padding: 5px 8px; border-radius: 999px; display: inline-flex; font-size: 11px; font-weight: 800; }
.status-pill.expired { background: #fde7e7; color: var(--danger); }
.status-pill.warning { background: #fff3d8; color: var(--warning); }
.status-pill.ok { background: #e7f4ef; color: var(--success); }

.products-grid { grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); }
.form-actions { display: flex; gap: 10px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
.import-row { display: flex; justify-content: space-between; gap: 14px; align-items: center; }
.import-row small { display: block; color: var(--muted); margin-top: 4px; }
.file-button { display: inline-flex; align-items: center; position: relative; white-space: nowrap; }
.file-button input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.card-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.mini-button { border: 1px solid var(--line); background: #fff; color: var(--navy); border-radius: 8px; padding: 6px 9px; font-weight: 750; font-size: 11px; }
.mini-button.danger { color: var(--danger); }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(390px, calc(100vw - 40px));
  z-index: 100;
  padding: 13px 16px;
  border-radius: 12px;
  background: var(--navy);
  color: white;
  box-shadow: 0 14px 40px rgba(0,0,0,.22);
  transform: translateY(120px);
  opacity: 0;
  transition: .25s ease;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

.modal { position: fixed; inset: 0; z-index: 90; background: rgba(7,25,40,.58); display: grid; place-items: center; padding: 20px; }
.modal-card { background: white; border-radius: 16px; width: min(430px, 100%); padding: 22px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .receipt-layout { grid-template-columns: 1fr; }
  .sticky-panel { position: static; }
}
@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: -260px; width: 240px; transition: left .25s ease; }
  .sidebar.open { left: 0; box-shadow: 20px 0 50px rgba(0,0,0,.2); }
  .main-content { padding: 0 14px 30px; }
  .menu-btn { display: inline-block; }
  .topbar { min-height: 76px; }
  .panel-grid, .products-grid, .photo-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .kpi-grid, .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .panel { padding: 15px; }
  .login-card { padding: 24px; }
  .filters { display: grid; width: 100%; }
  .filters input { min-width: 0; }
  .import-row { align-items: flex-start; flex-direction: column; }
}

.field-hint {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
}
.field-hint.match { color: var(--success); }
.field-hint.new { color: var(--warning); }
