/* =============================================================
   Standard Group — Management Portal
   Brand: pumpsuae.com | Developed by Faiz Information Technology
   ============================================================= */

/* ── BRAND TOKENS ─────────────────────────────────────────── */
:root {
  /* Standard Group brand palette */
  --sg-red:         #C62828;
  --sg-red-dark:    #8E0000;
  --sg-red-light:   #FF5F52;
  --sg-red-faint:   rgba(198,40,40,.08);
  --sg-navy:        #0D1B2A;
  --sg-navy-mid:    #162032;
  --sg-navy-light:  #1E2F42;
  --sg-orange:      #E65100;
  --sg-gold:        #F57F17;

  /* Sidebar */
  --sb-bg:          var(--sg-navy);
  --sb-border:      rgba(255,255,255,.08);
  --sb-text:        rgba(255,255,255,.55);
  --sb-text-hover:  rgba(255,255,255,.85);
  --sb-text-active: #FFFFFF;
  --sb-item-hover:  rgba(255,255,255,.06);
  --sb-item-active: rgba(198,40,40,.22);
  --sb-accent:      var(--sg-red);
  --sb-width:       240px;

  /* Header / Footer */
  --hdr-bg:        var(--sg-navy);
  --hdr-text:      #FFFFFF;
  --hdr-h:         60px;
  --ftr-bg:        var(--sg-navy-mid);
  --ftr-text:      rgba(255,255,255,.4);
  --ftr-h:         40px;

  /* Page background */
  --bg:            #EEF2F7;
  --panel:         #FFFFFF;
  --panel-tint:    #F8FAFC;
  --panel-soft:    #EDF2F7;

  /* Borders */
  --border:        #E2E8F0;
  --border-soft:   #EDF2F7;
  --border-dark:   #CBD5E0;

  /* Text */
  --text:          #1A202C;
  --text-2:        #2D3748;
  --muted:         #718096;
  --link:          #2B6CB0;

  /* Accents (preserved for fieldset usage) */
  --blue:    #BEE3F8; --blue-bg:   #EBF8FF; --blue-s:   #2B6CB0;
  --green:   #9AE6B4; --green-bg:  #F0FFF4; --green-s:  #276749;
  --yellow:  #FAF089; --yellow-bg: #FFFFF0; --yellow-s: #744210;
  --pink:    #FED7E2; --pink-bg:   #FFF5F7; --pink-s:   #97266D;
  --purple:  #D6BCFA; --purple-bg: #FAF5FF; --purple-s: #553C9A;
  --orange:  #FBD38D; --orange-bg: #FFFAF0; --orange-s: #7B341E;
  --teal:    #81E6D9; --teal-bg:   #E6FFFA; --teal-s:   #285E61;
  --gray:    #E2E8F0; --gray-bg:   #F7FAFC;

  /* Buttons */
  --btn:       #FFFFFF;
  --btn-h:     #F7FAFC;
  --btn-a:     #EDF2F7;
  --btn-b:     #CBD5E0;
  --btn-text:  #2D3748;
  --primary:   var(--sg-red);
  --primary-h: var(--sg-red-dark);
  --primary-a: #6D0000;
  --primary-t: #FFFFFF;
  --danger:    #E53E3E;
  --danger-h:  #C53030;
  --danger-t:  #FFFFFF;

  /* Shapes */
  --r:   8px;
  --r-s: 6px;
  --r-xs:4px;
  --sh0: 0 1px 2px rgba(0,0,0,.05);
  --sh1: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --sh2: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
  --sh3: 0 20px 50px rgba(0,0,0,.25);
  --ring: 0 0 0 3px rgba(198,40,40,.2);
  --t:   130ms cubic-bezier(.2,.6,.3,1);
}

