/* ═══════════════════════════════════════════════════════
   SMEKERP — Warm Slate & Amber Palette | Original Layout
   ═══════════════════════════════════════════════════════ */

:root {
  /* Sidebar dimensions */
  --sb-w:    200px;
  --sb-slim:  60px;
  --ease: cubic-bezier(.4,0,.2,1);

  /* ── Brand palette ── */
  --slate-deep:    #1e2a3a;
  --slate-mid:     #2c3e55;
  --slate-soft:    #3d5269;
  --amber:         #c87941;
  --amber-light:   #d9935e;
  --amber-soft:    #e8c68a;

  /* ── Surface & border ── */
  --surface:       #ffffff;
  --surface-alt:   #f7f5f2;
  --border:        #e8e4de;
  --border-light:  #f0ede8;

  /* ── Ink (text) ── */
  --ink:           #1a1f2e;
  --ink-mid:       #374151;
  --ink-light:     #6b7280;
  --ink-xlight:    #9ca3af;

  /* ── Semantic colors ── */
  --success:       #2e7d5e;
  --success-bg:    #edfaf4;
  --success-border:#b7e8d5;

  --warning:       #92400e;
  --warning-fg:    #c87941;
  --warning-bg:    #fffbeb;
  --warning-border:#fde68a;

  --danger:        #991b1b;
  --danger-bg:     #fef2f2;
  --danger-border: #fecaca;

  --info:          #3d5269;
  --info-bg:       #eef2f7;
  --info-border:   #bfcfde;

  --purple:        #5b21b6;
  --purple-bg:     #f5f3ff;
  --purple-border: #ddd6fe;

  /* ── Button tokens — EDIT HERE TO RESTYLE ALL BUTTONS ── */
  --btn-radius:      30px;
  --btn-font-size:   12.5px;
  --btn-font-weight: 500;
  --btn-padding:     8px 20px;
  --btn-transition:  all .18s ease;

  /* Primary (amber/brand) */
  --btn-primary-bg:      #c87941;
  --btn-primary-color:   #ffffff;
  --btn-primary-border:  transparent;
  --btn-primary-hover-bg: #b56a35;

  /* Default / light */
  --btn-default-bg:      #f1f5f9;
  --btn-default-color:   #475569;
  --btn-default-border:  #e2e8f0;
  --btn-default-hover-bg: #e2e8f0;

  /* Ghost (white outline) */
  --btn-ghost-bg:      #ffffff;
  --btn-ghost-color:   #6b7280;
  --btn-ghost-border:  #e8e4de;
  --btn-ghost-hover-bg: #f7f5f2;

  /* Success */
  --btn-success-bg:      #edfaf4;
  --btn-success-color:   #2e7d5e;
  --btn-success-border:  transparent;
  --btn-success-hover-bg: #d4f5e7;

  /* Danger */
  --btn-danger-bg:       #fef2f2;
  --btn-danger-color:    #991b1b;
  --btn-danger-border:   transparent;
  --btn-danger-hover-bg: #fde8e8;

  /* Warning */
  --btn-warning-bg:      #fffbeb;
  --btn-warning-color:   #c87941;
  --btn-warning-border:  transparent;
  --btn-warning-hover-bg: #fef3c7;

  /* Dark (slate) */
  --btn-dark-bg:         #1e2a3a;
  --btn-dark-color:      #ffffff;
  --btn-dark-border:     transparent;
  --btn-dark-hover-bg:   #2c3e55;

  /* ── Badge tokens — EDIT HERE TO RESTYLE ALL BADGES ── */
  --badge-radius:     20px;
  --badge-font-size:  10px;
  --badge-font-weight: 700;
  --badge-padding:    3px 10px;

  /* Badge variants */
  --badge-green-bg:    #edfaf4;
  --badge-green-color: #2e7d5e;

  --badge-red-bg:      #fef2f2;
  --badge-red-color:   #991b1b;

  --badge-yellow-bg:   #fffbeb;
  --badge-yellow-color: #c87941;

  --badge-blue-bg:     #eef2f7;
  --badge-blue-color:  #3d5269;

  --badge-purple-bg:   #f5f3ff;
  --badge-purple-color: #5b21b6;

  --badge-gray-bg:     #f1f5f9;
  --badge-gray-color:  #475569;

  /* ── Card tokens ── */
  --card-radius:   14px;
  --card-padding:  20px;
  --card-border:   1px solid var(--border-light);
  --card-bg:       #ffffff;
  --card-shadow:   var(--shadow-sm);

  /* ── Input tokens ── */
  --input-radius:    8px;
  --input-padding:   9px 13px;
  --input-font-size: 13px;
  --input-border:    1px solid var(--border);
  --input-bg:        #ffffff;
  --input-focus-shadow: 0 0 0 3px rgba(200,121,65,.12);
  --input-focus-border: var(--amber);

  /* ── Shadows ── */
  --shadow-sm:     0 1px 3px rgba(0,0,0,.05), 0 1px 2px rgba(0,0,0,.03);
  --shadow:        0 4px 16px rgba(0,0,0,.08);
  --shadow-lg:     0 8px 32px rgba(0,0,0,.12);

  /* ── Border radius ── */
  --radius:        12px;
  --radius-sm:     8px;
  --radius-lg:     16px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  background: var(--surface-alt);
  color: var(--ink);
}

