/* ═══════════════════════════════════════════════════════════════════════════
   Seamless Building – Global Stylesheet
   Primary: #C9A24D  |  Secondary / Background: #0F0F0F
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --primary:        #C9A24D;
  --primary-hover:  #b8903b;
  --primary-light:  #f5e9cc;
  --secondary:      #0F0F0F;
  --surface:        #1a1a1a;
  --surface-2:      #242424;
  --surface-3:      #2e2e2e;
  --border:         #3a3a3a;
  --text:           #f0f0f0;
  --text-muted:     #9a9a9a;
  --text-inverse:   #0F0F0F;
  --success:        #4caf7d;
  --warning:        #ffb347;
  --danger:         #e05252;
  --info:           #5b9bd5;
  --radius:         8px;
  --radius-lg:      12px;
  --shadow:         0 2px 8px rgba(0,0,0,0.5);
  --shadow-lg:      0 8px 32px rgba(0,0,0,0.6);
  --transition:     0.2s ease;
  --sidebar-w:      260px;
  --header-h:       60px;
  --font:           'Avenir Next', 'Avenir', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

html { font-size: 13px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--secondary);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

ul, ol { list-style: none; }

button { cursor: pointer; font-family: inherit; }

input, textarea, select {
  font-family: inherit;
  font-size: 0.9375rem;
}

/* ── Typography ─────────────────────────────────────────────────────────────── */
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.375rem; font-weight: 600; }
h3 { font-size: 1.125rem; font-weight: 600; }
h4 { font-size: 1rem;     font-weight: 600; }

/* ── Layout ─────────────────────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo-icon {
  width: 40px; height: 40px;
  background: var(--primary);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-inverse);
  font-size: 1.25rem;
  font-weight: 800;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.2;
  color: var(--text);
}

.sidebar-logo-text span {
  display: block;
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}

.sidebar-section-label {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
  padding: 20px 20px 6px;
  font-weight: 700;
  margin-top: 8px;
}

.sidebar-section-label:first-child {
  margin-top: 0;
  padding-top: 16px;
}

.sidebar-section-label:not(:first-child) {
  border-top: 1px solid var(--border);
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-muted);
  border-radius: 0;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  border-left: 3px solid transparent;
  position: relative;
}

.sidebar-nav a:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.sidebar-nav a.active {
  background: rgba(201,162,77,0.12);
  color: var(--primary);
  border-left-color: var(--primary);
}

.sidebar-nav a .nav-icon {
  width: 20px; text-align: center;
  font-size: 1rem;
}

.sidebar-nav a .nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
}

.sidebar-user:hover { background: var(--surface-2); }

.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--text-inverse);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 0.72rem;
  color: var(--primary);
  font-weight: 500;
}

/* ── Main Content ────────────────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Top Header ─────────────────────────────────────────────────────────────── */
.top-header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  transition: all var(--transition);
  position: relative;
}

.icon-btn:hover { background: var(--surface-3); color: var(--text); }

.icon-btn .badge {
  position: absolute;
  top: -4px; right: -4px;
  width: 16px; height: 16px;
  background: var(--danger);
  border-radius: 50%;
  font-size: 0.6rem;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 700;
}

/* ── Page Body ───────────────────────────────────────────────────────────────── */
.page {
  padding: 28px 32px;
  flex: 1;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}

.page-header-text h1 { margin-bottom: 4px; }

.page-header-text p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ── Cards ───────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.card + .card { margin-top: 20px; }

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

.card-body {
  /* Content area inside a .card, below .card-header */
}

.card-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
}

/* ── Detail Grid (bid detail page) ─────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.detail-value {
  font-size: 0.9rem;
  color: var(--text);
  word-break: break-word;
}

/* ── Stats Grid ─────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius);
  background: rgba(201,162,77,0.15);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.stat-info h3 {
  font-size: 1.625rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-info p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: var(--text-inverse);
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface-3); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #c44040; }

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover { background: #3a9460; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-icon { padding: 9px; }

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9375rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  text-transform: capitalize;
}

.form-control::placeholder { color: var(--text-muted); text-transform: none; }

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(201,162,77,0.15);
}

.form-control.error { border-color: var(--danger); }

.form-error {
  font-size: 0.78rem;
  color: var(--danger);
  margin-top: 4px;
}

.form-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

textarea.form-control {
  min-height: 100px;
  resize: vertical;
  text-transform: none;
}

textarea.form-control::first-letter { text-transform: uppercase; }

select.form-control { text-transform: none; }

.form-control[name="postcode"],
.form-control[data-format="postcode"] {
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-control[name="phone"],
.form-control[data-format="phone"] {
  letter-spacing: 0.02em;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

/* ── Client Cards ────────────────────────────────────────────────────────────── */
.client-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.client-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
  display: flex;
  flex-direction: column;
  gap: 0;
}

