/* ══════════════════════════════════════════════════════════════════
   GatsbyWears | App Stylesheet  (assets/css/app.css)
   Fonts: Cormorant Garamond · DM Sans · DM Mono
   ══════════════════════════════════════════════════════════════════ */

/* ── Design Tokens ────────────────────────────────────────────── */
:root {
  /* Surfaces */
  --bg:       #070709;
  --surface:  #0f0f16;
  --card:     #161622;
  --card2:    #1c1c2e;

  /* Borders */
  --border:   #2a2a40;
  --border2:  #1e1e30;

  /* Brand gold */
  --gold:     #c9a84c;
  --gold2:    #e8c97a;
  --gold-dim: rgba(201,168,76,0.10);
  --gold-dim2:rgba(201,168,76,0.18);

  /* Text */
  --text:     #f0ede8;
  --muted:    #7a7a96;
  --muted2:   #4a4a62;

  /* Semantic */
  --success:  #4cbe82;
  --danger:   #e05c5c;
  --warn:     #e0a44c;
  --info:     #5c9ce0;

  /* Layout */
  --sidebar:  240px;
  --radius:   12px;
  --radius-sm:8px;
  --radius-xs:5px;

  /* Transitions */
  --tr:       .18s ease;
}

/* ── Reset ────────────────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0; padding: 0; box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
/* Auth page needs scroll on small screens - toggled by JS */
body.auth-mode {
  overflow-y: auto;
  overflow-x: hidden;
}

#root {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Scrollbar */
::-webkit-scrollbar            { width: 4px; height: 4px; }
::-webkit-scrollbar-track      { background: transparent; }
::-webkit-scrollbar-thumb      { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover{ background: var(--muted2); }

/* Selection */
::selection { background: var(--gold-dim2); color: var(--gold2); }

/* ══════════════════════════════════════════════════════════════════
   AUTH
   ══════════════════════════════════════════════════════════════════ */
.auth-wrap {
  min-height: 100vh;
  min-height: 100dvh; /* dynamic viewport - handles mobile browser bars */
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  position: relative;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 20px 16px;
}

/* Decorative grid + radial glow */
.auth-bg {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 80% 60% at 50% -10%, rgba(201,168,76,.09), transparent 70%);
}
.auth-bg::after {
  content: '';
  position: absolute; inset: 0;
  background-image:
    repeating-linear-gradient(0deg,   transparent, transparent 40px, rgba(201,168,76,.018) 40px, rgba(201,168,76,.018) 41px),
    repeating-linear-gradient(90deg,  transparent, transparent 40px, rgba(201,168,76,.018) 40px, rgba(201,168,76,.018) 41px);
}

.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  position: relative;
  box-shadow: 0 40px 100px rgba(0,0,0,.65);
  z-index: 1;
  flex-shrink: 0;
}

/* Gold shimmer top edge */
.auth-card::before {
  content: '';
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 55%; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.auth-logo         { text-align: center; margin-bottom: 36px; }
.auth-logo-title   { font-family: 'Cormorant Garamond', serif; font-size: 30px; font-weight: 600; color: var(--gold2); letter-spacing: 4px; text-transform: uppercase; }
.auth-logo-sub     { font-size: 10px; letter-spacing: 4px; color: var(--muted); text-transform: uppercase; margin-top: 6px; }
.auth-divider      { width: 36px; height: 1px; background: var(--gold); margin: 14px auto; }

.auth-field        { margin-bottom: 16px; }
.auth-field label  { display: block; font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.auth-field input  {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color var(--tr), box-shadow var(--tr);
}
.auth-field input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201,168,76,.10);
}

.auth-role-toggle  { display: flex; gap: 8px; margin-bottom: 24px; }
.role-btn {
  flex: 1; padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 12px; letter-spacing: 1px; text-transform: uppercase;
  cursor: pointer; transition: all var(--tr);
}
.role-btn.active   { background: var(--gold-dim2); border-color: var(--gold); color: var(--gold2); }
.role-btn:hover:not(.active) { border-color: var(--muted2); color: var(--text); }