body { display: flex; gap: 10px; }

/* ════════════════════════════════════════════════════════
   BUTTONS  — use .btn + modifier
   ════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: var(--btn-padding);
  border-radius: var(--btn-radius);
  font-family: inherit;
  font-size: var(--btn-font-size);
  font-weight: var(--btn-font-weight);
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  transition: var(--btn-transition);
  white-space: nowrap;
  user-select: none;
}
.btn:disabled, .btn[disabled] { opacity: .5; pointer-events: none; }
.btn i { font-size: .9em; }

/* Full-width helper */
.btn-block { width: 100%; }

/* Size variants */
.btn-sm { padding: 5px 14px; font-size: 11.5px; }
.btn-lg { padding: 10px 26px; font-size: 13.5px; }

/* ── Colour variants ── */
.btn-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-color);
  border-color: var(--btn-primary-border);
}
.btn-primary:hover { background: var(--btn-primary-hover-bg); color: var(--btn-primary-color); }

.btn-default {
  background: var(--btn-default-bg);
  color: var(--btn-default-color);
  border-color: var(--btn-default-border);
}
.btn-default:hover { background: var(--btn-default-hover-bg); }

.btn-ghost {
  background: var(--btn-ghost-bg);
  color: var(--btn-ghost-color);
  border-color: var(--btn-ghost-border);
}
.btn-ghost:hover { background: var(--btn-ghost-hover-bg); }

.btn-success {
  background: var(--btn-success-bg);
  color: var(--btn-success-color);
  border-color: var(--btn-success-border);
}
.btn-success:hover { background: var(--btn-success-hover-bg); }

.btn-danger {
  background: var(--btn-danger-bg);
  color: var(--btn-danger-color);
  border-color: var(--btn-danger-border);
}
.btn-danger:hover { background: var(--btn-danger-hover-bg); }

.btn-warning {
  background: var(--btn-warning-bg);
  color: var(--btn-warning-color);
  border-color: var(--btn-warning-border);
}
.btn-warning:hover { background: var(--btn-warning-hover-bg); }

.btn-dark {
  background: var(--btn-dark-bg);
  color: var(--btn-dark-color);
  border-color: var(--btn-dark-border);
}
.btn-dark:hover { background: var(--btn-dark-hover-bg); }

/* ── Link-style button ── */
.btn-link {
  background: none;
  border-color: transparent;
  color: var(--amber);
  padding-left: 0; padding-right: 0;
}
.btn-link:hover { color: var(--btn-primary-hover-bg); background: none; }

/* ════════════════════════════════════════════════════════
   BADGES  — use .badge + modifier
   ════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: var(--badge-padding);
  border-radius: var(--badge-radius);
  font-size: var(--badge-font-size);
  font-weight: var(--badge-font-weight);
  line-height: 1;
  white-space: nowrap;
  font-family: inherit;
}

.badge-green  { background: var(--badge-green-bg);  color: var(--badge-green-color); }
.badge-red    { background: var(--badge-red-bg);    color: var(--badge-red-color); }
.badge-yellow { background: var(--badge-yellow-bg); color: var(--badge-yellow-color); }
.badge-blue   { background: var(--badge-blue-bg);   color: var(--badge-blue-color); }
.badge-purple { background: var(--badge-purple-bg); color: var(--badge-purple-color); }
.badge-gray   { background: var(--badge-gray-bg);   color: var(--badge-gray-color); }

/* Mono variant (audit log action badges) */
.badge-mono {
  font-family: monospace;
  font-size: 9px;
  padding: 2px 8px;
}