.client-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.client-card-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}

.client-card-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(201, 162, 77, 0.18);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}

.client-card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.client-card-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
  min-width: 0;
}

.client-card-row i {
  width: 14px;
  text-align: center;
  flex-shrink: 0;
  color: var(--text-muted);
}

.client-card-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.client-card-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

/* ── Notes ───────────────────────────────────────────────────────────────────── */
.note-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}

.note-item:last-child {
  margin-bottom: 0;
}

/* ── Tables ─────────────────────────────────────────────────────────────────── */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

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

thead {
  background: var(--surface-2);
}

thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
tbody tr.drag-over { outline: 2px solid var(--primary); outline-offset: -2px; background: var(--surface-2); }
tbody tr[draggable="true"] { cursor: default; }
tbody tr[draggable="true"] .drag-handle { cursor: grab; }
tbody tr[draggable="true"]:active .drag-handle { cursor: grabbing; }

tbody td {
  padding: 14px 16px;
  font-size: 0.875rem;
  color: var(--text);
  vertical-align: middle;
}

/* ── Badges / Pills ──────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge-primary  { background: rgba(201,162,77,0.2);  color: var(--primary);  }
.badge-success  { background: rgba(76,175,125,0.2); color: var(--success);  }
.badge-warning  { background: rgba(255,179,71,0.2);  color: var(--warning);  }
.badge-danger   { background: rgba(224,82,82,0.2);   color: var(--danger);   }
.badge-info     { background: rgba(91,155,213,0.2);  color: var(--info);     }
.badge-muted    { background: var(--surface-3);       color: var(--text-muted); }

/* ── Modal ──────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
  animation: fadeIn 0.15s ease;
}

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

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s ease;
}

@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-lg { max-width: 760px; }
.modal-xl { max-width: 960px; }

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

.modal-header h2 { font-size: 1.1rem; }

.modal-close {
  width: 32px; height: 32px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  transition: all var(--transition);
}

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

.modal-body { padding: 24px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* ── Toast Notifications ────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 280px;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
  animation: slideRight 0.25s ease;
}

@keyframes slideRight { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.toast.success { border-left: 4px solid var(--success); }
.toast.error   { border-left: 4px solid var(--danger); }
.toast.info    { border-left: 4px solid var(--info); }
.toast.warning { border-left: 4px solid var(--warning); }

.toast-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }
.toast.success .toast-icon { color: var(--success); }
.toast.error   .toast-icon { color: var(--danger); }
.toast.info    .toast-icon { color: var(--info); }
.toast.warning .toast-icon { color: var(--warning); }

.toast-body { flex: 1; }
.toast-title { font-size: 0.875rem; font-weight: 600; margin-bottom: 2px; }
.toast-msg   { font-size: 0.8rem; color: var(--text-muted); }

/* ── Search / Filter Bar ────────────────────────────────────────────────────── */
.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-input-wrap .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 9px 14px 9px 38px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.875rem;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
}

/* ── Tabs ───────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
  gap: 4px;
}

.tab-btn {
  padding: 10px 18px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: all var(--transition);
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Documents Area ──────────────────────────────────────────────────────────── */
.doc-explorer {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 20px;
  min-height: 500px;
}

.folder-tree {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  overflow-y: auto;
}

.folder-tree-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-muted);
  transition: background var(--transition);
}

.folder-tree-item:hover { background: var(--surface-2); color: var(--text); }
.folder-tree-item.active { background: rgba(201,162,77,0.12); color: var(--primary); }

.folder-tree-item .folder-arrow {
  font-size: 0.7rem;
  transition: transform var(--transition);
  width: 12px;
}

.folder-tree-item.expanded .folder-arrow { transform: rotate(90deg); }

.folder-children {
  padding-left: 20px;
}

.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.doc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
}

.doc-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(201,162,77,0.15);
}

.doc-card-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
}