/* ── RESET ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
a      { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11.5px;
  background: var(--panel-soft);
  color: var(--text-2);
  padding: 1px 5px;
  border-radius: var(--r-xs);
}
.muted { color: var(--muted); }
.error { color: #C53030; font-size: 12px; min-height: 1.2em; margin-top: 6px; }
.hint  { font-size: 12px; color: var(--muted); margin-top: 10px; }

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

/* ── APP LAYOUT: header / body(sidebar+content) / footer ─── */
.app-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* ── HEADER ───────────────────────────────────────────────── */
.app-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  height: var(--hdr-h);
  padding: 0 20px;
  background: var(--hdr-bg);
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
  z-index: 50;
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}
.header-logo {
  height: 36px;
  width: auto;
  object-fit: contain;
  display: block;
}
.header-logo-fallback {
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-logo-fallback .logo-icon {
  width: 36px; height: 36px;
  background: var(--sg-red);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 18px; color: #fff;
  flex-shrink: 0;
}
.header-logo-fallback .logo-text {
  display: flex; flex-direction: column; line-height: 1.15;
}
.header-logo-fallback .logo-text strong {
  font-size: 15px; font-weight: 700; color: #FFFFFF;
  letter-spacing: .02em;
}
.header-logo-fallback .logo-text span {
  font-size: 10px; font-weight: 400; color: rgba(255,255,255,.5);
  letter-spacing: .08em; text-transform: uppercase;
}
.header-divider {
  width: 1px; height: 28px;
  background: rgba(255,255,255,.15);
  flex-shrink: 0;
}
.header-portal-title {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,.6);
  letter-spacing: .02em;
}
.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.header-user {
  font-size: 12.5px;
  color: rgba(255,255,255,.7);
  display: flex; align-items: center; gap: 7px;
}
.header-user strong { color: #fff; font-weight: 600; }

/* ── BODY: sidebar + content ──────────────────────────────── */
.app-body {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

/* ── SIDEBAR ──────────────────────────────────────────────── */
.app-sidebar {
  flex-shrink: 0;
  width: var(--sb-width);
  background: var(--sb-bg);
  border-right: 1px solid var(--sb-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}
.app-sidebar::-webkit-scrollbar      { width: 4px; }
.app-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 4px; }

.sidebar-section {
  padding: 20px 0 4px;
}
.sidebar-section-label {
  padding: 0 16px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.25);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--sb-text);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  border-left: 3px solid transparent;
  transition: background var(--t), color var(--t), border-color var(--t);
  text-decoration: none;
  line-height: 1.3;
}
.nav-item:hover {
  background: var(--sb-item-hover);
  color: var(--sb-text-hover);
}
.nav-item.active {
  background: var(--sb-item-active);
  color: var(--sb-text-active);
  border-left-color: var(--sb-accent);
  font-weight: 600;
}
.nav-icon {
  font-size: 15px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  opacity: .7;
}
.nav-item.active .nav-icon { opacity: 1; }
.nav-item.nav-training {
  background: rgba(198,40,40,.12);
  color: #FF8A80;
  font-weight: 600;
}
.nav-item.nav-training:hover { background: rgba(198,40,40,.2); }
.nav-item.nav-training.active { background: rgba(198,40,40,.28); color: #fff; }

.sidebar-bottom {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,.06);
}
.sidebar-version {
  font-size: 10.5px;
  color: rgba(255,255,255,.2);
  text-align: center;
}

/* ── CONTENT AREA ─────────────────────────────────────────── */
/*
 * SCROLL ARCHITECTURE (unchanged from v1):
 *   .app-content: overflow-y:auto — scrolls non-table views (Status, README, etc.)
 *   .fieldset wrapping a table: flex column, min-height:0, NO overflow property
 *   .table-scroll: flex:1, overflow:auto — ONLY scroll container for tables
 */
.app-content {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--bg);
}
.content-inner {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  padding: 20px 22px;
  min-height: 0;
}
/* Let fieldset with table-scroll fill the remaining space */
.content-inner > .fieldset:has(.table-scroll) {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-bottom: 0;
}