/* ════════════════════════════════════════════════════════
   CARDS
   ════════════════════════════════════════════════════════ */
.card {
  background: var(--card-bg);
  border: var(--card-border);
  border-radius: var(--card-radius);
  padding: var(--card-padding);
  box-shadow: var(--card-shadow);
}

.card-header {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.card-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
}

.card-header-title i { font-size: 13px; color: var(--amber); }

.card-body { padding: var(--card-padding); }

/* ════════════════════════════════════════════════════════
   SECTION TITLE (uppercase label above sections)
   ════════════════════════════════════════════════════════ */
.section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--ink-xlight);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.section-title i { color: var(--amber); }

/* ════════════════════════════════════════════════════════
   FORM INPUTS  — all fields get consistent look
   ════════════════════════════════════════════════════════ */
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: var(--input-padding);
  border: var(--input-border);
  border-radius: var(--input-radius);
  background: var(--input-bg);
  font-family: inherit;
  font-size: var(--input-font-size);
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--input-focus-border);
  box-shadow: var(--input-focus-shadow);
}
.form-input::placeholder,
.form-select::placeholder,
.form-textarea::placeholder { color: var(--ink-xlight); }

.form-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ink-light);
  margin-bottom: 5px;
}

.form-group { margin-bottom: 18px; }

/* ════════════════════════════════════════════════════════
   TABLES
   ════════════════════════════════════════════════════════ */
.table-wrap {
  background: var(--surface);
  border-radius: var(--card-radius);
  border: var(--card-border);
  overflow: hidden;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table thead tr {
  border-bottom: 1px solid var(--border-light);
}

.table thead th {
  text-align: left;
  padding: 13px 18px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-xlight);
  white-space: nowrap;
}

.table thead th.center { text-align: center; }

.table tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background .12s;
}

.table tbody tr:last-child { border-bottom: none; }
.table tbody tr:hover { background: #faf9f7; }

.table tbody td {
  padding: 12px 18px;
  font-size: 12.5px;
  color: var(--ink-mid);
  vertical-align: middle;
}

.table tbody td.center { text-align: center; }

/* ════════════════════════════════════════════════════════
   BREADCRUMBS
   ════════════════════════════════════════════════════════ */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--ink-xlight);
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.breadcrumb a {
  color: var(--ink-xlight);
  text-decoration: none;
  transition: color .12s;
}
.breadcrumb a:hover { color: var(--amber); }
.breadcrumb .sep { font-size: 10px; color: var(--border); }
.breadcrumb .current { color: var(--ink-mid); font-weight: 500; }

/* ════════════════════════════════════════════════════════
   PAGE HEADER (title + subtitle block)
   ════════════════════════════════════════════════════════ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.page-header-left h1 {
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -.3px;
  line-height: 1.2;
}

.page-header-left p {
  font-size: 13px;
  color: var(--ink-light);
  margin-top: 4px;
}

/* ════════════════════════════════════════════════════════
   FILTER BAR
   ════════════════════════════════════════════════════════ */
.filter-bar {
  background: var(--surface);
  border: var(--card-border);
  border-radius: var(--radius);
  padding: 15px 20px;
  margin-bottom: 20px;
}

.filter-bar form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

/* ════════════════════════════════════════════════════════
   STAT CARD
   ════════════════════════════════════════════════════════ */
.stat-card {
  background: var(--surface);
  border: var(--card-border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}

/* Stat icon colour helpers */
.stat-icon-blue   { background: var(--info-bg);    color: var(--info); }
.stat-icon-green  { background: var(--success-bg); color: var(--success); }
.stat-icon-amber  { background: var(--warning-bg); color: var(--warning-fg); }
.stat-icon-red    { background: var(--danger-bg);  color: var(--danger); }
.stat-icon-purple { background: var(--purple-bg);  color: var(--purple); }

.stat-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--ink);
  font-family: monospace;
  line-height: 1;
}
.stat-label {
  font-size: 11px;
  color: var(--ink-light);
  margin-top: 2px;
}

