/* HACCP Management System — Shopify-style admin */

:root {
  --brand: #860031;
  --brand-dark: #6b0027;
  --brand-light: rgba(134, 0, 49, 0.08);
  --sidebar-w: 260px;
  --header-h: 56px;
  --bg: #f6f6f7;
  --surface: #ffffff;
  --border: #e3e3e5;
  --text: #1a1a1a;
  --text-muted: #6d7175;
  --success: #008060;
  --warning: #b98900;
  --critical: #d72c0d;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

a {
  color: var(--brand);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* App shell */
.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  text-decoration: none;
}
.sidebar-brand:hover {
  text-decoration: none;
}
.sidebar-brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
}

.nav-section {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 12px 12px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin-bottom: 2px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover {
  background: var(--bg);
  text-decoration: none;
}
.nav-link.active {
  background: var(--brand-light);
  color: var(--brand);
  font-weight: 600;
}
.nav-link svg {
  width: 18px;
  height: 18px;
  opacity: 0.7;
  flex-shrink: 0;
}
.nav-link.active svg {
  opacity: 1;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

.main-wrap {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  gap: 16px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.menu-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border: none;
  background: var(--bg);
  border-radius: 8px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.search-wrap {
  position: relative;
  max-width: 420px;
  flex: 1;
}
.search-wrap input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--bg);
}
.search-wrap input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px var(--brand-light);
}
.search-wrap svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  position: relative;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
}
.icon-btn:hover {
  background: var(--bg);
}
.icon-btn .dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: var(--brand);
  border-radius: 50%;
  border: 2px solid var(--surface);
}

.dropdown {
  position: relative;
}
.dropdown-panel {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 280px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 150;
}
.dropdown-panel.is-open {
  display: block;
}
.dropdown-panel h4 {
  margin: 0;
  padding: 12px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.dropdown-panel ul {
  list-style: none;
  margin: 0;
  padding: 8px 0;
  max-height: 320px;
  overflow-y: auto;
}
.dropdown-panel li {
  padding: 10px 16px;
  font-size: 13px;
  border-bottom: 1px solid #f4f4f5;
  cursor: pointer;
}
.dropdown-panel li:hover {
  background: var(--bg);
}
.dropdown-panel li small {
  display: block;
  color: var(--text-muted);
  margin-top: 2px;
}

.profile-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 4px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}
.profile-btn:hover {
  background: var(--bg);
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.content {
  flex: 1;
  padding: 20px 24px 32px;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.page-header h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.page-header p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  font-family: inherit;
}
.btn-primary {
  background: var(--brand);
  color: #fff;
}
.btn-primary:hover {
  background: var(--brand-dark);
}
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.btn-secondary:hover {
  background: var(--bg);
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad {
  padding: 16px 20px;
}
.card-title {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  padding: 16px 18px;
}
.stat-card .label {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.stat-card .value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.stat-card .change {
  font-size: 12px;
  margin-top: 6px;
}
.stat-card .change.up {
  color: var(--success);
}
.stat-card .change.down {
  color: var(--critical);
}
.stat-icon {
  float: right;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--brand-light);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.grid-3-2 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}
@media (max-width: 1024px) {
  .grid-2,
  .grid-3-2 {
    grid-template-columns: 1fr;
  }
}

/* Badges */
.badge {
  display: inline-flex;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
}
.badge-success {
  background: #e3f1df;
  color: var(--success);
}
.badge-warning {
  background: #fff5ea;
  color: var(--warning);
}
.badge-critical {
  background: #fee8e6;
  color: var(--critical);
}
.badge-info {
  background: var(--brand-light);
  color: var(--brand);
}
.badge-neutral {
  background: #f1f1f1;
  color: var(--text-muted);
}

/* Tables */
.table-wrap {
  overflow-x: auto;
}
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: #fafafa;
  border-bottom: 1px solid var(--border);
}
table.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f1f1;
  vertical-align: middle;
}
table.data-table tbody tr:hover {
  background: #fafafa;
}
table.data-table a {
  font-weight: 500;
}

/* Filters */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 4px;
  color: var(--text-muted);
}
.input,
.select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  min-width: 140px;
}
.input:focus,
.select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px var(--brand-light);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-muted);
}
.pagination-btns {
  display: flex;
  gap: 4px;
}
.pagination-btns button {
  padding: 6px 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.pagination-btns button:hover:not(:disabled) {
  background: var(--bg);
}
.pagination-btns button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Chart placeholder */
.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 160px;
  padding-top: 8px;
}
.chart-bar {
  flex: 1;
  background: var(--brand-light);
  border-radius: 4px 4px 0 0;
  min-height: 8px;
  position: relative;
  transition: height 0.4s ease;
}
.chart-bar span {
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}
.chart-bar.fill {
  background: var(--brand);
}

.activity-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.activity-list li {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #f1f1f1;
  font-size: 13px;
}
.activity-list li:last-child {
  border-bottom: none;
}
.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
  margin-top: 6px;
  flex-shrink: 0;
}

.compliance-ring {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: conic-gradient(var(--brand) 0 92%, #e3e3e5 92% 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
}
.compliance-ring-inner {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  color: var(--brand);
}

/* Login */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a1a1a 0%, #3d1520 50%, var(--brand) 100%);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: 12px;
  padding: 32px;
  box-shadow: var(--shadow-md);
}
.login-card h1 {
  margin: 0 0 8px;
  font-size: 22px;
}
.login-card .sub {
  color: var(--text-muted);
  margin-bottom: 24px;
  font-size: 14px;
}
.login-card .field {
  margin-bottom: 16px;
}
.login-card .input {
  width: 100%;
  min-width: 0;
}
.login-card .btn-primary {
  width: 100%;
  padding: 12px;
  margin-top: 8px;
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state svg {
  width: 48px;
  height: 48px;
  opacity: 0.4;
  margin-bottom: 12px;
}

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-overlay.is-open {
  display: flex;
}
.modal {
  background: var(--surface);
  border-radius: 12px;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-md);
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-body {
  padding: 20px;
}
.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 199;
}
.sidebar-backdrop.is-visible {
  display: block;
}

.hide-mobile {
  display: none;
}
@media (min-width: 901px) {
  .hide-mobile {
    display: inline;
  }
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.is-open {
    transform: translateX(0);
  }
  .main-wrap {
    margin-left: 0;
  }
  .menu-toggle {
    display: flex;
  }
  .search-wrap {
    display: none;
  }
}
