@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --brand: #2563eb;
  --brand-hover: #1d4ed8;
  --brand-light: #eff6ff;
  --brand-rgb: 37,99,235;

  --bg: #f0f2f5;
  --surface: #ffffff;
  --surface-2: #f8f9fa;
  --border: #e5e7eb;
  --border-soft: #f0f0f0;

  --text: #1e293b;
  --text-2: #475569;
  --text-muted: #94a3b8;

  --navy: #1b2a4a;
  --navy-light: #243556;
  --navy-active: #2563eb;

  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;

  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 6px;

  --shadow: 0 1px 3px rgb(0 0 0/.08);
  --shadow-md: 0 4px 12px rgb(0 0 0/.08);
  --shadow-lg: 0 8px 24px rgb(0 0 0/.12);

  --topbar-h: 64px;
  --sidebar-w: 68px;
  --sidebar-expanded: 250px;
  --transition: .2s ease;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 15px; scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--text); background: var(--bg); line-height: 1.6;
}
::selection { background: var(--brand-light); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }

/* ================================================================
   SHELL
   ================================================================ */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

/* ── TOPBAR ── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  position: sticky; top: 0; z-index: 1030;
  gap: 1rem;
}
.topbar .navbar-brand {
  font-weight: 800; font-size: 1.3rem; letter-spacing: -.03em;
  color: var(--navy) !important; text-decoration: none;
}
.topbar .navbar-brand span {
  color: var(--brand);
}

#sidebarToggle {
  width: 40px; height: 40px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: var(--radius-xs);
  background: transparent; color: var(--text-2);
  cursor: pointer; transition: all var(--transition);
  font-size: 1.2rem;
}
#sidebarToggle:hover { background: var(--surface-2); color: var(--text); }

.topbar .search-box {
  max-width: 400px; flex: 1;
  position: relative;
}
.topbar .search-box input {
  width: 100%; border: 1px solid var(--border);
  border-radius: 999px; padding: .5rem 1rem .5rem 2.5rem;
  font-size: .875rem; background: var(--surface-2);
  transition: all var(--transition); color: var(--text);
}
.topbar .search-box input::placeholder { color: var(--text-muted); }
.topbar .search-box input:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgb(var(--brand-rgb) / .1);
  background: var(--surface);
}
.topbar .search-box i {
  position: absolute; left: .875rem; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: .875rem; pointer-events: none;
}

/* ── SIDEBAR (dark, icon-only like Bidhive) ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  min-height: calc(100vh - var(--topbar-h));
  position: sticky; top: var(--topbar-h);
  flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center;
  padding: 1rem 0 !important;
  overflow: hidden;
  transition: width var(--transition);
  z-index: 1020;
}

.sidebar .sidebar-label { display: none; }

.sidebar .nav { width: 100%; padding: 0 .5rem; }
.sidebar .nav-link {
  color: rgba(255,255,255,.5);
  border-radius: var(--radius-sm);
  padding: .65rem 0;
  margin: 3px .25rem;
  font-size: .75rem; font-weight: 500;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.sidebar .nav-link i {
  font-size: 1.2rem; display: block; line-height: 1;
}
.sidebar .nav-link .nav-text {
  font-size: .6rem; letter-spacing: .02em;
}
.sidebar .nav-link:hover {
  color: rgba(255,255,255,.85);
  background: var(--navy-light);
}
.sidebar .nav-link.active {
  color: #fff;
  background: var(--navy-active);
  box-shadow: 0 2px 8px rgb(var(--brand-rgb) / .3);
}

/* Expanded sidebar (when toggled on desktop) */
.sidebar.expanded {
  width: var(--sidebar-expanded);
  align-items: stretch;
}
.sidebar.expanded .sidebar-label {
  display: block;
  font-size: .65rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .1em; color: rgba(255,255,255,.3);
  padding: .5rem 1rem; margin-bottom: 0;
}
.sidebar.expanded .nav { padding: 0 .75rem; }
.sidebar.expanded .nav-link {
  flex-direction: row; justify-content: flex-start;
  padding: .6rem .75rem; gap: 0;
  font-size: .875rem;
}
.sidebar.expanded .nav-link i {
  font-size: 1.1rem; width: 1.5rem; text-align: center;
  margin-right: .625rem;
}
.sidebar.expanded .nav-link .nav-text {
  font-size: .875rem;
}