/* ════════════════════════════════════════════════════════
   INFO / DETAIL ROWS (key–value pairs)
   ════════════════════════════════════════════════════════ */
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 12px;
}
.detail-row:last-child { border-bottom: none; }
.detail-row .key { color: var(--ink-light); }
.detail-row .val { color: var(--ink); font-weight: 500; }

/* ════════════════════════════════════════════════════════
   PERMISSION GROUP (role form)
   ════════════════════════════════════════════════════════ */
.perm-group {
  background: var(--surface-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 13px;
  margin-bottom: 10px;
}
.perm-group h4 {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.perm-group h4 i { color: var(--amber); font-size: 11px; }

.perm-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-right: 14px;
  margin-bottom: 7px;
  font-size: 12px;
  cursor: pointer;
}
.perm-checkbox input[type="checkbox"] { cursor: pointer; accent-color: var(--amber); }

/* ════════════════════════════════════════════════════════
   QUICK NAV PILLS (admin panel)
   ════════════════════════════════════════════════════════ */
.nav-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
}
.nav-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 16px;
  border-radius: 30px;
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  transition: all .18s;
  background: var(--surface-alt);
  color: var(--ink-light);
  border: 1px solid var(--border);
}
.nav-pill:hover {
  background: var(--info-bg);
  color: var(--info);
  border-color: var(--info-border);
}
.nav-pill.active {
  background: var(--info-bg);
  color: var(--info);
  border-color: var(--info-border);
  font-weight: 600;
}
.nav-pill i { font-size: 11px; }

/* ════════════════════════════════════════════════════════
   PAGINATION
   ════════════════════════════════════════════════════════ */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 22px;
}
.pagination a,
.pagination span {
  padding: 7px 14px;
  border-radius: 30px;
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  transition: all .15s;
}
.pagination a {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink);
}
.pagination a:hover {
  border-color: var(--amber);
  color: var(--amber);
}
.pagination span {
  background: var(--surface-alt);
  color: var(--ink-mid);
  border: 1px solid var(--border);
}

/* ════════════════════════════════════════════════════════
   SIDEBAR (Warm Slate)
   ════════════════════════════════════════════════════════ */
#sb {
  width: var(--sb-w);
  height: calc(100vh - 20px);
  margin: 10px 0 10px 10px;
  border-radius: 20px;
  background: linear-gradient(180deg, var(--slate-deep) 0%, var(--slate-mid) 100%);
  box-shadow: 0 4px 24px rgba(0,0,0,.15);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: width .28s var(--ease), border-radius .28s var(--ease);
  z-index: 50;
  position: relative;
}

body.slim #sb {
  width: var(--sb-slim);
  border-radius: 28px;
}

body.slim .hide-slim,
body.slim .sub,
body.slim .sb-orgtext { display: none !important; }

body.slim .logo {
  justify-content: center;
  padding: 16px 0;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

body.slim .sb-nav { padding: 12px 8px; }

body.slim .n {
  justify-content: center;
  padding: 10px 0;
  gap: 0;
  border-radius: 12px;
}

body.slim .n i { color: rgba(255,255,255,.6); margin: 0; font-size: 18px; width: auto; }
body.slim .n:hover { background: rgba(255,255,255,.1); }
body.slim .n:hover i { color: var(--amber-light); }

body.slim a.n.on {
  background: rgba(232,124,26,.2);
  border-left: none;
}
body.slim a.n.on i { color: var(--amber); }

body.slim .sb-foot {
  justify-content: center;
  padding: 16px 0;
  border-top: 1px solid rgba(255,255,255,.08);
}
body.slim .sec-lbl { display: none; }

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  text-decoration: none;
  flex-shrink: 0;
  overflow: hidden;
}

.logo-img {
  height: 36px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.logo-img-sm {
  height: 32px;
  width: 32px;
  object-fit: contain;
  border-radius: 8px;
  display: none;
  flex-shrink: 0;
  filter: brightness(0) invert(1);
}

body.slim .logo-img { display: none; }
body.slim .logo-img-sm { display: block; }

.sb-orgtext b {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}
.sb-orgtext small {
  font-size: 9px;
  font-weight: 600;
  color: var(--amber-light);
  letter-spacing: .06em;
  text-transform: uppercase;
}

/* Navigation */
.sb-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.2) transparent;
}

.sec-lbl {
  display: block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: rgba(255,255,255,.4);
  padding: 12px 8px 6px;
  white-space: nowrap;
}