.auth-submit {
  width: 100%; padding: 14px;
  background: linear-gradient(135deg, var(--gold), #a8852e);
  border: none; border-radius: var(--radius-sm);
  color: #08060a;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px; font-weight: 600; letter-spacing: 2px; text-transform: uppercase;
  cursor: pointer; transition: opacity var(--tr), transform var(--tr);
  margin-top: 8px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.auth-submit:hover    { opacity: .9; }
.auth-submit:active   { transform: scale(.985); }
.auth-submit:disabled { opacity: .5; cursor: not-allowed; }

/* ══════════════════════════════════════════════════════════════════
   APP SHELL
   ══════════════════════════════════════════════════════════════════ */
.app-layout {
  display: flex;
  height: 100%;
  overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  flex-shrink: 0;
  position: relative; z-index: 10;
  transition: left .28s cubic-bezier(.4,0,.2,1);
}

/* Gold shimmer right edge */
.sidebar::after {
  content: ''; position: absolute; top: 0; right: 0; width: 1px; height: 100%;
  background: linear-gradient(180deg, transparent 0%, var(--gold) 50%, transparent 100%);
  opacity: .35;
}

.sidebar-logo      { padding: 22px 20px 18px; border-bottom: 1px solid var(--border); }
.sidebar-logo-title{ font-family: 'Cormorant Garamond', serif; font-size: 18px; font-weight: 600; color: var(--gold2); letter-spacing: 2.5px; text-transform: uppercase; }
.sidebar-logo-sub  { font-size: 9px; letter-spacing: 3px; color: var(--muted2); text-transform: uppercase; margin-top: 3px; }

.sidebar-nav          { flex: 1; padding: 14px 10px; overflow-y: auto; }
.nav-section          { margin-bottom: 20px; }
.nav-section-label    { font-size: 9px; letter-spacing: 3px; color: var(--muted2); text-transform: uppercase; padding: 0 8px; margin-bottom: 6px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  cursor: pointer; margin-bottom: 2px;
  color: var(--muted); font-size: 13px; font-weight: 500;
  border: 1px solid transparent;
  transition: all var(--tr);
  user-select: none;
}
.nav-item:hover        { background: var(--gold-dim); color: var(--gold2); }
.nav-item.active       { background: var(--gold-dim2); border-color: rgba(201,168,76,.22); color: var(--gold2); }
.nav-item-ico          { font-size: 15px; flex-shrink: 0; width: 18px; text-align: center; }
.nav-badge             { margin-left: auto; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 20px; min-width: 20px; text-align: center; }

.sidebar-user          { padding: 14px 16px; border-top: 1px solid var(--border); }
.sidebar-user-info     { display: flex; align-items: center; gap: 10px; }
.user-avatar           {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--gold-dim); border: 1px solid rgba(201,168,76,.3);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Cormorant Garamond', serif; font-size: 15px; font-weight: 600; color: var(--gold);
  flex-shrink: 0; overflow: hidden;
}
.user-avatar img       { width: 100%; height: 100%; object-fit: cover; }
.user-name             { font-size: 12px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100px; }
.user-role             { font-size: 10px; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; }
.logout-btn            { margin-left: auto; background: none; border: 1px solid transparent; color: var(--muted); cursor: pointer; padding: 5px 6px; border-radius: 6px; transition: all var(--tr); font-size: 16px; flex-shrink: 0; }
.logout-btn:hover      { border-color: var(--danger); color: var(--danger); background: rgba(224,92,92,.08); }

/* ── Main panel ───────────────────────────────────────────────── */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }

