/* ===== Rafta.ai — Clean & Minimal Design System ===== */

/* --- Tokens --- */
:root {
  --bg: #f8f9fb;
  --surface: #ffffff;
  --border: #e8ecf0;
  --border-hover: #d0d5dd;
  --text: #1a1a2e;
  --text-2: #5f6980;
  --text-3: #8b95a5;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #eff4ff;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --success: #16a34a;
  --success-light: #f0fdf4;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg: 0 4px 16px rgba(0,0,0,.08);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --transition: 150ms ease;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; }
body { font-family: var(--font); margin: 0; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ===== HEADER ===== */
.hdr {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  height: 52px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  margin-right: 32px;
  flex-shrink: 0;
}
.brand:hover { text-decoration: none; }
.brand-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.3px;
}
.brand-org {
  font-size: 12px;
  color: var(--text-3);
  padding-left: 8px;
  border-left: 1px solid var(--border);
}

/* Main nav */
.nav-main {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
}
.nav-main a {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  transition: all var(--transition);
  text-decoration: none;
}
.nav-main a:hover {
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}
.nav-main a.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}
.nav-mobile-user { display: none; }

/* User menu */
.nav-user {
  position: relative;
  margin-left: auto;
  flex-shrink: 0;
}
.nav-username {
  background: none;
  border: none;
  color: var(--text-2);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
}
.nav-username:hover { background: var(--bg); color: var(--text); }
.nav-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  padding: 4px;
  z-index: 200;
}
.nav-dropdown.open { display: block; }
.nav-dropdown a, .nav-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 12px;
  color: var(--text);
  font-size: 13px;
  text-decoration: none;
  border: none;
  background: none;
  cursor: pointer;
  font-weight: 400;
  border-radius: 4px;
  font-family: var(--font);
}
.nav-dropdown a:hover, .nav-dropdown button:hover {
  background: var(--bg);
  text-decoration: none;
}
.nav-logout-btn { color: var(--danger) !important; }

/* Hamburger */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  padding: 6px;
  margin-left: auto;
  line-height: 1;
}

@media (max-width: 768px) {
  .hdr { padding: 0 12px; }
  .brand { margin-right: auto; }
  .brand-org { display: none; }
  .nav-toggle { display: block; }
  .nav-main {
    display: none;
    position: absolute;
    top: 52px;
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 8px;
    box-shadow: var(--shadow-lg);
  }
  .nav-main.open { display: flex; }
  .nav-main a { padding: 10px 12px; width: 100%; }
  .nav-mobile-user {
    display: block;
    border-top: 1px solid var(--border);
    margin-top: 4px;
    padding-top: 4px;
  }
  .nav-mobile-user a {
    display: block;
    padding: 8px 12px;
    color: var(--text-2);
    font-size: 13px;
  }
  .nav-mobile-user .nav-logout-btn {
    color: var(--danger);
    padding: 8px 12px;
    width: 100%;
    text-align: left;
    font-size: 13px;
  }
  .nav-user { display: none; }
}

/* ===== LAYOUT ===== */
.wrap {
  padding: 24px 20px;
  max-width: 720px;
  margin: 0 auto;
}
.wrap.full { max-width: 100%; padding: 16px; }

@media (max-width: 768px) {
  .wrap { padding: 16px 12px; }
}