a.n, span.n {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,.7);
  text-decoration: none;
  transition: all .15s ease;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
  cursor: pointer;
}

a.n:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
}

a.n.on {
  background: rgba(232,124,26,.15);
  color: var(--amber-light);
  font-weight: 600;
}

a.n.on::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  height: 60%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--amber);
}

.n i {
  width: 18px;
  text-align: center;
  font-size: 15px;
  flex-shrink: 0;
  color: rgba(255,255,255,.5);
}

a.n:hover i { color: var(--amber-light); }
a.n.on i { color: var(--amber); }

a.n.admin-link { color: rgba(255,255,255,.7); }
a.n.admin-link i { color: rgba(255,255,255,.5); }
a.n.admin-link:hover { background: rgba(232,124,26,.15); color: var(--amber-light); }
a.n.admin-link:hover i { color: var(--amber-light); }
a.n.admin-link.on {
  background: rgba(232,124,26,.2);
  color: var(--amber);
  font-weight: 600;
}
a.n.admin-link.on::before { background: var(--amber); }
body.slim a.n.admin-link.on { background: rgba(232,124,26,.25); }
body.slim a.n.admin-link.on i { color: var(--amber); }

/* Sidebar footer */
.sb-foot {
  border-top: 1px solid rgba(255,255,255,.08);
  padding: 14px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  overflow: hidden;
}

.u-info { flex: 1; min-width: 0; }
.u-info b {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.u-info small { font-size: 10px; color: rgba(255,255,255,.5); }

.sb-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: rgba(255,255,255,.5);
  text-decoration: none;
  transition: all .12s;
  flex-shrink: 0;
}
.sb-logout:hover { background: rgba(220,38,38,.2); color: #f87171; }

/* Avatars */
.av-circle, .av-circle-sm {
  border-radius: 50%;
  background: linear-gradient(135deg, var(--amber), var(--slate-soft));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  vertical-align: middle;
  overflow: hidden;
}
.av-circle { width: 36px; height: 36px; }
.av-circle-sm { width: 32px; height: 32px; }
.av-circle i, .av-circle-sm i { color: #fff; font-size: 14px; }
.av-circle img, .av-circle-sm img {
  width: 100%; height: 100%;
  object-fit: cover;
}

/* ════════════════════════════════════════════════════════
   MAIN AREA
   ════════════════════════════════════════════════════════ */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  min-width: 0;
}

#bar {
  height: 58px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  flex-shrink: 0;
  border-bottom-left-radius: 20px;
  border-bottom-right-radius: 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,.04);
}

.toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--slate-mid);
  cursor: pointer;
  flex-shrink: 0;
  transition: all .2s ease;
}
.toggle-btn:hover { background: var(--border-light); border-color: var(--amber); color: var(--amber); }
.toggle-btn i { font-size: 14px; transition: transform .28s var(--ease); }
body.slim .toggle-btn i { transform: rotate(180deg); }

.bar-title {
  flex: 1;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -.2px;
}

/* Search */
.srch { position: relative; flex-shrink: 0; }
.srch input {
  width: 220px;
  height: 36px;
  padding: 0 12px 0 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  font-family: inherit;
  font-size: 12.5px;
  color: var(--ink);
  outline: none;
  transition: all .15s;
}
.srch input:focus {
  border-color: var(--amber);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(200,121,65,.1);
}
.srch input::placeholder { color: var(--ink-xlight); }
.srch i {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--ink-xlight);
  font-size: 12px;
  pointer-events: none;
}

/* User pill */
.upill-wrap { position: relative; }
.upill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border: none;
  border-left: 1px solid var(--border);
  background: none;
  cursor: pointer;
  font-family: inherit;
  border-radius: 10px;
  transition: background .12s;
}
.upill:hover { background: var(--surface-alt); }

.up-meta { text-align: right; line-height: 1.3; }
.up-meta .u-name { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink); }
.up-meta .u-emp  { display: block; font-size: 10px; color: var(--ink-light); }

.up-chev { font-size: 11px; color: var(--ink-xlight); transition: transform .18s; }
.upill[aria-expanded=true] .up-chev { transform: rotate(180deg); }