.topbar {
  padding: 14px 24px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); flex-shrink: 0;
}
.topbar-title { font-family: 'Cormorant Garamond', serif; font-size: 22px; font-weight: 500; color: var(--text); line-height: 1.2; }
.topbar-sub   { font-size: 11px; color: var(--muted); margin-top: 1px; }

.content      { flex: 1; overflow-y: auto; padding: 22px 24px; }

/* ── Mobile overlay ───────────────────────────────────────────── */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 9; backdrop-filter: blur(3px); }
.mob-toggle      { display: none; background: none; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 7px 9px; cursor: pointer; color: var(--text); font-size: 18px; line-height: 1; }

/* ══════════════════════════════════════════════════════════════════
   CARDS & METRICS
   ══════════════════════════════════════════════════════════════════ */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}

.metric-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 12px; margin-bottom: 18px; }

.metric-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  position: relative; overflow: hidden;
  transition: border-color var(--tr), transform var(--tr);
  cursor: default;
}
.metric-card:hover { border-color: rgba(201,168,76,.35); transform: translateY(-1px); }
.metric-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: linear-gradient(90deg, transparent, var(--gold), transparent); opacity: .5; }

.metric-label  { font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.metric-value  { font-family: 'Cormorant Garamond', serif; font-size: 30px; font-weight: 600; color: var(--gold2); line-height: 1; }
.metric-sub    { font-size: 11px; color: var(--muted); margin-top: 6px; }
.metric-icon   { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 24px; opacity: .09; pointer-events: none; }

/* ══════════════════════════════════════════════════════════════════
   BADGES
   ══════════════════════════════════════════════════════════════════ */
.badge         { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 500; white-space: nowrap; }
.badge-success { background: rgba(76,190,130,.12);  color: var(--success); border: 1px solid rgba(76,190,130,.22);  }
.badge-danger  { background: rgba(224,92,92,.12);   color: var(--danger);  border: 1px solid rgba(224,92,92,.22);  }
.badge-warn    { background: rgba(224,164,76,.12);  color: var(--warn);    border: 1px solid rgba(224,164,76,.22); }
.badge-info    { background: rgba(92,156,224,.12);  color: var(--info);    border: 1px solid rgba(92,156,224,.22); }
.badge-gold    { background: var(--gold-dim);       color: var(--gold2);   border: 1px solid rgba(201,168,76,.22); }
.badge-muted   { background: rgba(122,122,150,.10); color: var(--muted);   border: 1px solid rgba(122,122,150,.18);}

/* ══════════════════════════════════════════════════════════════════
   TABLES
   ══════════════════════════════════════════════════════════════════ */
.table-wrap   { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table         { width: 100%; border-collapse: collapse; }
thead tr      { background: var(--card2); border-bottom: 1px solid var(--border); }
thead th      { padding: 11px 16px; text-align: left; font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); font-weight: 500; white-space: nowrap; }
tbody tr      { border-bottom: 1px solid rgba(42,42,64,.45); transition: background var(--tr); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover{ background: rgba(201,168,76,.04); }
tbody td      { padding: 11px 16px; font-size: 13px; vertical-align: middle; }
.td-mono      { font-family: 'DM Mono', monospace; font-size: 12px; color: var(--muted); }

/* ══════════════════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif; font-size: 12px; font-weight: 500;
  letter-spacing: .8px; text-transform: uppercase;
  cursor: pointer; border: 1px solid transparent;
  transition: all var(--tr); white-space: nowrap;
  user-select: none;
}
.btn:active            { transform: scale(.975); }
.btn:disabled          { opacity: .45; cursor: not-allowed; pointer-events: none; }

.btn-primary           { background: linear-gradient(135deg, var(--gold), #a8852e); color: #080604; border-color: transparent; }
.btn-primary:hover     { opacity: .88; }

.btn-outline           { background: transparent; color: var(--gold); border-color: rgba(201,168,76,.28); }
.btn-outline:hover     { background: var(--gold-dim); border-color: var(--gold); }

.btn-ghost             { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-ghost:hover       { color: var(--text); border-color: var(--muted2); background: rgba(255,255,255,.03); }

.btn-danger            { background: rgba(224,92,92,.12);   color: var(--danger); border-color: rgba(224,92,92,.2); }
.btn-danger:hover      { background: rgba(224,92,92,.22); }

.btn-success           { background: rgba(76,190,130,.12);  color: var(--success); border-color: rgba(76,190,130,.2); }
.btn-success:hover     { background: rgba(76,190,130,.22); }

.btn-info              { background: rgba(92,156,224,.12);  color: var(--info); border-color: rgba(92,156,224,.2); }
.btn-info:hover        { background: rgba(92,156,224,.22); }

.btn-sm                { padding: 6px 12px; font-size: 11px; }
.btn-lg                { padding: 12px 22px; font-size: 13px; }
.btn-icon              { width: 34px; height: 34px; padding: 0; justify-content: center; }
.btn-icon.btn-sm       { width: 28px; height: 28px; }

/* ══════════════════════════════════════════════════════════════════
   TOOLBAR & SEARCH
   ══════════════════════════════════════════════════════════════════ */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }

.search-box          { flex: 1; min-width: 170px; position: relative; }
.search-box input    {
  width: 100%; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 12px 9px 36px;
  color: var(--text); font-family: 'DM Sans', sans-serif; font-size: 13px;
  outline: none; transition: border-color var(--tr), box-shadow var(--tr);
}
.search-box input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-dim); }
.search-icon         { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 14px; pointer-events: none; }