/* ===== CARDS ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
}

/* ===== TYPOGRAPHY ===== */
.nm { font-weight: 600; font-size: 14px; color: var(--text); }
.meta { font-size: 12px; color: var(--text-3); margin-top: 4px; line-height: 1.6; }
.meta b { color: var(--text-2); font-weight: 500; }
.mut { color: var(--text-3); font-size: 12px; }
.sub { color: var(--text-3); font-size: 12px; margin-bottom: 8px; }
.rafhdr { font-size: 11px; font-weight: 600; color: var(--text-3); margin: 20px 0 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.warn { font-size: 12px; background: var(--warning-light); border-left: 2px solid var(--warning); padding: 6px 10px; margin-top: 8px; border-radius: 4px; color: #92400e; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
  line-height: 1.4;
  white-space: nowrap;
}
.btn:hover {
  background: var(--bg);
  border-color: var(--border-hover);
  text-decoration: none;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--danger); border-color: #fca5a5; }
.btn.danger:hover { background: var(--danger-light); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

/* ===== FLASH / ERROR ===== */
.flash {
  background: var(--success-light);
  border: 1px solid #bbf7d0;
  color: #166534;
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 13px;
}
.err {
  background: var(--danger-light);
  border: 1px solid #fecaca;
  color: #991b1b;
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 13px;
}

/* ===== FORMS ===== */
form.stack label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  margin: 12px 0 4px;
}
input[type=text], input[type=password], input[type=email],
input[type=date], input[type=number], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
textarea { min-height: 72px; resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 480px) { .row2 { grid-template-columns: 1fr; } }

/* ===== LOCATION BUTTONS ===== */
.locbtn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  margin: 3px;
  text-decoration: none;
  color: var(--text);
  font-weight: 500;
  font-size: 13px;
  transition: all var(--transition);
}
.locbtn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); text-decoration: none; }
.locbtn small { color: var(--text-3); font-weight: 400; }

/* ===== SEARCH ===== */
.searchbar { display: flex; gap: 8px; margin-bottom: 16px; }
.searchbar input { flex: 1; }
.search-filters { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.search-filters select, .search-filters input[type=date] { width: auto; padding: 6px 10px; font-size: 13px; }
.sugg { border-left: 2px solid var(--success); padding-left: 10px; margin: 10px 0; }

/* ===== TABLES ===== */
table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}
.tbl th, .tbl td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl th { background: var(--bg); font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.3px; }
.tbl tr:last-child td { border-bottom: none; }

/* ===== BADGES ===== */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  border-radius: 100px;
  padding: 1px 8px;
  background: var(--bg);
  color: var(--text-2);
}
.badge.admin { background: var(--accent-light); color: var(--accent); }
.badge.editor { background: var(--success-light); color: var(--success); }
.badge.contributor { background: var(--warning-light); color: var(--warning); }
.badge.off { background: var(--danger-light); color: var(--danger); }

/* ===== INLINE FORMS (qty, etc) ===== */
.qtyform { display: inline-flex; align-items: center; gap: 4px; }
.qtyform input { width: 60px; text-align: center; padding: 4px; font-size: 13px; }

/* ===== DIALOGS ===== */
dialog { border: none; border-radius: var(--radius-lg); max-width: 380px; width: 92%; padding: 20px; box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgba(0,0,0,.3); }

/* ===== ITEM CARD ACTIONS (collapsible) ===== */
.item-actions { margin-top: 8px; }
.item-actions-toggle {
  font-size: 12px;
  color: var(--text-3);
  cursor: pointer;
  font-weight: 500;
  padding: 4px 0;
  list-style: none;
}
.item-actions-toggle::-webkit-details-marker { display: none; }
.item-actions-toggle::before { content: ''; }
.item-actions-body { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

/* ===== PAGINATION ===== */
.paging {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 0;
  font-size: 13px;
}
.paging a {
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all var(--transition);
}
.paging a:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.paging-info { color: var(--text-3); }

/* ===== DASHBOARD ===== */
.dash-welcome {
  margin-bottom: 24px;
}
.dash-welcome h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.3px;
}
.dash-welcome .org {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 2px;
}

.dash-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
@media (max-width: 600px) {
  .dash-grid { grid-template-columns: repeat(2, 1fr); }
}
.dash-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.dash-stat .num {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}
.dash-stat .num.warn { color: var(--warning); }
.dash-stat .label {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: 500;
}

.dash-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.dash-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin: 0 0 10px;
}

.activity-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.activity-row:last-child { border-bottom: none; }
.activity-row .activity-text { flex: 1; color: var(--text-2); }
.activity-row .activity-text b { color: var(--text); font-weight: 500; }
.activity-row .activity-text em { color: var(--text); font-style: normal; font-weight: 500; }
.activity-row .activity-time { color: var(--text-3); font-size: 12px; flex-shrink: 0; margin-left: 12px; }

/* ===== ORG NAME (header) ===== */
.org-name { font-size: 12px; opacity: .7; margin-left: 4px; }