/* Dropdown */
.dd {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0,0,0,.12), 0 0 0 1px var(--border);
  min-width: 200px;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-5px);
  transition: all .15s var(--ease);
  z-index: 100;
}
.dd.open { opacity: 1; visibility: visible; transform: translateY(0); }
.dd-head { padding: 12px 16px; border-bottom: 1px solid var(--border-light); }
.dd-head b { display: block; font-size: 13px; font-weight: 700; color: var(--ink); }
.dd-head small { font-size: 10.5px; color: var(--ink-light); }

.dd a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 12.5px;
  color: var(--ink-mid);
  text-decoration: none;
  transition: background .1s;
}
.dd a:hover { background: var(--surface-alt); }
.dd a i { width: 16px; font-size: 13px; color: var(--ink-light); }
.dd a.red { color: var(--danger); }
.dd a.red i { color: var(--danger); }
.dd a.red:hover { background: var(--danger-bg); }
.dd hr { border: none; border-top: 1px solid var(--border-light); margin: 4px 0; }

/* Page content */
#pg {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

#ft {
  padding: 10px 24px;
  font-size: 11px;
  color: var(--ink-xlight);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}

/* ════════════════════════════════════════════════════════
   FLASH MESSAGES
   ════════════════════════════════════════════════════════ */
#flash-container {
  position: fixed;
  top: 70px; right: 20px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}
.flash-msg {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: flashIn .25s ease both;
}
@keyframes flashIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
.flash-msg.success { border-left: 3px solid var(--success); background: var(--success-bg); color: var(--success); }
.flash-msg.danger  { border-left: 3px solid var(--danger);  background: var(--danger-bg);  color: var(--danger); }
.flash-msg.warning { border-left: 3px solid var(--warning); background: var(--warning-bg); color: var(--warning); }
.flash-msg.info    { border-left: 3px solid var(--amber);   background: #fff8f0;            color: var(--slate-mid); }

.flash-close {
  background: none; border: none;
  font-size: 16px; color: var(--ink-xlight);
  cursor: pointer; line-height: 1; padding: 0; flex-shrink: 0;
}
.flash-close:hover { color: var(--ink); }

/* Mobile overlay */
#ov {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  backdrop-filter: blur(2px);
  z-index: 40;
}
#ov.on { display: block; }

/* ════════════════════════════════════════════════════════
   MOBILE RESPONSIVE
   ════════════════════════════════════════════════════════ */
@media (max-width: 820px) {
  #sb {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    height: 100vh;
    margin: 0;
    border-radius: 0;
    width: var(--sb-w) !important;
    transform: translateX(-100%);
    transition: transform .28s var(--ease);
  }
  #sb.on { transform: translateX(0); }
  body.slim #sb { width: var(--sb-w) !important; }
  .toggle-btn.desktop-only { display: none; }
  .srch, .up-meta { display: none; }
}

.min-h-screen { min-height: 100vh; }

/* ════════════════════════════════════════════════════════
   SUB-NAV  — child links under a parent nav item
   ════════════════════════════════════════════════════════ */
.sub {
  list-style: none;
  padding: 2px 0 6px 32px;
  position: relative;
}

.sub::before {
  content: '';
  position: absolute;
  left: 20px;
  top: 0;
  bottom: 8px;
  width: 1px;
  background: rgba(255,255,255,.1);
}

.sub li {
  position: relative;
}

.sub li::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 50%;
  width: 8px;
  height: 1px;
  background: rgba(255,255,255,.1);
}