/* ── FOOTER ───────────────────────────────────────────────── */
.app-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: var(--ftr-h);
  padding: 0 20px;
  background: var(--ftr-bg);
  border-top: 1px solid rgba(255,255,255,.06);
  font-size: 11px;
  color: var(--ftr-text);
  z-index: 10;
}
.app-footer strong { color: rgba(255,255,255,.35); font-weight: 600; }

/* ── BUTTONS ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 5px; padding: 7px 14px;
  font: 500 13px/1 inherit;
  border: 1px solid var(--btn-b);
  border-radius: var(--r-s);
  background: var(--btn);
  color: var(--btn-text);
  cursor: pointer; min-width: 60px; white-space: nowrap;
  box-shadow: var(--sh0);
  transition: background var(--t), border-color var(--t), transform 80ms;
}
.btn:hover         { background: var(--btn-h); border-color: var(--border-dark); }
.btn:active        { background: var(--btn-a); transform: translateY(1px); box-shadow: none; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled      { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn.primary {
  background: var(--primary); border-color: var(--primary);
  color: var(--primary-t); box-shadow: 0 1px 3px rgba(198,40,40,.3);
}
.btn.primary:hover  { background: var(--primary-h); border-color: var(--primary-h); }
.btn.primary:active { background: var(--primary-a); border-color: var(--primary-a); }
.btn.btn-secondary  { background: var(--panel-soft); }
.btn.btn-tiny       { padding: 4px 10px; font-size: 12px; min-width: 0; }
.btn.btn-danger {
  background: var(--danger); border-color: var(--danger);
  color: var(--danger-t); box-shadow: 0 1px 3px rgba(229,62,62,.3);
}
.btn.btn-danger:hover { background: var(--danger-h); border-color: var(--danger-h); }
.btn.btn-outline {
  background: transparent; border-color: var(--sg-red); color: var(--sg-red);
}
.btn.btn-outline:hover { background: var(--sg-red-faint); }

/* ── INPUTS ───────────────────────────────────────────────── */
input.swing, select.swing, textarea.swing {
  width: 100%; padding: 8px 10px;
  font: 13px/1.4 inherit;
  background: var(--panel);
  border: 1px solid var(--border-dark);
  border-radius: var(--r-s);
  color: var(--text);
  transition: border-color var(--t), box-shadow var(--t);
}
input.swing:focus, select.swing:focus, textarea.swing:focus {
  outline: none; border-color: var(--sg-red); box-shadow: var(--ring);
}
input.swing:disabled { background: var(--panel-soft); color: var(--muted); }
input.swing::placeholder, textarea.swing::placeholder { color: var(--muted); opacity: .6; }

/* ── CARDS / FIELDSETS ────────────────────────────────────── */
.fieldset {
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 18px 18px;
  margin: 0 0 14px;
  background: var(--panel);
  box-shadow: var(--sh0);
}
.fieldset > legend {
  padding: 0 6px;
  font: 600 13px/1 inherit;
  color: var(--text);
  background: var(--panel);
}
.fieldset.accent-blue   { border-top: 3px solid var(--blue-s);   }
.fieldset.accent-blue   > legend { color: var(--blue-s);   }
.fieldset.accent-green  { border-top: 3px solid var(--green-s);  }
.fieldset.accent-green  > legend { color: var(--green-s);  }
.fieldset.accent-yellow { border-top: 3px solid var(--yellow-s); }
.fieldset.accent-yellow > legend { color: var(--yellow-s); }
.fieldset.accent-pink   { border-top: 3px solid var(--pink-s);   }
.fieldset.accent-pink   > legend { color: var(--pink-s);   }
.fieldset.accent-purple { border-top: 3px solid var(--purple-s); }
.fieldset.accent-purple > legend { color: var(--purple-s); }
.fieldset.accent-orange { border-top: 3px solid var(--orange-s); }
.fieldset.accent-orange > legend { color: var(--orange-s); }
.fieldset.accent-teal   { border-top: 3px solid var(--teal-s);   }
.fieldset.accent-teal   > legend { color: var(--teal-s);   }
.fieldset.accent-gray   { border-top: 3px solid var(--border-dark); }
.fieldset.accent-red    { border-top: 3px solid var(--sg-red); }
.fieldset.accent-red > legend { color: var(--sg-red); }

