:root {
  --bg:      #FFFFFF;
  --primary: #171A31;
  --accent:  #F05A22;
  --border:  #E5E7EB;
  --muted:   #9CA3AF;
  --surface: #F9FAFB;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', sans-serif;
  font-size: 14px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
header {
  background: var(--primary);
  color: #fff;
  height: 52px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  flex-shrink: 0;
}
.header-logo {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.header-logo .accent { color: var(--accent); }

/* ── App body (sidebar + main) ── */
.app-body {
  display: flex;
  flex: 1;
}

/* ── Sidebar ── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  display: flex;
  flex-direction: column;
}
.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 12px 16px 4px;
}
.sidebar-item {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  font-size: 13px;
  color: #4B5563;
  text-decoration: none;
  transition: background 0.1s, color 0.1s;
  border-right: 3px solid transparent;
}
.sidebar-item:hover {
  background: #F3F4F6;
  color: var(--primary);
}
.sidebar-item.active {
  background: #FEEDE6;
  color: var(--accent);
  font-weight: 600;
  border-right-color: var(--accent);
}

/* ── Main ── */
main {
  flex: 1;
  padding: 28px 24px;
  min-width: 0;
}

/* ── Page header ── */
.page-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 24px;
}

/* ── Section ── */
.section { margin-bottom: 40px; }
.section-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--accent);
  display: inline-block;
}

/* ── Camera feed grid ── */
.camera-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}
.camera-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  width: 280px;
  background: var(--bg);
}
.camera-card-name  { font-size: 13px; font-weight: 700; margin-bottom: 2px; }
.camera-card-store { font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.camera-card-img {
  width: 100%;
  border-radius: 4px;
  background: #F3F4F6;
  display: block;
  aspect-ratio: 4/3;
  object-fit: cover;
}
.camera-card-shelves {
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.camera-card-offline {
  width: 100%;
  aspect-ratio: 4/3;
  background: #F3F4F6;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--muted);
}

/* ── Shelf cards grid ── */
.shelf-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

/* ── Store group ── */
.store-group {
  width: 100%;
  margin-bottom: 24px;
}
.store-group-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  margin-bottom: 12px;
}
.store-shelf-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

/* ── Shelf card ── */
.shelf-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  width: 200px;
  background: var(--bg);
}
.shelf-card--closed {
  opacity: 0.45;
  border-style: dashed;
}
.shelf-card-closed-badge {
  font-size: 10px;
  color: var(--muted);
  background: #F3F4F6;
  border-radius: 4px;
  padding: 2px 6px;
  display: inline-block;
  margin-bottom: 8px;
}
.shelf-card-name  { font-size: 13px; font-weight: 700; }
.shelf-card-store { font-size: 11px; color: var(--muted); margin-top: 2px; margin-bottom: 16px; }
.shelf-products {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  margin-bottom: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
  cursor: default;
}
.shelf-products[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  padding: 5px 8px;
  border-radius: 4px;
  white-space: normal;
  max-width: 240px;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  line-height: 1.5;
}
.shelf-card-badge-row  { margin-bottom: 12px; }
.shelf-card-indicators { font-size: 16px; letter-spacing: 2px; margin-bottom: 6px; }
.shelf-card-count { font-size: 11px; color: var(--muted); margin-bottom: 12px; }
.shelf-card-time  { font-size: 11px; color: var(--muted); }

/* ── Badge ── */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 700;
}
.badge-full         { background: #F0F9F0; color: #27AE60; }
.badge-slightly_low { background: #FFF8E6; color: #E67E22; }
.badge-half         { background: #FEEDE6; color: #F05A22; }
.badge-empty        { background: #FDE8E8; color: #E74C3C; }
.badge-unknown      { background: #EBEBEB; color: #333333; }

/* ── Card (table wrapper) ── */
.card {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
}

/* ── Table ── */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead { background: var(--surface); }
th {
  padding: 9px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--surface);
  color: var(--primary);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #FAFAFA; }

/* ── Empty state ── */
.empty-msg {
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ── Auto refresh hint ── */
.auto-refresh {
  font-size: 11px;
  color: var(--muted);
  text-align: right;
  margin-top: 8px;
}

/* ── Toast ── */
#toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
  pointer-events: auto;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.3s ease, transform 0.3s ease;
  max-width: 340px;
}
.toast-success { background: var(--primary); color: #fff; }
.toast-error   { background: #c0392b; color: #fff; }
.toast-fade-out { opacity: 0; transform: translateY(-6px); }

/* ── Utility ── */
.hidden { display: none !important; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-danger  { background: #E74C3C; color: #fff; }
.btn-default { background: var(--surface); color: var(--primary); border: 1px solid var(--border); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ── Page header row ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: #fff;
  border-radius: 10px;
  padding: 28px;
  width: 480px;
  max-width: calc(100vw - 32px);
  box-shadow: 0 20px 48px rgba(0,0,0,0.2);
}
.modal-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 20px;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}

/* ── Form ── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: var(--primary);
  background: var(--bg);
  transition: border-color 0.15s;
}
.form-control:focus { outline: none; border-color: var(--accent); }
.form-hint { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ── Conditions page ── */
.shelf-section { margin-bottom: 32px; }
.shelf-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--accent);
}
.shelf-section-title { font-size: 14px; font-weight: 700; }
.shelf-section-sub { font-size: 12px; color: var(--muted); margin-left: 8px; }

/* ── Notifications page ── */
.notif-shelf {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
}
.notif-shelf-name { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.notif-default-hint { font-size: 11px; color: var(--muted); font-style: italic; margin-bottom: 12px; }
.notif-states { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.notif-state-item { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.notif-state-item input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* ── Confirm dialog ── */
#confirm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 500;
  align-items: center;
  justify-content: center;
}
#confirm-overlay.active { display: flex; }
#confirm-box {
  background: #fff;
  border-radius: 8px;
  padding: 24px 28px;
  min-width: 300px;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
#confirm-box h4 { font-size: 15px; font-weight: 700; margin-bottom: 10px; }
#confirm-box p  { font-size: 13px; color: #555; margin-bottom: 20px; line-height: 1.5; }
#confirm-box .confirm-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ── Footer ── */
footer {
  text-align: center;
  padding: 16px;
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid var(--border);
}