.sub a.n {
  font-size: 12px;
  font-weight: 400;
  color: rgba(255,255,255,.55);
  padding: 6px 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sub a.n:hover {
  color: #fff;
  background: rgba(255,255,255,.06);
}

.sub a.n.on {
  color: var(--amber-light);
  background: rgba(200,121,65,.08);
  font-weight: 500;
}

.sub a.n.on::before { display: none; }

/* ═══════════════════════════════════════════════
   MODAL — overlay + box
   ═══════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(26, 31, 46, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: modalFadeIn .18s ease both;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-box {
  background: var(--surface);
  border-radius: 16px;
  box-shadow:
    0 0 0 1px rgba(0,0,0,.08),
    0 24px 64px rgba(0,0,0,.22);
  width: 100%;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 24px;
  animation: modalSlideUp .2s cubic-bezier(.16,1,.3,1) both;
}

@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(18px) scale(.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1);   }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-light);
}

.modal-header h3 {
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
  margin: 0;
}

.modal-close {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--ink-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: all .15s ease;
  flex-shrink: 0;
}

.modal-close:hover {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger);
}

/* Close on overlay click */
.modal-overlay > .modal-box {
  pointer-events: all;
}

/* ════════════════════════════════════════════════════════
   INVENTORY MODULE — COMPREHENSIVE MOBILE RESPONSIVENESS
   Covers all inline grids, tables, and layout patterns
   across dashboard, detail, form, and list templates.
   ════════════════════════════════════════════════════════ */

/* ── Shared: make all inline-style grids stack on mobile ── */
@media (max-width: 768px) {

  /* ── Page padding ── */
  #pg {
    padding: 14px 14px;
  }

  /* ── Page header: stack title + actions ── */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .page-header > div:last-child,
  .page-header > a:last-child {
    width: 100%;
  }

  .page-header > div[style*="display:flex"],
  .page-header > div[style*="display: flex"] {
    flex-wrap: wrap;
    width: 100%;
  }

  .page-header .btn {
    flex: 1;
    justify-content: center;
    min-width: 0;
  }

  /* ── Breadcrumbs: smaller on mobile ── */
  .breadcrumb {
    font-size: 11px;
    margin-bottom: 14px;
  }

  /* ── Cards: reduce padding ── */
  .card {
    padding: 14px;
  }

  .card-header {
    padding: 11px 14px;
  }

  /* ── Tables: horizontal scroll ── */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table {
    min-width: 560px;
  }

  .table thead th,
  .table tbody td {
    padding: 10px 12px;
  }

  /* ── Filter forms: stack vertically ── */
  form[method="GET"] {
    flex-direction: column;
    align-items: stretch;
  }

  form[method="GET"] .form-input,
  form[method="GET"] .form-select,
  form[method="GET"] select,
  form[method="GET"] input {
    width: 100% !important;
    margin-bottom: 0;
  }

  form[method="GET"] .btn {
    width: 100%;
    justify-content: center;
  }

  /* ── Stat grid: 2 columns on tablet, 1 on small ── */
  .stat-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

  /* ── Two-col-grid: single column ── */
  .two-col-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  /* ── Settings layout (categories, UoM): single column ── */
  .settings-layout {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  /* ── Quick links: wrap nicely ── */
  .quick-links-grid {
    gap: 8px;
  }

  .quick-link {
    flex: 1;
    min-width: calc(50% - 4px);
    justify-content: center;
  }

  /* ── Flash messages: full width ── */
  #flash-container {
    left: 12px;
    right: 12px;
    max-width: none;
  }

  /* ── Modal box: full-width on mobile ── */
  .modal-box {
    width: 95vw !important;
    padding: 20px 16px;
  }

  /* ── Forms inside cards: single column ── */
  .card form > div[style*="grid-template-columns"],
  .card > form > div[style*="grid"] {
    grid-template-columns: 1fr !important;
  }

  /* ── Inline KPI strip on detail pages ── */
  div[style*="grid-template-columns:repeat(auto-fit,minmax(150px"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

  /* ── Detail page 2fr/1fr split ── */
  div[style*="grid-template-columns:2fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  /* ── GRN scan: stack columns ── */
  div[style*="grid-template-columns:1fr 1fr;gap:20px;align-items:start"] {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  /* ── Barcode panel: button row ── */
  #barcode-panel div[style*="display:flex;gap:6px"] {
    flex-wrap: wrap;
  }

  #barcode-panel .btn {
    flex: 1;
    min-width: 120px;
    justify-content: center;
  }

  /* ── Form action rows (Save + Cancel) ── */
  div[style*="display:flex;gap:10px;margin-top"] {
    flex-wrap: wrap;
  }

  div[style*="display:flex;gap:10px;margin-top"] .btn {
    flex: 1;
    justify-content: center;
    min-width: 120px;
  }

  /* ── Stock count detail: input fields ── */
  .table input[type="number"],
  .table input[type="text"] {
    width: 90px !important;
  }

  /* ── Pagination ── */
  .pagination,
  div[style*="display:flex;justify-content:center;gap:6px;margin-top:18px"] {
    flex-wrap: wrap;
    gap: 4px !important;
  }
}

/* ── Extra small: phones < 480px ── */
@media (max-width: 480px) {

  #pg {
    padding: 10px 10px;
  }

  /* ── Stat grid: single column ── */
  .stat-grid {
    grid-template-columns: 1fr !important;
  }

  /* ── KPI cards on detail page: single col ── */
  div[style*="grid-template-columns:repeat(auto-fit,minmax(150px"] {
    grid-template-columns: 1fr !important;
  }

  /* ── Quick links: single column ── */
  .quick-link {
    min-width: 100%;
  }

  /* ── Page header h1: smaller ── */
  .page-header-left h1 {
    font-size: 18px;
  }

  /* ── Barcode label sheet: full width ── */
  #label-sheet-wrap .label-card {
    width: 100% !important;
    max-width: 280px;
    margin: 0 auto;
  }

  /* ── Finished product form grid ── */
  div[style*="grid-template-columns:1fr 1fr;gap:16px"] {
    grid-template-columns: 1fr !important;
  }

  /* ── Tag metadata grid in barcode panel ── */
  div[style*="grid-template-columns:1fr 1fr;gap:6px;margin-bottom:12px"] {
    grid-template-columns: 1fr !important;
  }

  /* ── Card stat values: slightly smaller ── */
  .stat-value {
    font-size: 22px;
  }
}

