/* ---- APP SHELL ---- */
.app-body {
  display: flex;
  min-height: 100vh;
  background: var(--bg-dark);
}

/* ---- SIDEBAR ---- */
.sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  padding: 1.5rem 1rem;
}

.sidebar-logo {
  margin-bottom: 2.5rem;
  padding: 0 0.5rem;
}

.logo-link {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
}

.logo-hq {
  color: var(--accent);
}

.nav-links {
  list-style: none;
  flex: 1;
}

.nav-links li {
  margin-bottom: 4px;
}

.nav-links a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.nav-links a:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.nav-links a.active {
  background: var(--accent-glow);
  color: var(--accent-bright);
}

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

.sidebar-footer {
  padding: 0.5rem;
}

.sidebar-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 6px 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.sidebar-badge .dot {
  width: 6px;
  height: 6px;
  background: var(--hivis);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

/* ---- MAIN CONTENT ---- */
.main-content {
  flex: 1;
  margin-left: 220px;
  padding: 2.5rem 2rem;
  min-height: 100vh;
}

/* ---- PAGE HEADER ---- */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2rem;
}

.page-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

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

.header-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

/* ---- BUTTONS ---- */
.btn-primary {
  display: inline-block;
  background: var(--accent);
  color: #0f1116;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: var(--radius);
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
  transition: opacity 0.15s;
}

.btn-primary:hover { opacity: 0.9; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-ghost {
  display: inline-block;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 500;
  padding: 10px 16px;
  border-radius: var(--radius);
  text-decoration: none;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.15s, color 0.15s;
}

.btn-ghost:hover {
  border-color: rgba(255,255,255,0.15);
  color: var(--text-primary);
}

.btn-accent {
  display: inline-block;
  background: var(--hivis);
  color: #0f1116;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: var(--radius);
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
  transition: opacity 0.15s;
}

.btn-accent:hover { opacity: 0.9; }

.btn-sm {
  padding: 6px 12px;
  font-size: 0.82rem;
}

/* ---- STATS GRID ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.stat-card.stat-accent { border-color: var(--accent-glow); }
.stat-card.stat-hivis { border-color: var(--hivis-glow); }

.stat-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}

.stat-card.stat-accent .stat-value { color: var(--accent); }
.stat-card.stat-hivis .stat-value { color: var(--hivis); }

.stat-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ---- SECTION HEADER ---- */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.section-header h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.15rem;
  font-weight: 600;
}

.link-muted {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
}

.link-muted:hover { color: var(--accent); }

/* ---- QUOTES TABLE ---- */
.quotes-table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

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

.quotes-table thead tr {
  background: var(--bg-elevated);
}

.quotes-table th {
  padding: 10px 16px;
  text-align: left;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 600;
}

.quotes-table td {
  padding: 13px 16px;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}

.quotes-table tr:hover td { background: var(--bg-elevated); }

.td-num { color: var(--text-muted); font-size: 0.85rem; }
.td-title { font-weight: 500; }
.td-muted { color: var(--text-secondary); }
.td-total { font-family: 'Space Grotesk', sans-serif; font-weight: 600; color: var(--accent); }

/* ---- STATUS BADGES ---- */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-draft { background: var(--bg-elevated); color: var(--text-muted); }
.status-sent { background: var(--accent-glow); color: var(--accent-bright); }
.status-accepted { background: var(--hivis-glow); color: var(--hivis); }
.status-expired { background: rgba(239,68,68,0.12); color: #f87171; }

/* ---- FILTER TABS ---- */
.filter-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  width: fit-content;
}

.filter-tabs a {
  display: inline-block;
  padding: 7px 16px;
  border-radius: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.filter-tabs a:hover { color: var(--text-primary); }
.filter-tabs a.active { background: var(--bg-elevated); color: var(--text-primary); }

/* ---- EMPTY STATE ---- */
.empty-state {
  text-align: center;
  padding: 5rem 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.empty-state h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ---- QUOTE BUILDER ---- */
.builder-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 1.5rem;
  align-items: start;
}

.builder-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
}

.form-section {
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.form-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.form-section-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1.25rem;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-group {
  margin-bottom: 1rem;
}

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

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  padding: 10px 12px;
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.15s;
  appearance: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

/* ---- LINE ITEMS ---- */
.template-shortcuts {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.template-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.template-chip {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 100px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  padding: 4px 12px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, color 0.15s;
}

.template-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.line-items {
  min-height: 60px;
}

.empty-items {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 1.5rem;
  background: var(--bg-elevated);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
}

.line-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 8px;
  transition: border-color 0.15s;
}

.line-item:hover { border-color: rgba(255,255,255,0.12); }

.line-item-main {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.line-item-nums {
  display: grid;
  grid-template-columns: 80px 120px auto 1fr auto;
  gap: 8px;
  align-items: center;
}

.li-type, .li-desc, .li-qty, .li-price {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  padding: 7px 10px;
  font-size: 0.88rem;
  font-family: inherit;
  width: 100%;
}

.li-type:focus, .li-desc:focus, .li-qty:focus, .li-price:focus {
  outline: none;
  border-color: var(--accent);
}

.li-gst {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text-muted);
  font-size: 0.82rem;
  white-space: nowrap;
  cursor: pointer;
}

.li-gst input { width: auto; }

.li-total {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  color: var(--accent);
  font-size: 0.95rem;
  text-align: right;
}

.li-remove {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
  transition: color 0.15s;
}

.li-remove:hover { color: #ef4444; }

/* ---- TOTALS BOX ---- */
.totals-box {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-top: 1rem;
  max-width: 320px;
  margin-left: auto;
}

.total-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.total-grand {
  border-top: 1px solid var(--border);
  margin-top: 8px;
  padding-top: 12px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
}

/* ---- FORM ACTIONS ---- */
.form-actions {
  display: flex;
  gap: 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  margin-top: 1.5rem;
}

/* ---- BUILDER SIDEBAR ---- */
.builder-sidebar {
  position: sticky;
  top: 2rem;
}

.sidebar-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.sidebar-card h4 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

/* ---- MODAL ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,17,22,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 480px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.modal-header h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
}

.modal-close:hover { color: var(--text-primary); }

/* ---- TOAST ---- */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 20px;
  font-size: 0.9rem;
  z-index: 9999;
  max-width: 360px;
  animation: slideUp 0.2s ease;
}

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

.toast-success { border-color: var(--hivis); color: var(--hivis); }
.toast-error   { border-color: #ef4444; color: #f87171; }

/* ---- RESPONSIVE ---- */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 1.5rem 1rem; }
  .builder-layout { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .line-item-nums { grid-template-columns: 70px 100px auto 1fr auto; }
  .form-grid-2 { grid-template-columns: 1fr; }
}