.doc-card-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-card-size {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.doc-card-autosave {
  font-size: 0.68rem;
  color: var(--success);
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.drop-zone.dragover {
  border-color: var(--primary);
  background: rgba(201,162,77,0.05);
  color: var(--primary);
}

.drop-zone-icon { font-size: 3rem; margin-bottom: 12px; }

/* ── Settings Hub ─────────────────────────────────────────────────────────────── */
.settings-hub {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 16px;
  max-width: 900px;
}

.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}

.settings-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 16px rgba(201,162,77,0.15);
  transform: translateY(-2px);
}

.settings-card-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.settings-card-body {
  flex: 1;
}

.settings-card-body h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 4px;
  color: var(--text-primary);
}

.settings-card-body p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}

.settings-card-arrow {
  color: var(--text-muted);
  font-size: 0.9rem;
  flex-shrink: 0;
}

/* ── Chat ────────────────────────────────────────────────────────────────────── */
.chat-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: calc(100vh - var(--header-h) - 56px);
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.chat-list {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-list-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-list-scroll {
  flex: 1;
  overflow-y: auto;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.chat-item:hover { background: var(--surface-2); }
.chat-item.active { background: rgba(201,162,77,0.1); }

.chat-item-info { flex: 1; min-width: 0; }

.chat-item-name {
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-preview {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.chat-item-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.chat-unread {
  background: var(--primary);
  color: var(--text-inverse);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 0.68rem;
  font-weight: 700;
}

.chat-window {
  display: flex;
  flex-direction: column;
  background: var(--secondary);
}

.chat-window-header {
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message-group {
  display: flex;
  gap: 10px;
}

.message-group.own { flex-direction: row-reverse; }

.msg-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--text-inverse);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
  align-self: flex-end;
}

.message-group.own .msg-avatar { background: var(--surface-3); }

.msg-bubble {
  max-width: 70%;
}

.msg-sender {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.message-group.own .msg-sender { text-align: right; }

.msg-text {
  background: var(--surface-2);
  border-radius: 12px 12px 12px 2px;
  padding: 10px 14px;
  font-size: 0.875rem;
  line-height: 1.5;
  word-break: break-word;
}

.message-group.own .msg-text {
  background: rgba(201,162,77,0.2);
  border-radius: 12px 12px 2px 12px;
}

.msg-time {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 3px;
}
.message-group.own .msg-time { text-align: right; }

.chat-typing-indicator {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 0 20px 8px;
  height: 20px;
}

.chat-input-area {
  padding: 14px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 10px 16px;
  color: var(--text);
  font-size: 0.9rem;
  resize: none;
  max-height: 120px;
  outline: none;
  transition: border-color var(--transition);
}

.chat-input:focus { border-color: var(--primary); }

.chat-send-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--primary);
  border: none;
  color: var(--text-inverse);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  transition: all var(--transition);
  flex-shrink: 0;
}

.chat-send-btn:hover { background: var(--primary-hover); }

/* ── Login Page ──────────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--secondary);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo-icon {
  width: 64px; height: 64px;
  background: var(--primary);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-inverse);
  margin: 0 auto 14px;
}

.login-logo h1 {
  font-size: 1.375rem;
  color: var(--text);
}

.login-logo p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.login-error {
  background: rgba(224,82,82,0.1);
  border: 1px solid rgba(224,82,82,0.3);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: var(--danger);
  font-size: 0.875rem;
  margin-bottom: 18px;
  display: none;
}

.login-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ── Empty State ─────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state-icon { font-size: 3rem; margin-bottom: 14px; }
.empty-state h3 { font-size: 1.1rem; color: var(--text); margin-bottom: 6px; }
.empty-state p  { font-size: 0.875rem; margin-bottom: 20px; }

/* ── Status colour helpers ─────────────────────────────────────────────────── */
.status-enquiry   { color: var(--info);    }
.status-quoted    { color: var(--warning); }
.status-accepted  { color: var(--success); }
.status-rejected  { color: var(--danger);  }
.status-active    { color: var(--success); }
.status-on-hold   { color: var(--warning); }
.status-completed { color: var(--primary); }
.status-cancelled { color: var(--danger);  }

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .form-row, .form-row-3 {
    grid-template-columns: 1fr;
  }
  .doc-explorer {
    grid-template-columns: 1fr;
  }
  .chat-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .page { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-header { flex-direction: column; }
}

/* ── Scrollbar ────────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Utility ─────────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-primary { color: var(--primary); }
.text-muted  { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.text-right { text-align: right; }
.font-bold { font-weight: 700; }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