.select-filter       {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 12px;
  color: var(--text); font-family: 'DM Sans', sans-serif; font-size: 13px;
  outline: none; cursor: pointer;
  transition: border-color var(--tr);
}
.select-filter:focus { border-color: var(--gold); }

/* ══════════════════════════════════════════════════════════════════
   MODALS
   ══════════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.80);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fadeIn .18s ease;
}
.modal {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; width: 100%; max-width: 540px;
  max-height: 92vh; overflow-y: auto; position: relative;
  animation: slideUp .22s ease;
}
.modal-lg     { max-width: 680px; }
.modal-xl     { max-width: 820px; }

/* Gold top edge */
.modal::before {
  content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 50%; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: var(--card); z-index: 5;
  border-radius: 16px 16px 0 0;
}
.modal-title  { font-family: 'Cormorant Garamond', serif; font-size: 20px; font-weight: 600; color: var(--gold2); }
.modal-close  {
  background: none; border: 1px solid var(--border); color: var(--muted);
  width: 30px; height: 30px; border-radius: 6px; cursor: pointer; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--tr);
}
.modal-close:hover { border-color: var(--danger); color: var(--danger); background: rgba(224,92,92,.08); }

.modal-body   { padding: 20px 24px; }
.modal-footer {
  padding: 14px 24px; border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
  position: sticky; bottom: 0; background: var(--card);
  border-radius: 0 0 16px 16px;
}

/* ══════════════════════════════════════════════════════════════════
   FORMS
   ══════════════════════════════════════════════════════════════════ */
.form-row   { display: grid; grid-template-columns: 1fr 1fr;     gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.form-field { margin-bottom: 14px; }

.form-field label {
  display: block; font-size: 10px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--muted); margin-bottom: 7px;
}
.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  outline: none;
  transition: border-color var(--tr), box-shadow var(--tr);
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-dim);
}
.form-field textarea  { resize: vertical; min-height: 76px; }
.form-field select    { cursor: pointer; }

.form-section       { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 6px; margin-bottom: 14px; }
.form-section-title { font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--gold); margin-bottom: 14px; }

.form-hint { font-size: 11px; color: var(--muted2); margin-top: 5px; }
.form-error{ font-size: 12px; color: var(--danger); margin-top: 5px; }

/* ══════════════════════════════════════════════════════════════════
   IMAGE UPLOAD
   ══════════════════════════════════════════════════════════════════ */