/* ===== MAP VIEW ===== */
/* (kept from existing — these are map-specific and work fine) */
#map-wrap { position: relative; overflow: hidden; background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--border); margin-bottom: 12px; touch-action: pan-x pan-y; }
#map-zoom { position: absolute; top: 10px; right: 10px; z-index: 5; display: flex; flex-direction: column; gap: 4px; }
#map-zoom button { width: 32px; height: 32px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); font-size: 16px; font-weight: 600; color: var(--text); cursor: pointer; line-height: 1; transition: all var(--transition); }
#map-zoom button:hover { background: var(--bg); }
#lab-map { width: 100%; height: auto; display: block; cursor: grab; }
#lab-map:active { cursor: grabbing; }
.loc { cursor: pointer; }
.loc rect { transition: opacity var(--transition); }
.loc:hover rect { opacity: 0.35 !important; }
.loc.active rect { stroke: var(--text); stroke-width: 2; opacity: 0.4 !important; }

#panel-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.2); z-index: 50; }
#panel-overlay.open { display: block; }
#item-panel { position: fixed; right: -400px; top: 0; bottom: 0; width: 380px; max-width: 90vw; background: var(--surface); box-shadow: var(--shadow-lg); z-index: 51; overflow-y: auto; transition: right 200ms ease; }
#item-panel.open { right: 0; }
.panel-hdr { position: sticky; top: 0; background: var(--surface); border-bottom: 1px solid var(--border); padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; z-index: 2; }
.panel-hdr h3 { margin: 0; font-size: 15px; font-weight: 600; }
.panel-close { background: none; border: none; color: var(--text-3); font-size: 20px; cursor: pointer; padding: 0 4px; }
.panel-close:hover { color: var(--text); }
.panel-body { padding: 16px; }
.panel-type { font-size: 11px; background: var(--bg); color: var(--text-2); border-radius: 100px; padding: 2px 10px; display: inline-block; margin: 0 0 10px; font-weight: 500; }
.panel-empty { color: var(--text-3); font-size: 13px; padding: 24px 0; text-align: center; }
.panel-item { background: var(--bg); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 6px; }
.panel-item .pi-name { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.panel-item .pi-meta { font-size: 12px; color: var(--text-3); }
.panel-item .pi-meta b { color: var(--text-2); font-weight: 500; }
.panel-link { display: block; text-align: center; padding: 10px; margin-top: 12px; font-weight: 500; font-size: 13px; text-decoration: none; color: var(--accent); border: 1px solid var(--border); border-radius: var(--radius); transition: all var(--transition); }
.panel-link:hover { background: var(--accent-light); border-color: var(--accent); }
.shelf-hdr { font-size: 11px; font-weight: 600; color: var(--text-3); margin: 16px 0 6px; text-transform: uppercase; letter-spacing: 0.3px; }

.legend { display: flex; flex-wrap: wrap; gap: 10px; padding: 8px 0; }
.legend-item { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-2); }
.legend-swatch { width: 12px; height: 12px; border-radius: 3px; }
.map-stats { font-size: 12px; color: var(--text-3); margin: 6px 0 10px; }
.home-link { display: inline-block; margin-bottom: 10px; font-size: 13px; color: var(--accent); text-decoration: none; font-weight: 500; }
.map-empty-msg { text-align: center; padding: 60px 20px; color: var(--text-3); }
.map-empty-msg p { margin: 8px 0; font-size: 14px; }
.map-empty-msg a { color: var(--accent); font-weight: 500; }

@media (max-width: 600px) {
  #item-panel { width: 100%; max-width: 100%; right: -100%; bottom: 0; top: 35vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  #item-panel.open { right: 0; }
}

