/* ─── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --c-bg:       #f4f6f9;
  --c-surface:  #ffffff;
  --c-border:   #d1d5db;
  --c-text:     #111827;
  --c-muted:    #6b7280;
  --c-primary:  #2563eb;
  --c-primary-h:#1d4ed8;
  --c-danger:   #dc2626;
  --c-warn:     #d97706;
  --c-success:  #16a34a;
  --c-green:    #dcfce7;
  --c-red:      #fee2e2;
  --c-yellow:   #fef9c3;
  --c-orange:   #ffedd5;
  --c-gray:     #f3f4f6;
  --c-dark:     #374151;
  --radius:     6px;
  --shadow:     0 1px 3px rgba(0,0,0,.1);
}

html { font-size: 15px; }
body { font-family: system-ui, -apple-system, sans-serif; background: var(--c-bg); color: var(--c-text); line-height: 1.5; }
a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Layout ────────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--c-text);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .6rem 1.25rem;
  flex-wrap: wrap;
}
.site-brand { color: #fff; font-weight: 700; font-size: 1.1rem; white-space: nowrap; }
.site-nav { display: flex; gap: .75rem; flex: 1; flex-wrap: wrap; }
.site-nav a { color: #d1d5db; font-size: .875rem; }
.site-nav a:hover { color: #fff; text-decoration: none; }
.site-user { display: flex; align-items: center; gap: .5rem; font-size: .8rem; color: #d1d5db; white-space: nowrap; }
.site-user a { color: #d1d5db; }
.site-user a:hover { color: #fff; }
.role-badge { background: #374151; padding: .1rem .4rem; border-radius: 999px; font-size: .7rem; }

.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1rem; }
h1 { font-size: 1.5rem; margin-bottom: 1rem; }
h2 { font-size: 1.2rem; margin: 1.25rem 0 .75rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }

.site-footer { text-align: center; padding: 1.5rem; font-size: .8rem; color: var(--c-muted); border-top: 1px solid var(--c-border); margin-top: 2rem; }

/* ─── Card ──────────────────────────────────────────────────────────────────── */
.card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); margin-bottom: 1rem; }

/* ─── Alerts ────────────────────────────────────────────────────────────────── */
.alert { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .9rem; }
.alert-success { background: var(--c-green); color: #166534; border: 1px solid #bbf7d0; }
.alert-error   { background: var(--c-red);   color: #991b1b; border: 1px solid #fecaca; }
.alert-warn    { background: var(--c-yellow); color: #854d0e; border: 1px solid #fde047; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ─── Forms ─────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: .9rem; }
.form-group label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .25rem; color: var(--c-dark); }
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], input[type=search], select, textarea {
  width: 100%; padding: .45rem .65rem; border: 1px solid var(--c-border);
  border-radius: var(--radius); font-size: .9rem; background: #fff;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
textarea { min-height: 90px; resize: vertical; }
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 180px; }
.form-hint { font-size: .78rem; color: var(--c-muted); margin-top: .2rem; }
.required::after { content: ' *'; color: var(--c-danger); }

/* ─── Buttons ───────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: .35rem; padding: .45rem .9rem; border-radius: var(--radius); font-size: .875rem; font-weight: 500; cursor: pointer; border: 1px solid transparent; text-decoration: none; transition: background .15s, box-shadow .15s; }
.btn-primary   { background: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-h); text-decoration: none; color: #fff; }
.btn-secondary { background: #fff; color: var(--c-text); border-color: var(--c-border); }
.btn-secondary:hover { background: var(--c-gray); text-decoration: none; }
.btn-danger    { background: var(--c-danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; text-decoration: none; color: #fff; }
.btn-sm        { padding: .25rem .6rem; font-size: .8rem; }
.btn-group     { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }

/* ─── Tables ────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th, td { padding: .55rem .75rem; text-align: left; border-bottom: 1px solid var(--c-border); }
th { background: var(--c-gray); font-weight: 600; white-space: nowrap; }
tr:hover td { background: #f9fafb; }
.table-actions { white-space: nowrap; }

/* ─── Filters ───────────────────────────────────────────────────────────────── */
.filters { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.filters .form-group { margin-bottom: 0; }
.filters select, .filters input { min-width: 150px; }

/* ─── Badges ────────────────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: .15rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge-green  { background: var(--c-green);  color: #166534; }
.badge-red    { background: var(--c-red);    color: #991b1b; }
.badge-yellow { background: var(--c-yellow); color: #854d0e; }
.badge-orange { background: var(--c-orange); color: #9a3412; }
.badge-gray   { background: var(--c-gray);   color: var(--c-dark); }
.badge-dark   { background: #374151;          color: #f9fafb; }

/* ─── Tabs ──────────────────────────────────────────────────────────────────── */
.tabs { display: flex; border-bottom: 2px solid var(--c-border); margin-bottom: 1rem; gap: 0; }
.tab-link { padding: .5rem 1rem; font-size: .875rem; color: var(--c-muted); border-bottom: 2px solid transparent; margin-bottom: -2px; cursor: pointer; background: none; border-top: none; border-left: none; border-right: none; }
.tab-link.active { color: var(--c-primary); border-bottom-color: var(--c-primary); font-weight: 600; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─── Pagination ────────────────────────────────────────────────────────────── */
.pagination { display: flex; gap: .35rem; margin-top: 1rem; flex-wrap: wrap; }
.pagination a { padding: .3rem .65rem; border: 1px solid var(--c-border); border-radius: var(--radius); font-size: .8rem; color: var(--c-text); }
.pagination a:hover { background: var(--c-gray); text-decoration: none; }
.pagination a.active { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }

/* ─── Detail grid ───────────────────────────────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.detail-item label { font-size: .78rem; font-weight: 600; color: var(--c-muted); display: block; text-transform: uppercase; letter-spacing: .05em; }
.detail-item span  { font-size: .95rem; display: block; }

/* ─── Login ─────────────────────────────────────────────────────────────────── */
.login-wrap { max-width: 380px; margin: 4rem auto; }
.login-wrap h1 { text-align: center; margin-bottom: 1.5rem; }

/* ─── QR scan ───────────────────────────────────────────────────────────────── */
#reader { width: 100%; max-width: 400px; }

/* ─── Label preview ─────────────────────────────────────────────────────────── */
.label-preview { border: 1px solid var(--c-border); padding: 1rem; display: inline-block; min-width: 280px; }

/* ─── Stat cards ────────────────────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); padding: 1rem; text-align: center; }
.stat-card .stat-val { font-size: 2rem; font-weight: 700; color: var(--c-primary); }
.stat-card .stat-lbl { font-size: .8rem; color: var(--c-muted); margin-top: .2rem; }

/* ─── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .site-header { flex-direction: column; align-items: flex-start; }
  .form-row { flex-direction: column; }
  .filters { flex-direction: column; }
}