/* ── CONTENT ── */
.content-wrap {
  flex: 1; min-width: 0; max-width: 100%;
  padding: 1.75rem 2rem !important;
}
@media (min-width: 1400px) { .content-wrap { padding: 2rem 2.5rem !important; } }
@media (min-width: 1700px) { .content-wrap { padding: 2rem 3.5rem !important; } }

/* ================================================================
   TYPOGRAPHY
   ================================================================ */
h1,.h1,h2,.h2,h3,.h3,h4,.h4,h5,.h5,h6,.h6 {
  font-weight: 700; letter-spacing: -.02em; color: var(--text); line-height: 1.3;
}
.h4 { font-size: 1.35rem; }
.h5 { font-size: 1.1rem; }
.h6 { font-size: .875rem; }
.page-title { font-size: 1.5rem; font-weight: 800; letter-spacing: -.03em; color: var(--navy); }
.page-desc { color: var(--text-2); font-size: .9rem; }

/* ================================================================
   CARDS
   ================================================================ */
.card {
  background: var(--surface); border: none;
  border-radius: var(--radius); box-shadow: var(--shadow);
  transition: box-shadow var(--transition), transform var(--transition);
}
a.card { text-decoration: none; color: inherit; }
a.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card-header {
  padding: 1rem 1.5rem; border-bottom: 1px solid var(--border-soft);
  background: var(--surface); border-radius: var(--radius) var(--radius) 0 0;
}
.card-header.bg-white { background: var(--surface) !important; }
.card-body { padding: 1.5rem; }