/* ===== MAP EDITOR ===== */
.me-wrap { display: flex; gap: 0; height: calc(100vh - 56px); margin: -24px -20px; overflow: hidden; }
.me-sidebar { width: 260px; min-width: 260px; background: var(--bg); border-right: 1px solid var(--border); padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.me-canvas-wrap { flex: 1; position: relative; overflow: hidden; background: var(--surface); }
.me-section { margin-bottom: 4px; }
.me-section h4 { font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; margin: 0 0 8px; letter-spacing: 0.3px; }
.me-field { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.me-field label { font-size: 11px; color: var(--text-2); flex-shrink: 0; }
.me-field input[type=number] { width: 52px; padding: 4px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; }
.me-field input[type=text] { flex: 1; padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.me-palette { display: flex; flex-direction: column; gap: 2px; }
.me-ptype { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; border: 2px solid transparent; transition: all var(--transition); font-size: 13px; color: var(--text); }
.me-ptype:hover { background: var(--bg); }
.me-ptype.active { border-color: var(--accent); background: var(--accent-light); }
.me-ptype .swatch { width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; }
.me-props { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.me-props h4 { margin-top: 0; }
.me-btn-row { display: flex; gap: 6px; margin-top: 8px; }
.me-btn-row button { flex: 1; }
.me-toolbar { position: absolute; top: 10px; right: 10px; display: flex; gap: 4px; z-index: 5; }
.me-toolbar button { width: 34px; height: 34px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); font-size: 15px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all var(--transition); color: var(--text); }
.me-toolbar button:hover { background: var(--bg); }
.me-toolbar button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.me-save-bar { position: absolute; top: 10px; left: 10px; z-index: 5; display: flex; gap: 8px; align-items: center; }
.me-save-bar button, .me-save-bar a.btn { padding: 6px 16px; border-radius: var(--radius); font-size: 13px; font-weight: 500; cursor: pointer; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-sm); }
.me-save-bar .btn-save { background: var(--accent); color: #fff; border-color: var(--accent); }
.me-save-bar .save-status { font-size: 12px; color: var(--text-3); }
#editor-svg { width: 100%; height: 100%; display: block; }
#editor-svg.placing { cursor: crosshair; }
.cab-selected rect, .cab-selected circle { stroke: var(--text); stroke-width: 2; stroke-dasharray: 4,2; }
.cab-ghost { opacity: .5; pointer-events: none; }
.sel-rect { fill: rgba(37,99,235,.06); stroke: var(--accent); stroke-width: 1; stroke-dasharray: 4,2; pointer-events: none; }
.me-hint { font-size: 11px; color: var(--text-3); margin-top: 4px; }

@media (max-width: 768px) {
  .me-wrap { flex-direction: column; }
  .me-sidebar { width: 100%; min-width: 0; flex-direction: row; flex-wrap: wrap; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--border); max-height: 200px; }
  .me-canvas-wrap { min-height: 400px; }
}

/* ===== LOCATIONS ===== */
.loc-breadcrumb { font-size: 13px; margin-bottom: 12px; }
.loc-breadcrumb a { color: var(--accent); text-decoration: none; font-weight: 500; }
.loc-breadcrumb span { color: var(--text-3); }
.loc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-top: 12px; }
.loc-card { background: var(--surface); border-radius: var(--radius-lg); padding: 16px; border: 1px solid var(--border); text-decoration: none; color: var(--text); display: block; transition: all var(--transition); }
.loc-card:hover { border-color: var(--accent); box-shadow: var(--shadow); text-decoration: none; }
.loc-card-icon { font-size: 24px; margin-bottom: 6px; }
.loc-card-name { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.loc-card-meta { font-size: 12px; color: var(--text-3); }
.loc-card-actions { display: flex; gap: 4px; margin-top: 8px; }
.loc-add-form { background: var(--surface); border-radius: var(--radius-lg); padding: 16px; border: 1px solid var(--border); margin-top: 12px; max-width: 500px; }
.loc-hint { font-size: 12px; color: var(--text-3); background: var(--accent-light); border-radius: var(--radius); padding: 12px 14px; margin: 12px 0; }

/* ===== KEYBOARD SHORTCUTS ===== */
.shortcuts-grid { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; font-size: 13px; }
.shortcuts-grid kbd { background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; font-size: 12px; font-family: var(--font); white-space: nowrap; }

/* ===== ONBOARDING ===== */
.onboard-wrap { max-width: 480px; margin: 60px auto; }
.onboard-step { display: none; }
.onboard-step.active { display: block; }
.onboard-progress { display: flex; gap: 8px; margin-bottom: 24px; }
.onboard-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.onboard-dot.done { background: var(--success); }
.onboard-dot.current { background: var(--accent); }

/* ===== IMPORT ===== */
.import-mapping { width: 100%; border-collapse: collapse; margin: 12px 0; }
.import-mapping th, .import-mapping td { padding: 8px; text-align: left; border-bottom: 1px solid var(--border); }
.import-mapping th { background: var(--bg); font-size: 11px; font-weight: 600; text-transform: uppercase; }
.import-preview { overflow-x: auto; margin: 12px 0; }
.import-preview table { width: 100%; border-collapse: collapse; font-size: 12px; }
.import-preview th, .import-preview td { padding: 4px 8px; border: 1px solid var(--border); white-space: nowrap; }

/* ===== AUTH PAGES (login, register, forgot, reset, password) ===== */
.auth-card {
  max-width: 400px;
  margin: 60px auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
}
.auth-card h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 4px;
  letter-spacing: -0.3px;
}
.auth-card .auth-sub {
  font-size: 13px;
  color: var(--text-3);
  margin-bottom: 20px;
}
.auth-card .auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-3);
}
.auth-card .auth-footer a { font-weight: 500; }
.auth-card .btn.primary { width: 100%; justify-content: center; }