.img-upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 22px; text-align: center; cursor: pointer;
  transition: all var(--tr); position: relative;
  min-height: 100px; display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 6px;
}
.img-upload-zone:hover,
.img-upload-zone.drag  { border-color: var(--gold); background: var(--gold-dim); }
.img-upload-zone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }

.img-preview-wrap { position: relative; }
.img-preview      { width: 100%; height: 130px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); display: block; }
.img-remove       {
  position: absolute; top: 6px; right: 6px;
  background: rgba(0,0,0,.75); border: 1px solid var(--border);
  color: var(--danger); width: 26px; height: 26px; border-radius: 6px;
  cursor: pointer; font-size: 12px; display: flex; align-items: center; justify-content: center;
  transition: background var(--tr);
}
.img-remove:hover { background: rgba(224,92,92,.25); }

/* ══════════════════════════════════════════════════════════════════
   BRANCH ALLOCATOR
   ══════════════════════════════════════════════════════════════════ */
.alloc-grid       { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.alloc-row        {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 12px;
  transition: border-color var(--tr);
}
.alloc-row:hover  { border-color: var(--muted2); }
.alloc-branch-name{ flex: 1; font-size: 13px; }
.alloc-branch-code{ font-family: 'DM Mono', monospace; font-size: 10px; color: var(--muted); }
.alloc-input      {
  width: 86px; background: var(--card); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 8px;
  color: var(--text); font-family: 'DM Mono', monospace; font-size: 13px;
  text-align: center; outline: none; flex-shrink: 0;
  transition: border-color var(--tr);
}
.alloc-input:focus{ border-color: var(--gold); }
.alloc-total      {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; background: var(--gold-dim);
  border: 1px solid rgba(201,168,76,.18); border-radius: var(--radius-sm); margin-top: 8px;
}

/* ══════════════════════════════════════════════════════════════════
   STAT STRIP
   ══════════════════════════════════════════════════════════════════ */
.stat-strip {
  display: flex; gap: 18px; padding: 12px 18px;
  background: var(--card2); border-radius: var(--radius);
  margin-bottom: 16px; border: 1px solid var(--border); overflow-x: auto;
}
.stat-item  { flex-shrink: 0; text-align: center; min-width: 56px; }
.stat-num   { font-family: 'Cormorant Garamond', serif; font-size: 22px; font-weight: 600; color: var(--gold2); line-height: 1; }
.stat-lbl   { font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); margin-top: 3px; }

/* ══════════════════════════════════════════════════════════════════
   SECTION HEADERS
   ══════════════════════════════════════════════════════════════════ */