/* KPI cards — full-color gradient style like Bidhive */
.kpi-card { border: none; overflow: hidden; }
.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-3px); }
.kpi-card .card-body { padding: 1.5rem 1.75rem; }
.kpi-card .display-6 {
  font-size: 2.25rem; font-weight: 800; letter-spacing: -.03em; line-height: 1;
}
.kpi-card .kpi-label {
  font-size: .8rem; font-weight: 600; margin-bottom: .25rem;
}
.kpi-card .icon {
  width: 48px; height: 48px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.2rem; flex-shrink: 0;
}
.kpi-card .text-muted.small {
  font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
}
.kpi-gradient-1 { background: linear-gradient(135deg, #1e3a5f 0%, #2d5f8a 100%); color: #fff; }
.kpi-gradient-1 .display-6, .kpi-gradient-1 .kpi-label { color: #fff; }
.kpi-gradient-1 .icon { background: rgba(255,255,255,.15); color: #fff; }
.kpi-gradient-2 { background: linear-gradient(135deg, #1e3a5f 0%, #3b7dd8 100%); color: #fff; }
.kpi-gradient-2 .display-6, .kpi-gradient-2 .kpi-label { color: #fff; }
.kpi-gradient-2 .icon { background: rgba(255,255,255,.15); color: #fff; }
.kpi-gradient-3 { background: linear-gradient(135deg, #0d9488 0%, #2dd4bf 100%); color: #fff; }
.kpi-gradient-3 .display-6, .kpi-gradient-3 .kpi-label { color: #fff; }
.kpi-gradient-3 .icon { background: rgba(255,255,255,.15); color: #fff; }

/* metric mini boxes */
.metric-box {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); padding: .875rem 1rem;
  transition: all var(--transition);
}
.metric-box:hover {
  background: var(--brand-light); border-color: rgb(var(--brand-rgb) / .2);
}
.metric-box .metric-label {
  font-size: .7rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-muted);
}
.metric-box .metric-value {
  font-size: 1.4rem; font-weight: 700; letter-spacing: -.02em; color: var(--text);
}

/* ================================================================
   BUTTONS
   ================================================================ */
.btn {
  font-weight: 600; font-size: .875rem; border-radius: var(--radius-xs);
  padding: .5rem 1.125rem; transition: all var(--transition); white-space: nowrap;
}
.btn-sm { padding: .4rem .875rem; font-size: .8125rem; }
.btn-primary {
  background: var(--brand); border-color: var(--brand); color: #fff;
  box-shadow: 0 1px 3px rgb(var(--brand-rgb) / .25);
}
.btn-primary:hover {
  background: var(--brand-hover); border-color: var(--brand-hover);
  box-shadow: 0 4px 14px rgb(var(--brand-rgb) / .3); transform: translateY(-1px);
}
.btn-primary:active { transform: none; }
.btn-outline-primary { color: var(--brand); border-color: var(--brand); }
.btn-outline-primary:hover {
  background: var(--brand); border-color: var(--brand); color: #fff;
  transform: translateY(-1px);
}
.btn-outline-secondary { color: var(--text-2); border-color: var(--border); }
.btn-outline-secondary:hover { background: var(--surface-2); color: var(--text); }
.btn-outline-dark { color: var(--text); border-color: var(--border); }
.btn-outline-dark:hover { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-light { background: var(--surface-2); border-color: var(--border); color: var(--text-2); }
.btn-light:hover { background: var(--border); color: var(--text); }

/* ================================================================
   FORMS
   ================================================================ */
.form-control, .form-select {
  border-radius: var(--radius-xs); border: 1px solid var(--border);
  font-size: .875rem; padding: .5rem .875rem; color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgb(var(--brand-rgb) / .1);
}
.form-control::placeholder { color: var(--text-muted); }
.form-control-sm, .form-select-sm { font-size: .8125rem; padding: .375rem .75rem; }
.form-label { font-size: .8125rem; font-weight: 600; color: var(--text); margin-bottom: .375rem; }
.form-text { font-size: .75rem; color: var(--text-muted); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.input-group-text { background: var(--surface-2); border-color: var(--border); color: var(--text-muted); }

/* ================================================================
   TABLES
   ================================================================ */
.table { font-size: .875rem; --bs-table-bg: transparent; }
.table > thead > tr > th {
  font-weight: 600; font-size: .75rem; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-muted);
  border-bottom: 2px solid var(--border); padding: .75rem 1rem;
  white-space: nowrap; background: var(--surface);
}
.table > tbody > tr > td { padding: .75rem 1rem; border-color: var(--border-soft); vertical-align: middle; }
.table-hover > tbody > tr:hover > * { background: var(--brand-light); --bs-table-bg-state: var(--brand-light); }
.table-responsive { -webkit-overflow-scrolling: touch; }
.table-responsive:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.table-sticky thead th { position: sticky; top: 0; z-index: 4; background: var(--surface); }

/* ================================================================
   BADGES
   ================================================================ */
.badge { font-weight: 600; font-size: .7rem; padding: .35em .65em; border-radius: var(--radius-xs); }

/* ================================================================
   NAV TABS
   ================================================================ */
.nav-tabs { border-bottom: 2px solid var(--border-soft); }
.nav-tabs .nav-link {
  white-space: nowrap; color: var(--text-muted); font-weight: 500; font-size: .875rem;
  padding: .75rem 1rem; border: none; border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: all var(--transition); border-radius: 0;
}
.nav-tabs .nav-link:hover { color: var(--text); border-bottom-color: var(--border); background: transparent; }
.nav-tabs .nav-link.active {
  color: var(--brand); font-weight: 600; background: transparent;
  border-bottom-color: var(--brand);
}

/* ================================================================
   BREADCRUMB / ALERTS / MISC
   ================================================================ */
.breadcrumb { font-size: .8125rem; }
.breadcrumb-item a { color: var(--brand); text-decoration: none; }
.breadcrumb-item.active { color: var(--text-muted); }

.alert { border-radius: var(--radius); font-size: .875rem; border: 1px solid transparent; padding: 1rem 1.25rem; }
.alert-primary { background: var(--brand-light); color: var(--brand-hover); border-color: rgb(var(--brand-rgb) / .15); }
.alert-warning { background: #fefce8; color: #854d0e; border-color: #fef08a; }
.alert-success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.alert-info { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }

.step-pill {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .35rem .75rem; border: 1px solid var(--border); border-radius: 999px;
  font-size: .8125rem; font-weight: 500; color: var(--text-2); background: var(--surface);
}
.step-pill i { color: var(--brand); }

.empty-state {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 3rem 2rem; text-align: center; background: var(--surface);
}
.empty-state i { opacity: .25; }

.min-w-0 { min-width: 0 !important; }

.split-review { max-height: calc(100dvh - 200px); overflow: auto; scrollbar-width: thin; }
.photo-thumb {
  width: 100%; max-width: 180px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); object-fit: cover;
  transition: transform var(--transition); }
.photo-thumb:hover { transform: scale(1.03); box-shadow: var(--shadow-md); }
[data-copy] { color: var(--text-muted) !important; transition: color var(--transition); }
[data-copy]:hover { color: var(--brand) !important; }

.dropzone-upload {
  border: 2px dashed rgb(var(--brand-rgb) / .28);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgb(var(--brand-rgb) / .04), transparent);
  padding: 1.25rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
}
.dropzone-upload:hover,
.dropzone-upload.is-dragover {
  border-color: var(--brand);
  background: var(--brand-light);
  transform: translateY(-1px);
}
.dropzone-upload.has-files {
  border-style: solid;
}
.dropzone-upload__icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgb(var(--brand-rgb) / .1);
  color: var(--brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
}
.dropzone-file-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .5rem;
  width: 100%;
}
.file-chip {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  max-width: 100%;
  padding: .35rem .7rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: .78rem;
  color: var(--text-2);
}
.file-chip span {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
.attachment-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.attachment-preview {
  min-height: 160px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.attachment-preview img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
}
.attachment-placeholder {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: rgb(var(--brand-rgb) / .08);
  color: var(--brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
}
.attachment-card__body {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1rem;
}
.attachment-card__body > .min-w-0 {
  flex: 1;
}
.attachment-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}

.note-feed {
  display: flex;
  flex-direction: column;
  gap: .875rem;
}
.note-entry {
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: .9rem 1rem;
}
.note-entry--internal {
  border-left-color: var(--warning);
  background: #fffdf6;
}
.note-entry__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .45rem;
  margin-bottom: .45rem;
  font-size: .76rem;
  color: var(--text-muted);
}
.note-badge {
  font-size: .68rem;
}
.note-entry__body {
  font-size: .875rem;
  color: var(--text);
  white-space: normal;
  overflow-wrap: anywhere;
}

/* ================================================================
   LOADING / TOAST / COMMAND
   ================================================================ */
.global-loading {
  position: fixed; top: calc(var(--topbar-h) + 12px); right: 16px;
  z-index: 1100; display: none; align-items: center;
  padding: .5rem 1rem; border-radius: var(--radius);
  background: rgba(255,255,255,.95); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); font-size: .8125rem; font-weight: 500;
  color: var(--text-2);
  backdrop-filter: blur(12px);
}
/* loading state managed by JS directly via el.style.display */
@keyframes slideDown { from { opacity:0; transform:translateY(-8px); } to { opacity:1; transform:translateY(0); } }

.toast-container { z-index: 1090; }
.toast { border-radius: var(--radius); box-shadow: var(--shadow-lg); }

.command-list .list-group-item {
  border-left: 0; border-right: 0; padding: .75rem 1rem;
  font-size: .875rem; font-weight: 500; transition: all var(--transition);
}
.command-list .list-group-item:first-child { border-top: 0; }
.command-list .list-group-item:last-child { border-bottom: 0; }
.command-list .list-group-item:hover { background: var(--brand-light); color: var(--brand); }
.command-list .list-group-item i { color: var(--text-muted); width: 1.5rem; text-align: center; }
.command-list .list-group-item:hover i { color: var(--brand); }

.pagination .page-link {
  font-size: .8125rem; font-weight: 500; border-radius: var(--radius-xs);
  margin: 0 2px; border-color: var(--border); color: var(--text-2); padding: .375rem .7rem;
}
.pagination .page-item.active .page-link { background: var(--brand); border-color: var(--brand); }

.dropdown-menu {
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: .5rem; border: 1px solid var(--border); animation: slideDown .15s ease;
}
.dropdown-item { border-radius: var(--radius-xs); padding: .5rem .75rem; font-weight: 500; }
.dropdown-item:hover { background: var(--brand-light); color: var(--brand); }

.offcanvas { border-left: 1px solid var(--border); }
.offcanvas-header { border-bottom: 1px solid var(--border-soft); padding: 1.25rem; }
.offcanvas .list-group-item { border-color: var(--border-soft); padding: .75rem 1rem; font-weight: 500; }
.offcanvas .list-group-item:hover { background: var(--brand-light); color: var(--brand); }

.modal-content { border-radius: var(--radius); box-shadow: var(--shadow-lg); border: none; overflow: hidden; }
.modal-header { border-bottom: 1px solid var(--border-soft); padding: 1.25rem 1.5rem; }
.modal-body { padding: 1.5rem; }
.modal-footer { border-top: 1px solid var(--border-soft); padding: 1rem 1.5rem; }
.modal-title { font-weight: 700; font-size: 1.1rem; }

.login-brand {
  font-weight: 800; font-size: 1.75rem; letter-spacing: -.04em; color: var(--navy);
}
.login-brand span { color: var(--brand); }
.login-card { border: none !important; box-shadow: var(--shadow-lg) !important; border-radius: 16px !important; }

.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: .7rem; font-weight: 700;
}

/* ================================================================
   RESPONSIVE — MOBILE
   ================================================================ */
@media (max-width: 767.98px) {
  :root { --topbar-h: 56px; --sidebar-w: 0px; }
  .topbar { padding: 0 1rem; }
  .topbar .navbar-brand { font-size: 1.1rem; }
  .sidebar {
    position: fixed; left: 0; top: var(--topbar-h); z-index: 1025;
    width: 68px; height: calc(100dvh - var(--topbar-h));
    transform: translateX(-100%); transition: transform var(--transition);
  }
  .sidebar.mobile-open { transform: translateX(0); box-shadow: 4px 0 24px rgb(0 0 0/.12); }
  .content-wrap { padding: 1rem !important; }
  .card-body { padding: 1rem; }
  .card-header { padding: .875rem 1rem; }
  .h4 { font-size: 1.15rem; }
  .page-title { font-size: 1.25rem; }
  .kpi-card .display-6 { font-size: 1.5rem; }
  .kpi-card .card-body { padding: 1rem 1.25rem; }
  .nav-tabs { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .nav-tabs::-webkit-scrollbar { display: none; }
  .nav-tabs .nav-link { padding: .65rem .75rem; font-size: .8125rem; }
  .table > thead > tr > th { font-size: .675rem; padding: .5rem .75rem; }
  .table > tbody > tr > td { padding: .5rem .75rem; font-size: .8125rem; }
  .empty-state { padding: 2rem 1.25rem; }
  .split-review { max-height: none; }
  .global-loading { right: 10px; }
  .dropzone-upload { padding: 1rem; }
  .attachment-grid { grid-template-columns: 1fr; }
  .attachment-preview,
  .attachment-preview img { min-height: 140px; height: 140px; }
  .attachment-card__body { padding: .875rem; }
}

@media (max-width: 479.98px) {
  html { font-size: 14px; }
  .content-wrap { padding: .75rem !important; }
  .card-body { padding: .875rem; }
  .kpi-card .display-6 { font-size: 1.3rem; }
}

@media (min-width: 1400px) {
  .kpi-card .display-6 { font-size: 2.5rem; }
  .kpi-card .icon { width: 52px; height: 52px; }
}

@media print {
  .sidebar, .topbar, .global-loading, .toast-container, #modal-root, .offcanvas { display: none !important; }
  .content-wrap { padding: 0 !important; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}