/* ===== ADMIN PAGES ===== */
.admin-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
}
.admin-tabs a {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  border-radius: 6px 6px 0 0;
  text-decoration: none;
  white-space: nowrap;
  transition: all var(--transition);
}
.admin-tabs a:hover {
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}
.admin-tabs a.active {
  color: var(--accent);
  font-weight: 600;
  border-bottom: 2px solid var(--accent);
}

.user-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 10px;
}
.user-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.user-card-name { font-weight: 600; font-size: 14px; }
.user-card-email { font-size: 12px; color: var(--text-3); }
.user-card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* ===== SEARCH RESULTS ENHANCEMENTS ===== */
.search-count {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 12px;
  font-weight: 500;
}

/* ===== LOCATION DETAIL (single loc view) ===== */
.loc-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.loc-header .loc-icon { font-size: 24px; }
.loc-header .loc-type-badge {
  font-size: 11px;
  background: var(--bg);
  border-radius: 100px;
  padding: 2px 10px;
  color: var(--text-2);
  font-weight: 500;
}

/* ===== V2: CATEGORY BADGES ===== */
.cat-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 100px;
  padding: 2px 10px;
  background: var(--bg);
  color: var(--text-2);
}
.cat-badge .cat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ===== V2: ITEM STATUS ===== */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 100px;
  padding: 2px 10px;
}
.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.status-available { background: var(--success-light); color: var(--success); }
.status-available::before { background: var(--success); }
.status-checked_out { background: var(--warning-light); color: var(--warning); }
.status-checked_out::before { background: var(--warning); }
.status-reserved { background: var(--accent-light); color: var(--accent); }
.status-reserved::before { background: var(--accent); }
.status-maintenance { background: var(--danger-light); color: var(--danger); }
.status-maintenance::before { background: var(--danger); }
.status-depleted { background: var(--bg); color: var(--text-3); }
.status-depleted::before { background: var(--text-3); }

/* ===== V2: STOCK ALERTS ===== */
.alert-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.alert-card.alert-low { border-left: 3px solid var(--warning); }
.alert-card.alert-expiry { border-left: 3px solid var(--danger); }
.alert-card.alert-overdue { border-left: 3px solid var(--accent); }
.alert-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.alert-low .alert-icon { background: var(--warning-light); color: var(--warning); }
.alert-expiry .alert-icon { background: var(--danger-light); color: var(--danger); }
.alert-overdue .alert-icon { background: var(--accent-light); color: var(--accent); }
.alert-body { flex: 1; min-width: 0; }
.alert-title { font-size: 13px; font-weight: 600; }
.alert-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.alert-actions { flex-shrink: 0; }