/* ── FORMS ────────────────────────────────────────────────── */
.form-row { display: block; margin-bottom: 12px; }
.form-row > label, .form-row label:first-of-type {
  display: block; font: 600 12px/1 inherit;
  color: var(--text-2); margin-bottom: 5px; letter-spacing: .01em;
}
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px,1fr)); gap: 12px 16px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.readonly-val {
  font-size: 13px; background: var(--panel-soft); border: 1px solid var(--border-soft);
  border-radius: var(--r-s); padding: 7px 10px; min-height: 33px;
  color: var(--text-2); line-height: 1.5;
}
.readonly-val.readonly-block { white-space: pre-wrap; min-height: 56px; }

/* ── PANEL TOOLBAR ────────────────────────────────────────── */
.panel-actions {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 8px; margin-bottom: 12px;
}
.panel-actions input.swing { width: 240px; max-width: 100%; }

/* ── DATA TABLE ───────────────────────────────────────────── */
.table-scroll {
  flex: 1 1 auto;
  min-height: 200px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--panel);
}
.table-scroll::-webkit-scrollbar          { width: 12px; height: 12px; }
.table-scroll::-webkit-scrollbar-thumb    {
  background: #9ca3af; border: 3px solid var(--panel);
  border-radius: 999px; min-height: 32px; min-width: 32px;
}
.table-scroll::-webkit-scrollbar-thumb:hover { background: #6b7280; }
.table-scroll::-webkit-scrollbar-track   { background: var(--panel-tint); }
.table-scroll::-webkit-scrollbar-corner  { background: var(--panel-tint); }
.table-scroll { scrollbar-width: thin; scrollbar-color: #9ca3af var(--panel-tint); }

table.swing {
  width: max-content; min-width: 100%;
  table-layout: auto;
  border-collapse: separate; border-spacing: 0;
  font-size: 12.5px; font-family: inherit;
  background: var(--panel);
}
table.swing thead th {
  position: sticky; top: 0; z-index: 3;
  background: var(--panel-tint);
  border-bottom: 2px solid var(--border-dark);
  border-right: 1px solid var(--border);
  padding: 9px 12px; text-align: left;
  font: 600 11px/1 inherit;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
table.swing thead th:last-child { border-right: none; }
table.swing tbody tr               { background: var(--panel); }
table.swing tbody tr:nth-child(even) td { background: var(--panel-tint); }
table.swing tbody tr:hover           td { background: #FFF5F5; color: var(--text); }
table.swing tbody td {
  border-bottom: 1px solid var(--border-soft);
  border-right: 1px solid var(--border-soft);
  padding: 8px 12px;
  vertical-align: middle;
  color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: inherit;
}
table.swing tbody td:last-child { border-right: none; }
table.swing tbody td:has(.cell-input:focus) { overflow: visible; position: relative; z-index: 8; }
table.swing thead th.col-actions,
table.swing tbody   td.col-actions {
  position: sticky; right: 0; z-index: 2;
  border-left: 1px solid var(--border-dark); border-right: none;
  box-shadow: -3px 0 8px -3px rgba(0,0,0,.12);
  overflow: visible; white-space: nowrap;
}
table.swing thead th.col-actions { z-index: 4; background: var(--panel-tint); text-align: center; }
table.swing tbody td.col-actions { background: var(--panel); }
table.swing tbody tr:nth-child(even) td.col-actions { background: var(--panel-tint); }
table.swing tbody tr:hover           td.col-actions { background: #FFF5F5; }

.cell-input {
  display: block; width: 100%;
  padding: 4px 6px;
  font: 12.5px/1.4 inherit; color: inherit;
  background: transparent; border: 1px solid transparent;
  border-radius: var(--r-xs); text-overflow: ellipsis;
  transition: background var(--t), border-color var(--t), box-shadow var(--t);
}
.cell-input:focus {
  background: var(--panel); border-color: var(--sg-red);
  box-shadow: var(--ring), var(--sh2); outline: none;
  position: relative; z-index: 9;
  min-width: 260px; width: max(100%, 260px); text-overflow: clip;
}
.cell-input.dirty { background: var(--yellow-bg); border-color: var(--yellow); }

.row-actions { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
.row-actions .btn { padding: 5px 12px; font-size: 12px; min-width: 0; box-shadow: none; }

/* ── STATUS CARDS ─────────────────────────────────────────── */
.status-item {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--r-s); padding: 14px 16px;
  transition: border-color var(--t), box-shadow var(--t);
}
.status-item:hover { border-color: var(--sg-red); box-shadow: var(--sh1); }
.status-item .k { font: 600 11px/1 inherit; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.status-item .v { font: 600 20px/1 inherit; color: var(--text); margin-top: 5px; letter-spacing: -.01em; }

/* ── PILLS ────────────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center;
  padding: 2px 10px; border: 1px solid transparent;
  border-radius: 999px; background: var(--panel-soft);
  font: 600 11px/1.4 inherit; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted);
}
.pill.role-admin   { background: var(--pink-bg);   color: var(--pink-s);   border-color: var(--pink); }
.pill.role-sales   { background: var(--blue-bg);   color: var(--blue-s);   border-color: var(--blue); }
.pill.s-new        { background: var(--yellow-bg); color: var(--yellow-s); border-color: var(--yellow); }
.pill.s-progress   { background: var(--blue-bg);   color: var(--blue-s);   border-color: var(--blue); }
.pill.s-quoted     { background: var(--purple-bg); color: var(--purple-s); border-color: var(--purple); }
.pill.s-won        { background: var(--green-bg);  color: var(--green-s);  border-color: var(--green); }
.pill.s-lost       { background: var(--pink-bg);   color: var(--pink-s);   border-color: var(--pink); }
.pill.s-closed     { background: var(--panel-soft);color: var(--muted);    border-color: var(--border); }

/* ── MODAL ────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center; padding: 20px;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: fadeIn 150ms ease-out;
}
.modal-frame {
  width: 100%; max-width: 560px; max-height: 92vh;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--sh3);
  overflow-y: auto;
  animation: popIn 180ms cubic-bezier(.2,.7,.3,1);
}
.modal-frame-lg { max-width: 780px; }
.modal-header {
  display: flex; align-items: center;
  padding: 16px 20px;
  background: var(--sg-navy);
  color: #fff;
  border-radius: var(--r) var(--r) 0 0;
  font-size: 14px; font-weight: 600;
}
.modal-body { padding: 20px; }
@keyframes fadeIn { from { opacity: 0; }  to { opacity: 1; } }
@keyframes popIn  { from { opacity: 0; transform: scale(.97) translateY(8px); }
                    to   { opacity: 1; transform: scale(1)   translateY(0); } }

/* ── TOAST ────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 18px; right: 18px; z-index: 300;
  padding: 12px 16px; max-width: 360px; font-size: 13px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--r-s); box-shadow: var(--sh2);
  animation: popIn 150ms ease-out;
}
.toast.success { background: var(--green-bg); border-color: var(--green); color: var(--green-s); }
.toast.error   { background: var(--pink-bg);  border-color: var(--pink);  color: var(--pink-s); }

/* ── LOGIN PAGE ───────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sg-navy);
  background-image: linear-gradient(135deg, var(--sg-navy) 0%, #1E2F42 100%);
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--panel);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0,0,0,.4);
  overflow: hidden;
}
.login-card-header {
  background: var(--sg-navy-mid);
  padding: 28px 32px 24px;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.login-logo {
  height: 48px; width: auto;
  max-width: 240px;
  object-fit: contain;
  display: block;
  margin: 0 auto 16px;
}
.login-logo-fallback {
  margin: 0 auto 16px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.login-logo-fallback .lf-icon {
  width: 52px; height: 52px;
  background: var(--sg-red);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 26px; color: #fff;
}
.login-logo-fallback .lf-name {
  font-size: 16px; font-weight: 700; color: #fff; letter-spacing: .02em;
}
.login-card-title {
  font-size: 13px; font-weight: 400; color: rgba(255,255,255,.5);
  text-transform: uppercase; letter-spacing: .1em;
}
.login-card-body { padding: 28px 32px 32px; }
.login-card-body .form-row { margin-bottom: 16px; }
.login-card-body label {
  font-size: 12px; font-weight: 600; color: var(--text-2);
  display: block; margin-bottom: 6px;
}
.login-card-body .btn.primary {
  width: 100%; height: 42px; font-size: 14px;
  background: var(--sg-red); border-color: var(--sg-red);
  margin-top: 6px;
}
.login-card-body .btn.primary:hover { background: var(--sg-red-dark); border-color: var(--sg-red-dark); }

/* ── TRAINING PLATFORM ────────────────────────────────────── */
/* content-inner override: training needs overflow:hidden so inner flex/scroll works */
.content-inner.training-active {
  padding: 12px 14px;
  overflow: hidden;             /* kills scroll — inner panes manage their own */
}

.training-layout {
  display: grid;
  grid-template-columns: 1fr 320px;  /* wider chat pane, compact library */
  gap: 12px;
  height: 100%;
  min-height: 0;
}

/* Chat pane */
.training-chat-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--sh0);
  overflow: hidden;
}
.training-pane-header {
  flex-shrink: 0;
  padding: 14px 18px;
  background: var(--sg-navy);
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.training-pane-header h3 {
  font-size: 14px; font-weight: 700; margin-bottom: 2px;
}
.training-pane-header p {
  font-size: 12px; color: rgba(255,255,255,.55); margin: 0;
}

.training-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  background: #F7F9FC;          /* WhatsApp-ish background */
  scrollbar-width: thin;
  scrollbar-color: var(--border-dark) transparent;
}
.training-messages::-webkit-scrollbar { width: 6px; }
.training-messages::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 4px; }

.chat-msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;                  /* fill container — inner bubble controls its own width */
}
.chat-msg.user { align-items: flex-end; }
.chat-msg.bot  { align-items: flex-start; }

.chat-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
/* User bubble: right-aligned, 68% wide */
.chat-msg.user .chat-bubble {
  width: 68%;
  background: var(--sg-red);
  color: #fff;
  border-radius: 12px 12px 3px 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
}
/* Bot bubble: full width of the messages area */
.chat-msg.bot .chat-bubble {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 3px 12px 12px 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.07);
}
.chat-msg.bot .chat-bubble.editing {
  background: #FFFFF0;
  border-color: var(--yellow);
}
/* Textarea inside bubble: auto-height, no resize handle */
.chat-bubble textarea {
  display: block;
  width: 100%;
  min-height: 48px;
  font: 13.5px/1.6 inherit;
  background: transparent;
  border: none; outline: none;
  resize: none;                 /* hide the resize handle */
  overflow: hidden;             /* JS auto-height handles overflow */
  color: inherit;
}
/* Tool badges, usage bar, actions — all full width too */
.chat-msg.bot .chat-tools,
.chat-msg.bot .chat-usage,
.chat-msg.bot .chat-photos,
.chat-msg.bot .chat-wa-buttons,
.chat-msg.bot .chat-actions {
  width: 100%;
}

/* WhatsApp-style interactive buttons rendered in training */
.chat-wa-buttons {
  display: flex; flex-direction: column; gap: 1px;
  margin-top: 2px;
  border: 1px solid var(--border);
  border-radius: 0 0 12px 12px;
  overflow: hidden;
  max-width: 92%;
}
.chat-wa-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 16px;
  background: var(--panel);
  border: none; border-top: 1px solid var(--border-soft);
  font-size: 13.5px; font-weight: 500; color: #0C7BC7;
  cursor: pointer; text-align: center;
  transition: background var(--t);
}
.chat-wa-btn:hover { background: #EBF5FF; }
.chat-wa-btn:first-child { border-top: none; }
.chat-actions {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.chat-actions .btn { padding: 4px 10px; font-size: 11.5px; min-width: 0; }
.chat-actions .save-cat {
  padding: 3px 8px; font-size: 11.5px;
  border: 1px solid var(--border-dark);
  border-radius: var(--r-s); background: var(--panel);
  color: var(--text-2);
}

.training-input-area {
  flex-shrink: 0;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--panel);
  display: flex; flex-direction: column; gap: 6px;
}
.training-input-row {
  display: flex; gap: 6px; align-items: flex-end;
}
.training-input-row textarea.swing {
  flex: 1;
  min-height: 48px; max-height: 140px;
  resize: none; overflow-y: auto;
  font-size: 14px; padding: 11px 14px;
  border-radius: 22px;             /* rounded pill input — WhatsApp style */
}
.training-toolbar {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
}
.training-toolbar label {
  font-size: 11.5px; font-weight: 600; color: var(--muted);
}
.training-toolbar select.swing {
  width: auto; min-width: 120px; padding: 5px 8px; font-size: 12px;
}

/* Library pane */
.training-library-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--sh0);
  overflow: hidden;
}