/* ── Tablet range 769–1024px: moderate adjustments ── */
@media (min-width: 769px) and (max-width: 1024px) {

  /* ── Stat grid: 3 columns ── */
  .stat-grid {
    grid-template-columns: repeat(3, 1fr) !important;
  }

  /* ── Settings layout: compressed ── */
  .settings-layout {
    grid-template-columns: 260px 1fr !important;
  }
}

/* ── Table responsive wrapper utility ── */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
  .table-responsive .table {
    min-width: 500px;
  }
}


/* ════════════════════════════════════════════════════════
   CLASS-BASED RESPONSIVE HELPERS
   Added to template containers for reliable breakpoints
   ════════════════════════════════════════════════════════ */

/* ── KPI strip: detail page top metrics ── */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

/* ── Detail page main content / sidebar split ── */
.detail-split {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

/* ── GRN scan: camera + log split ── */
.grn-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

/* ── 2-column form grid ── */
.form-grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ── Filter form row ── */
.filter-form-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  align-items: flex-end;
}

@media (max-width: 768px) {

  .kpi-strip {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

  .detail-split {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  .grn-split {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  .form-grid-2col {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .filter-form-row {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-form-row .form-input,
  .filter-form-row select,
  .filter-form-row input[type="text"],
  .filter-form-row input[type="date"] {
    width: 100% !important;
  }

  .filter-form-row .btn {
    width: 100%;
    justify-content: center;
  }

  /* ── Barcode label copies + container ── */
  #label-sheet-wrap > div[style*="width:100%"] {
    flex-direction: column;
  }

  /* ── Stock count detail: input shrink ── */
  .table-wrap input[type="number"],
  .table-wrap input[type="text"] {
    width: 80px !important;
    padding: 4px 6px;
  }

  /* ── Page header action buttons ── */
  .page-header > div[style] > .btn,
  .page-header > div > a.btn {
    flex: 1;
    min-width: 120px;
    justify-content: center;
  }

  /* ── Inline action button rows ── */
  div[style*="display:flex;gap:8px"] > .btn,
  div[style*="display:flex;gap:6px"] > .btn {
    flex: 1;
    min-width: 100px;
    justify-content: center;
  }

  /* ── GRN receive inner grid ── */
  #receive-fields > div.form-grid-2col {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 480px) {

  .kpi-strip {
    grid-template-columns: 1fr !important;
  }

  .form-grid-2col {
    grid-template-columns: 1fr !important;
  }

  /* ── Stat values on mobile ── */
  .kpi-strip .card > div:first-child {
    font-size: 24px !important;
  }

  /* ── Barcode label: full width ── */
  .label-card {
    width: 100% !important;
    max-width: 300px;
    margin: 0 auto;
  }

  /* ── Table: even more compact ── */
  .table thead th,
  .table tbody td {
    padding: 8px 10px;
    font-size: 11.5px;
  }
}

/* ── Print: keep label layout regardless of screen size ── */
@media print {
  .kpi-strip,
  .detail-split,
  .grn-split,
  .form-grid-2col {
    /* restored by print-specific styles in barcode_label.html */
  }
}

/* ── Result KPI mini grids (barcode scanner) ── */
.result-kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

@media (max-width: 400px) {
  .result-kpi-grid {
    grid-template-columns: 1fr !important;
  }
}