/* ===== V2: NOTIFICATION BELL ===== */
.notif-btn {
  position: relative;
  background: none;
  border: none;
  color: var(--text-2);
  font-size: 18px;
  cursor: pointer;
  padding: 6px;
  margin-right: 4px;
  transition: color var(--transition);
}
.notif-btn:hover { color: var(--text); }
.notif-count {
  position: absolute;
  top: 2px;
  right: 0;
  min-width: 16px;
  height: 16px;
  border-radius: 100px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
}
.notif-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  width: 340px;
  max-height: 400px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  display: none;
}
.notif-dropdown.open { display: block; }
.notif-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
}
.notif-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  cursor: pointer;
  transition: background var(--transition);
}
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: var(--accent-light); }
.notif-item .notif-title { font-weight: 600; font-size: 13px; }
.notif-item .notif-body { color: var(--text-2); font-size: 12px; margin-top: 2px; }
.notif-item .notif-time { color: var(--text-3); font-size: 11px; margin-top: 4px; }
.notif-empty { text-align: center; padding: 24px; color: var(--text-3); font-size: 13px; }

/* ===== V2: CHECKOUT CARD ===== */
.checkout-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.checkout-card.overdue { border-left: 3px solid var(--danger); }
.checkout-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}
.checkout-info { flex: 1; min-width: 0; }
.checkout-item-name { font-weight: 600; font-size: 13px; }
.checkout-detail { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.checkout-due { flex-shrink: 0; text-align: right; }
.checkout-due .due-date { font-size: 12px; font-weight: 500; }
.checkout-due .due-date.overdue { color: var(--danger); }

/* ===== V2: GHS PICTOGRAMS ===== */
.ghs-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin: 4px 0;
}
.ghs-picto {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ghs-picto img, .ghs-picto svg {
  width: 24px;
  height: 24px;
}
.ghs-picto.large {
  width: 40px;
  height: 40px;
}
.ghs-picto.large img, .ghs-picto.large svg {
  width: 36px;
  height: 36px;
}

/* ===== V2: DYNAMIC FIELD DISPLAY ===== */
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 8px 0;
}
@media (max-width: 480px) {
  .field-grid { grid-template-columns: 1fr; }
}
.field-item {
  font-size: 12px;
}
.field-item .field-label {
  color: var(--text-3);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: 500;
}
.field-item .field-value {
  color: var(--text);
  font-weight: 500;
  margin-top: 1px;
}
.field-item .field-value a { font-weight: 500; }

/* ===== V2: ATTACHMENT INDICATOR ===== */
.attach-count {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--text-3);
}
.attach-count svg { width: 12px; height: 12px; }

/* ===== V2: BARCODE / QR ===== */
.barcode-wrap {
  text-align: center;
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius);
  margin: 8px 0;
}
.barcode-wrap img, .barcode-wrap svg {
  max-width: 160px;
}
.barcode-label {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 4px;
  font-family: monospace;
  letter-spacing: 1px;
}

/* ===== V2: SECTOR ONBOARDING ===== */
.sector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin: 16px 0;
}
.sector-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
}
.sector-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.sector-card.selected { border-color: var(--accent); background: var(--accent-light); }
.sector-card .sector-icon { font-size: 28px; margin-bottom: 8px; }
.sector-card .sector-label { font-size: 13px; font-weight: 600; }

/* ===== V2: CATEGORY MANAGEMENT (admin) ===== */
.cat-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cat-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.cat-row .cat-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cat-row .cat-name { font-weight: 600; font-size: 14px; flex: 1; }
.cat-row .cat-field-count { font-size: 12px; color: var(--text-3); }
.cat-row .cat-actions { display: flex; gap: 6px; }

.field-list {
  margin-top: 8px;
  padding-left: 24px;
}
.field-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.field-row:last-child { border-bottom: none; }
.field-row .field-type-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg);
  color: var(--text-3);
  font-weight: 600;
  text-transform: uppercase;
}
.field-row .field-flags { font-size: 11px; color: var(--text-3); }
.field-drag { cursor: grab; color: var(--text-3); }
.field-drag:active { cursor: grabbing; }

/* ===== V2: MAINTENANCE CALENDAR ===== */
.maint-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.maint-item.overdue { border-left: 3px solid var(--danger); }
.maint-item.due-soon { border-left: 3px solid var(--warning); }
.maint-type {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg);
  color: var(--text-3);
}
.maint-info { flex: 1; }
.maint-info .maint-name { font-weight: 600; font-size: 13px; }
.maint-info .maint-meta { font-size: 12px; color: var(--text-3); }
.maint-due { font-size: 12px; font-weight: 500; text-align: right; }