.training-lib-items {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border-dark) transparent;
}
.training-lib-items::-webkit-scrollbar { width: 6px; }
.training-lib-items::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 4px; }

.training-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
  transition: background var(--t);
}
.training-item:hover { background: var(--panel-tint); }
.training-item.inactive { opacity: .5; }
.ti-category {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--sg-red); margin-bottom: 5px;
}
.ti-question {
  font-size: 12.5px; font-weight: 600; color: var(--text);
  margin-bottom: 4px; line-height: 1.4;
}
.ti-answer {
  font-size: 12px; color: var(--muted); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.ti-footer {
  display: flex; align-items: center; gap: 6px; margin-top: 8px;
}
.ti-footer .btn { padding: 3px 8px; font-size: 11px; min-width: 0; }
.ti-toggle {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600;
  padding: 3px 10px; border-radius: 99px; cursor: pointer;
  border: 1px solid; transition: all var(--t);
}
.ti-toggle.on  { background: var(--green-bg); color: var(--green-s); border-color: var(--green); }
.ti-toggle.off { background: var(--panel-soft); color: var(--muted); border-color: var(--border); }
.ti-by { margin-left: auto; font-size: 11px; color: var(--muted); }

.lib-empty {
  padding: 48px 24px; text-align: center; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.lib-empty .empty-icon { font-size: 36px; opacity: .4; }

/* ── Training: tool call badges ──────────────────────────── */
.chat-tools {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-bottom: 6px;
}
.tool-badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 7px;
  background: var(--sg-navy);
  color: rgba(255,255,255,.75);
  border-radius: 4px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 10.5px;
  letter-spacing: .01em;
}
.tool-badge.tool-photo { background: var(--sg-red); color: #fff; }
.tool-badge.tool-routing { background: #1d4ed8; color: #fff; }

/* ── Training: inline photos ─────────────────────────────── */
.chat-photos {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 8px;
}
.chat-photo-wrap {
  position: relative;
  width: 120px; height: 90px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  flex-shrink: 0;
}
.chat-photo-wrap img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .2s;
}
.chat-photo-wrap:hover img { transform: scale(1.05); }
.chat-photo-caption {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,.6); color: #fff;
  font-size: 10px; padding: 3px 5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-photo-pdf {
  width: 120px; height: 90px;
  border: 1px solid var(--border);
  border-radius: 6px;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
  background: var(--panel-soft); color: var(--muted);
  flex-shrink: 0;
}
.chat-photos-label {
  font-size: 10.5px; color: var(--sg-red); font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em;
  margin-bottom: 4px; display: block;
}

/* ── Training: token usage bar ───────────────────────────── */
.chat-usage {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 6px 10px;
  background: #F0F4F8;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  font-size: 11px; color: var(--muted);
  margin-top: 6px;
  align-items: center;
}
.usage-chip {
  display: flex; align-items: center; gap: 3px; white-space: nowrap;
}
.usage-chip strong { color: var(--text-2); font-weight: 600; }
.usage-chip .uc-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted);
}
.usage-model {
  font-family: ui-monospace, "SF Mono", monospace;
  background: var(--sg-navy); color: rgba(255,255,255,.8);
  padding: 1px 6px; border-radius: 3px; font-size: 10.5px;
  margin-right: 4px;
}
.usage-sep {
  color: var(--border-dark);
}