.section-head  { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-title { font-family: 'Cormorant Garamond', serif; font-size: 18px; font-weight: 500; color: var(--text); }
.section-title span { color: var(--gold); }

/* ══════════════════════════════════════════════════════════════════
   BARS (stock capacity)
   ══════════════════════════════════════════════════════════════════ */
.bar-label   { display: flex; justify-content: space-between; margin-bottom: 5px; font-size: 12px; color: var(--muted); }
.bar-track   { height: 4px; background: var(--card2); border-radius: 4px; overflow: hidden; }
.bar-fill    { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--gold), var(--gold2)); transition: width .6s ease; }
.bar-fill-low{ background: linear-gradient(90deg, var(--danger), #ff8484); }
.bar-fill-mid{ background: linear-gradient(90deg, var(--warn), #ffd080); }

/* ══════════════════════════════════════════════════════════════════
   PRODUCT GRID
   ══════════════════════════════════════════════════════════════════ */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }

.product-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  transition: border-color var(--tr), transform var(--tr), box-shadow var(--tr);
}
.product-card:hover { border-color: rgba(201,168,76,.4); transform: translateY(-2px); box-shadow: 0 8px 32px rgba(0,0,0,.35); }

.product-thumb         { height: 116px; display: flex; align-items: center; justify-content: center; font-size: 38px; background: var(--card2); position: relative; overflow: hidden; }
.product-thumb img     { width: 100%; height: 100%; object-fit: cover; }
.product-thumb-overlay { position: absolute; inset: 0; background: linear-gradient(to bottom, transparent 40%, rgba(0,0,0,.45)); }

.product-body      { padding: 12px; }
.product-name      { font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.product-sku       { font-family: 'DM Mono', monospace; font-size: 10px; color: var(--muted); margin-bottom: 8px; }
.product-footer    { display: flex; align-items: flex-end; justify-content: space-between; margin-top: 6px; }
.product-qty       { font-family: 'Cormorant Garamond', serif; font-size: 24px; font-weight: 600; color: var(--gold2); line-height: 1; }
.product-qty-lbl   { font-size: 10px; color: var(--muted); }

/* ══════════════════════════════════════════════════════════════════
   BRANCH GRID
   ══════════════════════════════════════════════════════════════════ */
.branch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.branch-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; transition: border-color var(--tr); }
.branch-card:hover { border-color: rgba(201,168,76,.28); }
.branch-name { font-family: 'Cormorant Garamond', serif; font-size: 18px; font-weight: 600; color: var(--text); }
.branch-code { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ══════════════════════════════════════════════════════════════════
   WORKER GRID
   ══════════════════════════════════════════════════════════════════ */
.worker-grid      { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.worker-card      { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; transition: border-color var(--tr); }
.worker-card:hover{ border-color: rgba(201,168,76,.28); }
.worker-avatar-lg {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--gold-dim); border: 1px solid rgba(201,168,76,.25);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Cormorant Garamond', serif; font-size: 20px; font-weight: 600; color: var(--gold);
  margin-bottom: 12px; overflow: hidden; flex-shrink: 0;
}
.worker-avatar-lg img { width: 100%; height: 100%; object-fit: cover; }

/* ══════════════════════════════════════════════════════════════════
   TRANSFERS / LOGISTICS
   ══════════════════════════════════════════════════════════════════ */
.transfer-item {
  display: flex; gap: 12px; padding: 14px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 10px;
  align-items: flex-start; transition: border-color var(--tr);
}
.transfer-item:hover  { border-color: var(--border2); }
.transfer-icon        { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; }

/* ══════════════════════════════════════════════════════════════════
   TABS
   ══════════════════════════════════════════════════════════════════ */
.tab-bar  { display: flex; gap: 3px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px; }
.tab-btn  {
  padding: 7px 14px; border-radius: 6px; border: 1px solid transparent;
  background: transparent; color: var(--muted);
  font-family: 'DM Sans', sans-serif; font-size: 12px;
  cursor: pointer; text-transform: capitalize; letter-spacing: .4px;
  transition: all var(--tr); white-space: nowrap;
}
.tab-btn.active { background: var(--gold-dim2); color: var(--gold2); border-color: rgba(201,168,76,.2); }
.tab-btn:hover:not(.active) { color: var(--text); }

/* ══════════════════════════════════════════════════════════════════
   STOCK DETAIL (inside cards)
   ══════════════════════════════════════════════════════════════════ */
.stock-detail-row            { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid rgba(42,42,64,.3); font-size: 12px; }
.stock-detail-row:last-child { border-bottom: none; }

/* ══════════════════════════════════════════════════════════════════
   CONFIRM DIALOG
   ══════════════════════════════════════════════════════════════════ */
.confirm-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: flex; align-items: center; justify-content: center; z-index: 200; backdrop-filter: blur(10px); animation: fadeIn .15s ease; }
.confirm-card    { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 32px 28px; max-width: 340px; width: 90%; text-align: center; box-shadow: 0 40px 100px rgba(0,0,0,.6); animation: slideUp .2s ease; }
.confirm-icon    { font-size: 40px; margin-bottom: 14px; }
.confirm-title   { font-family: 'Cormorant Garamond', serif; font-size: 22px; font-weight: 600; color: var(--text); margin-bottom: 10px; }
.confirm-msg     { font-size: 13px; color: var(--muted); margin-bottom: 24px; line-height: 1.6; }

/* ══════════════════════════════════════════════════════════════════
   ACTIVITY FEED
   ══════════════════════════════════════════════════════════════════ */
.activity-item            { display: flex; align-items: flex-start; gap: 12px; padding: 11px 0; border-bottom: 1px solid rgba(42,42,64,.35); }
.activity-item:last-child { border-bottom: none; }
.activity-dot             { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 5px; }
.activity-text            { font-size: 12px; color: var(--muted); line-height: 1.5; }
.activity-text strong     { color: var(--text); font-weight: 500; }
.activity-time            { font-size: 11px; color: var(--muted2); margin-top: 2px; }

/* ══════════════════════════════════════════════════════════════════
   LAYOUT HELPERS
   ══════════════════════════════════════════════════════════════════ */
.two-col   { display: grid; grid-template-columns: 1fr 1fr;     gap: 16px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.chart-wrap{ position: relative; height: 190px; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-icon  { font-size: 44px; margin-bottom: 14px; opacity: .35; }
.empty-text  { font-size: 13px; }

/* ══════════════════════════════════════════════════════════════════
   LOADING / SPINNER
   ══════════════════════════════════════════════════════════════════ */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.15);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
.spinner-dark { border-color: rgba(8,6,4,.15); border-top-color: #08060a; }

.loading-full { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; color: var(--muted); }
.loading-full .spinner { width: 28px; height: 28px; border-width: 3px; border-top-color: var(--gold); }

/* ══════════════════════════════════════════════════════════════════
   SYNC DOT
   ══════════════════════════════════════════════════════════════════ */
.sync-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); display: inline-block; margin-right: 4px; animation: pulse 2.4s ease-in-out infinite; }

/* ══════════════════════════════════════════════════════════════════
   SCANNER
   ══════════════════════════════════════════════════════════════════ */
.scanner-wrap    { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; min-height: 240px; }
.scanner-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  pointer-events: none; z-index: 2;
}
.scanner-corner  {
  position: absolute; width: 22px; height: 22px;
  border-color: var(--gold); border-style: solid; border-width: 0;
}
.scanner-corner.tl { top: 20%; left: 14%; border-top-width: 3px; border-left-width: 3px; border-radius: 3px 0 0 0; }
.scanner-corner.tr { top: 20%; right: 14%; border-top-width: 3px; border-right-width: 3px; border-radius: 0 3px 0 0; }
.scanner-corner.bl { bottom: 20%; left: 14%; border-bottom-width: 3px; border-left-width: 3px; border-radius: 0 0 0 3px; }
.scanner-corner.br { bottom: 20%; right: 14%; border-bottom-width: 3px; border-right-width: 3px; border-radius: 0 0 3px 0; }
.scan-line {
  position: absolute; left: 14%; right: 14%; height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  animation: scanMove 2s ease-in-out infinite;
  box-shadow: 0 0 8px var(--gold);
}

/* ══════════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ══════════════════════════════════════════════════════════════════ */
.toast-wrap { position: fixed; bottom: 22px; right: 22px; z-index: 300; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  padding: 11px 16px; border-radius: 10px; font-size: 13px;
  display: flex; align-items: center; gap: 10px;
  animation: toastIn .28s cubic-bezier(.34,1.56,.64,1);
  min-width: 220px; max-width: 340px;
  pointer-events: auto; border: 1px solid transparent;
  box-shadow: 0 8px 32px rgba(0,0,0,.45);
}
.toast-success { background: #081a0f; border-color: rgba(76,190,130,.28); color: var(--success); }
.toast-error   { background: #1a0808; border-color: rgba(224,92,92,.28);  color: var(--danger); }
.toast-info    { background: #08101a; border-color: rgba(92,156,224,.28); color: var(--info); }
.toast-icon    { font-size: 15px; flex-shrink: 0; }

/* ══════════════════════════════════════════════════════════════════
   ANIMATIONS
   ══════════════════════════════════════════════════════════════════ */
@keyframes spin      { to { transform: rotate(360deg); } }
@keyframes pulse     { 0%,100% { opacity: 1; } 50% { opacity: .25; } }
@keyframes fadeIn    { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp   { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn   { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastIn   { from { opacity: 0; transform: translateX(40px) scale(.92); } to { opacity: 1; transform: translateX(0) scale(1); } }
@keyframes scanMove  { 0%,100% { top: 20%; } 50% { top: 78%; } }

/* ══════════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; left: -100%; top: 0; bottom: 0;
    z-index: 50; transition: left .28s cubic-bezier(.4,0,.2,1);
    box-shadow: 4px 0 32px rgba(0,0,0,.5);
  }
  .sidebar.open           { left: 0; }
  .sidebar-overlay.open   { display: block; }
  .mob-toggle             { display: flex; align-items: center; }

  .content                { padding: 14px; }
  .topbar                 { padding: 11px 14px; }

  .metric-grid            { grid-template-columns: 1fr 1fr; }
  .two-col, .three-col    { grid-template-columns: 1fr; }
  .form-row, .form-row-3  { grid-template-columns: 1fr; }
  .branch-grid,
  .product-grid,
  .worker-grid            { grid-template-columns: 1fr; }

  .modal    { max-width: 100%; border-radius: 12px; }
  .modal-lg { max-width: 100%; }
  .modal-xl { max-width: 100%; }

  .toast-wrap { right: 10px; bottom: 10px; left: 10px; }
  .toast      { min-width: unset; max-width: 100%; }
}

@media (max-width: 420px) {
  .metric-grid  { grid-template-columns: 1fr; }
  .auth-card    { padding: 28px 20px; border-radius: 14px; max-width: 100%; }
  .auth-wrap    { padding: 16px 14px; align-items: flex-start; padding-top: 32px; }
  .stat-strip   { flex-wrap: wrap; }
  .tab-bar      { flex-wrap: wrap; }
}

/* ══════════════════════════════════════════════════════════════════
   BARCODE SCANNER — additional styles
   ══════════════════════════════════════════════════════════════════ */

/* html5-qrcode injects its own video element — we normalise it */
#gw-barcode-reader video {
  width: 100% !important;
  height: auto !important;
  object-fit: cover;
  border-radius: 0 !important;
  display: block;
}

/* Hide the default html5-qrcode header/footer UI — we use our own */
#gw-barcode-reader > div:not([style*="position"]) {
  display: none !important;
}

#gw-barcode-reader img[alt="Info icon"],
#gw-barcode-reader img[alt="Camera based scan"],
#gw-barcode-reader select,
#gw-barcode-reader button,
#gw-barcode-reader span:not([style]) {
  display: none !important;
}

/* Keep only the video/canvas region */
#gw-barcode-reader > div[style*="position"] {
  border: none !important;
  box-shadow: none !important;
}

/* Scan button in toolbar */
.scan-toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid rgba(201,168,76,.3);
  color: var(--gold);
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .5px;
  cursor: pointer;
  transition: all var(--tr);
  white-space: nowrap;
}
.scan-toolbar-btn:hover {
  background: var(--gold-dim);
  border-color: var(--gold);
}

/* Manual barcode input focus state */
#gw-manual-barcode:focus {
  border-color: var(--gold) !important;
  box-shadow: 0 0 0 3px var(--gold-dim);
}

/* Scanner modal on very small screens */
@media (max-width: 420px) {
  #gw-barcode-reader video {
    min-height: 200px;
  }
  .scanner-wrap {
    min-height: 200px !important;
  }
}