/* ── Training: model selector in toolbar ─────────────────── */
.training-model-sel {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  background: rgba(13,27,42,.06);
  border: 1px solid var(--border);
  border-radius: var(--r-s);
  flex-shrink: 0;
}
.training-model-sel label {
  font-size: 11px; font-weight: 600; color: var(--muted);
  white-space: nowrap;
}
.training-model-sel select.swing {
  width: auto; min-width: 160px; padding: 4px 8px; font-size: 12px;
}

/* ── Typing indicator */
.typing-indicator {
  display: flex; align-items: center; gap: 5px;
  padding: 8px 12px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 12px 12px 12px 3px;
  align-self: flex-start;
}
.typing-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted);
  animation: typingBounce 1.2s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(1); opacity: .5; }
  40%            { transform: scale(1.3); opacity: 1; }
}

/* ── BRAND PHOTOS GRID ────────────────────────────────────── */
.photos-grid { display: flex; flex-direction: column; gap: 16px; margin-top: 12px; }
.photos-heading { font-size: 13px; font-weight: 600; margin: 4px 0; color: var(--text-2); }
.photos-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.photo-card {
  border: 1px solid var(--border); border-radius: 8px;
  background: #fff; overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: var(--sh0);
}
.photo-thumb {
  width: 100%; height: 130px; object-fit: cover;
  background: var(--panel-soft); display: block;
}
.photo-thumb.pdf { display: grid; place-items: center; font-weight: 600; color: var(--muted); background: var(--panel-soft); }
.photo-meta { padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.photo-brand  { font-size: 12px; }
.photo-caption { font-size: 12px; }
.photo-actions { display: flex; gap: 6px; align-items: center; margin-top: 4px; }
.photo-actions .btn-link { font-size: 11.5px; color: var(--sg-red); text-decoration: none; margin-right: auto; }
.photo-actions .btn-link:hover { text-decoration: underline; }

/* ── QUERY LOG ────────────────────────────────────────────── */
.cell-wrap { white-space: pre-wrap; word-break: break-word; max-width: 380px; line-height: 1.5; }
.cell-wrap code { white-space: pre-wrap; word-break: break-word; }

/* ── RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 1100px) {
  :root { --sb-width: 210px; }
  .training-layout { grid-template-columns: 1fr 290px; }
  .content-inner { padding: 16px; }
}

@media (max-width: 900px) {
  .training-layout { grid-template-columns: 1fr; grid-template-rows: 1fr 300px; }
  .training-library-pane { max-height: 300px; }
}

@media (max-width: 768px) {
  .app-sidebar { position: fixed; left: 0; top: var(--hdr-h); bottom: var(--ftr-h); z-index: 100;
                 transform: translateX(-100%); transition: transform .25s ease; }
  .app-sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,.4); }
  :root { --sb-width: 260px; }
  .content-inner { padding: 12px; }
  .modal { padding: 8px; }
  .modal-frame { max-height: 96vh; }
  .toast { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}

/* ── REDUCED MOTION ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
