/* ===== Albario Estimate — Claymorphism Design System ===== */

:root {
  --sidebar: #2f4a45;
  --sidebar-deep: #23372f;
  --gold: #e0a83d;
  --gold-deep: #c6902b;
  --bg: #eef1ec;
  --surface: #ffffff;
  --ink: #223029;
  --ink-soft: #5c6d66;
  --danger: #c2564a;
  --success: #3f8f6b;
  --radius-lg: 26px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --shadow-raised: 10px 10px 22px rgba(33, 48, 41, 0.12), -10px -10px 22px rgba(255, 255, 255, 0.85);
  --shadow-raised-sm: 6px 6px 14px rgba(33, 48, 41, 0.1), -6px -6px 14px rgba(255, 255, 255, 0.8);
  --shadow-inset: inset 5px 5px 10px rgba(33, 48, 41, 0.12), inset -5px -5px 10px rgba(255, 255, 255, 0.7);
  --shadow-dark-raised: 8px 8px 18px rgba(0, 0, 0, 0.28), -6px -6px 16px rgba(255, 255, 255, 0.05);
  --font-display: "Segoe UI", "Poppins", system-ui, sans-serif;
  --font-body: "Segoe UI", system-ui, -apple-system, sans-serif;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

* { box-sizing: border-box; }

* {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 28 28'%3E%3Cpath d='M9.2 7.3 L9.2 18.5 L12.2 15.6 L12.6 15.5 L17.4 15.5 Z' fill='%23E0A93D' stroke='%232A423D' stroke-width='1' stroke-linejoin='round'/%3E%3C/svg%3E") 15 12, auto !important;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; margin: 0; padding: 0; }
button { font-family: inherit; }

/* ---------- Shell layout ---------- */

.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 264px;
  flex-shrink: 0;
  background: linear-gradient(160deg, var(--sidebar) 0%, var(--sidebar-deep) 100%);
  color: #eef3f0;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: relative;
  overflow: hidden;
}

.sidebar::before {
  content: "";
  position: absolute;
  top: -60px;
  right: -60px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(224, 168, 61, 0.35), transparent 70%);
}

.sidebar-logo {
  display: flex;
  justify-content: center;
  z-index: 1;
  text-align: center !important;
}

.sidebar-logo img {
  height: 52px;
  width: auto;
}

.sidebar-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 22px 16px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: var(--shadow-dark-raised);
  z-index: 1;
  transition: background 0.2s ease, transform 0.2s ease;
}

.sidebar-profile:hover {
  background: rgba(255, 255, 255, 0.09);
  transform: translateY(-2px);
}

.sidebar-profile.active {
  background: rgba(224, 168, 61, 0.16);
  box-shadow: var(--shadow-dark-raised), 0 0 0 1.5px rgba(224, 168, 61, 0.5);
}

.avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--sidebar-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 22px;
  box-shadow: var(--shadow-dark-raised);
  border: 3px solid rgba(255, 255, 255, 0.25);
}

.avatar-img {
  object-fit: cover;
  background: var(--gold);
}

.avatar-preview {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto;
  display: block;
  box-shadow: var(--shadow-raised-sm);
  border: 4px solid var(--bg);
}

.avatar-preview-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gold);
  color: var(--sidebar-deep);
  font-weight: 700;
  font-size: 40px;
}

.sidebar-profile .name { font-weight: 600; letter-spacing: 0.02em; }
.sidebar-profile .role {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(238, 243, 240, 0.6);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 1;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-radius: var(--radius-md);
  color: rgba(238, 243, 240, 0.75);
  font-weight: 500;
  transition: all 0.25s ease;
  position: relative;
}

.nav a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  transform: translateX(3px);
}

.nav a.active {
  color: var(--sidebar-deep);
  background: var(--gold);
  box-shadow: var(--shadow-dark-raised);
  font-weight: 600;
}

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

.nav-section-label {
  padding: 16px 16px 6px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold);
}

.upload-preview-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.upload-preview-thumb {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 72px;
}

.upload-preview-thumb img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 10px;
  box-shadow: var(--shadow-raised-sm);
}

.upload-preview-doc {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 10px;
  background: var(--surface-2, #f0efe9);
  font-size: 28px;
  box-shadow: var(--shadow-raised-sm);
}

.upload-preview-remove {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--danger);
  cursor: pointer;
}

a.upload-preview-thumb {
  text-decoration: none;
}

.boiler-water-form h3 {
  margin: 26px 0 12px;
  font-size: 16px;
}

.boiler-water-title {
  margin: 0 0 20px;
  font-size: 20px;
}

.boiler-water-table th,
.boiler-water-table td {
  white-space: nowrap;
}

.boiler-cell-input {
  width: 100%;
  min-width: 90px;
  padding: 6px 8px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--bg);
  box-shadow: var(--shadow-inset);
  font-size: 13px;
  color: var(--ink);
}

.boiler-cell-input:focus {
  outline: none;
  box-shadow: var(--shadow-inset), 0 0 0 2px rgba(224, 168, 61, 0.35);
}

.boiler-chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 18px;
}

.boiler-chart-card h4 {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.boiler-bar-chart {
  height: 110px;
  gap: 8px;
}

.boiler-bar-chart .bar {
  width: 20px;
}

.boiler-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 12px;
  font-size: 11px;
  color: var(--ink-soft);
}

.boiler-chart-legend span { display: inline-flex; align-items: center; }

.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--bg);
  color: var(--ink-soft);
  box-shadow: var(--shadow-raised-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

.icon-btn:hover {
  color: var(--ink);
  transform: translateY(-2px);
}

.icon-btn-view { color: #2f9e6e; }
.icon-btn-view:hover { background: #e1f6ec; color: #1f7a54; }

.icon-btn-edit { color: #d99a2b; }
.icon-btn-edit:hover { background: #fdf0d9; color: #b87d1b; }

.icon-btn-reports { color: #3d8fb0; }
.icon-btn-reports:hover { background: #e0f2f8; color: #2c7290; }

.icon-btn-print { color: #8265c9; }
.icon-btn-print:hover { background: #ece6fa; color: #6b4bb3; }

.icon-btn-chat { color: #3d6fb0; }
.icon-btn-chat:hover { background: #e1eaf8; color: #2c5490; }

.plan-chat {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.plan-chat-messages {
  display: flex;
  flex-direction: column;
  gap: 2px;
  height: 64vh;
  min-height: 380px;
  overflow-y: auto;
  padding: 8px 8px 8px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--gold) transparent;
}

.plan-chat.compact .plan-chat-messages {
  height: 420px;
  min-height: 0;
}

.report-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.report-chat-head h2 { margin: 0; font-size: 18px; }
.report-chat-head .subtitle { color: var(--ink-soft); font-size: 13px; margin-top: 2px; }

.plan-chat-messages::-webkit-scrollbar { width: 6px; }
.plan-chat-messages::-webkit-scrollbar-track { background: transparent; }
.plan-chat-messages::-webkit-scrollbar-thumb { background: var(--gold); border-radius: 999px; }

.chat-msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-top: 2px;
}

.chat-msg-row.group-start { margin-top: 14px; }
.chat-msg-row.theirs { justify-content: flex-start; }
.chat-msg-row.mine { justify-content: flex-end; }

.chat-avatar {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--sidebar);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.chat-msg-col {
  display: flex;
  flex-direction: column;
  max-width: 68%;
}

.chat-msg-row.mine .chat-msg-col { align-items: flex-end; }
.chat-msg-row.theirs .chat-msg-col { align-items: flex-start; }

.chat-sender-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-soft);
  margin: 0 4px 3px;
}

.chat-bubble {
  position: relative;
  background: var(--bg);
  color: var(--ink);
  border-radius: 18px;
  padding: 9px 14px;
  box-shadow: var(--shadow-raised-sm);
  animation: fadeSlideIn 0.2s ease both;
}

.chat-msg-row.theirs .chat-bubble { border-bottom-left-radius: 18px; }
.chat-msg-row.theirs .chat-bubble.tail { border-bottom-left-radius: 5px; }

.chat-msg-row.mine .chat-bubble {
  background: linear-gradient(160deg, var(--sidebar) 0%, var(--sidebar-deep) 100%);
  color: #eef3f0;
  border-bottom-right-radius: 18px;
}

.chat-msg-row.mine .chat-bubble.tail { border-bottom-right-radius: 5px; }

.chat-bubble-body {
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-msg-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 3px 4px 0;
  font-size: 11px;
  color: var(--ink-soft);
}

.chat-edit-trigger {
  border: none;
  background: none;
  padding: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--gold-deep);
  cursor: pointer;
}

.chat-edit-trigger:hover { text-decoration: underline; }

.chat-edit-row textarea {
  width: 100%;
  min-width: 200px;
  padding: 8px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-inset);
  font-size: 14px;
  resize: vertical;
}

.chat-edit-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.chat-error {
  font-size: 13px;
  color: var(--danger);
}

.chat-readonly-note {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: #fbe9e6;
  color: var(--danger);
  font-size: 13px;
  text-align: center;
}

.plan-chat-input {
  display: flex;
  gap: 10px;
  align-items: center;
  border-top: 1px solid rgba(33, 48, 41, 0.08);
  padding-top: 14px;
}

.plan-chat-input textarea {
  flex: 1;
  padding: 12px 18px;
  border: none;
  border-radius: 999px;
  background: var(--bg);
  box-shadow: var(--shadow-inset);
  font-size: 14px;
  color: var(--ink);
  resize: none;
  max-height: 120px;
}

.plan-chat-input textarea:focus {
  outline: none;
  box-shadow: var(--shadow-inset), 0 0 0 3px rgba(224, 168, 61, 0.35);
}

.chat-send-btn {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--gold);
  color: var(--sidebar-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-raised-sm);
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.chat-send-btn svg { width: 18px; height: 18px; }

.chat-send-btn:hover:not(:disabled) { transform: scale(1.06); }

.chat-send-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.icon-btn-delete,
.icon-btn-danger { color: #d1655a; }
.icon-btn-delete:hover,
.icon-btn-danger:hover { background: #fbe9e6; color: var(--danger); }

.icon-btn-wrap {
  position: relative;
  display: inline-flex;
}

.icon-btn-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--surface);
}

.icon-tooltip {
  position: absolute;
  bottom: calc(100% + 9px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--sidebar-deep);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-dark-raised);
  border: 1px solid rgba(224, 168, 61, 0.4);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 500;
}

.icon-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--sidebar-deep);
}

.icon-btn-wrap:hover .icon-tooltip,
.icon-btn-wrap:focus-within .icon-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.sidebar-footer {
  margin-top: auto;
  z-index: 1;
}

.logout-form button {
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(238, 243, 240, 0.8);
  cursor: pointer;
  transition: all 0.2s ease;
}

.logout-form button:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }

.main {
  flex: 1;
  padding: 32px 40px 60px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  animation: fadeSlideIn 0.5s ease both;
}

.topbar h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
.topbar .subtitle { color: var(--ink-soft); font-size: 14px; margin-top: 2px; }

/* ---------- Clay surfaces ---------- */

.clay-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-raised);
  padding: 26px;
}

.clay-card.tight { padding: 18px 22px; }

.flash {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.flash .toast {
  padding: 14px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-raised-sm);
  font-size: 14px;
  font-weight: 500;
  animation: fadeSlideIn 0.4s ease both;
}

.toast.success { background: #e4f3ec; color: var(--success); }
.toast.error { background: #fbe9e6; color: var(--danger); }

.unread-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  background: linear-gradient(160deg, var(--sidebar) 0%, var(--sidebar-deep) 100%);
  color: #eef3f0;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-dark-raised);
  animation: fadeSlideIn 0.35s ease both;
}

.unread-toast strong { color: var(--gold); }

.unread-toast-icon { font-size: 16px; }

@media (max-width: 640px) {
  .unread-toast { left: 16px; right: 16px; top: 76px; }
}

/* ---------- Dashboard charts ---------- */

.chart-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr;
  gap: 22px;
  margin-bottom: 28px;
}

@media (max-width: 1100px) {
  .chart-grid { grid-template-columns: 1fr; }
}

.chart-card {
  animation: statPopIn 0.65s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.chart-card:nth-child(1) { animation-delay: 0.05s; }
.chart-card:nth-child(2) { animation-delay: 0.16s; }
.chart-card:nth-child(3) { animation-delay: 0.27s; }

.chart-card h3 { margin: 0 0 18px; font-size: 16px; }

.chart-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.chart-card-head h3 { margin: 0; }

.chart-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  color: var(--ink-soft);
}

.chart-legend.vertical {
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  margin-top: 18px;
}

.legend-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 5px;
}

.dot-teal { background: var(--sidebar); }
.dot-gold { background: var(--gold); }

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  height: 170px;
  padding-top: 4px;
}

.bar-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  height: 100%;
  justify-content: flex-end;
}

.bar-pair {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 140px;
  width: 100%;
  justify-content: center;
}

.bar {
  width: 14px;
  min-height: 3px;
  border-radius: 6px 6px 3px 3px;
  height: 0;
  animation: growBar 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  transition: opacity 0.2s ease;
}

.bar:hover { opacity: 0.75; }
.bar.purchases { background: var(--sidebar); }
.bar.estimates { background: var(--gold); }

.bar-label {
  font-size: 12px;
  color: var(--ink-soft);
}

@keyframes growBar {
  from { height: 0; }
}

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 24px;
  justify-content: center;
  flex-wrap: wrap;
}

.donut {
  --pct: 50;
  width: 148px;
  height: 148px;
  border-radius: 50%;
  background: conic-gradient(var(--sidebar) calc(var(--pct) * 1%), var(--gold) 0);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-raised-sm);
  position: relative;
}

.donut::before {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  background: var(--surface);
}

.donut-center {
  position: relative;
  text-align: center;
  z-index: 1;
}

.donut-value { font-size: 22px; font-weight: 700; color: var(--sidebar); }
.donut-caption { font-size: 11px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.05em; }

.top-products {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.top-product-row {
  display: grid;
  grid-template-columns: 100px 1fr 70px;
  align-items: center;
  gap: 12px;
}

.top-product-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-product-track {
  height: 10px;
  border-radius: 999px;
  background: var(--bg);
  box-shadow: var(--shadow-inset);
  overflow: hidden;
}

.top-product-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--sidebar), var(--gold));
  width: 0;
  animation: growWidth 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes growWidth {
  from { width: 0; }
}

.top-product-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--sidebar);
  text-align: right;
}

/* ---------- Stat tiles ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 22px;
  margin-bottom: 28px;
}

.stat-tile {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-raised);
  padding: 22px 24px;
  animation: statPopIn 0.65s cubic-bezier(0.22, 1, 0.36, 1) both;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

@keyframes statPopIn {
  0% { opacity: 0; transform: translateY(18px) scale(0.92); }
  65% { opacity: 1; transform: translateY(-3px) scale(1.02); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.stat-tile:hover { transform: translateY(-4px); box-shadow: var(--shadow-raised), 0 14px 24px rgba(33,48,41,0.1); }

.stat-tile .label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  margin-bottom: 10px;
}

.stat-tile .value { font-size: 28px; font-weight: 700; color: var(--sidebar); }
.stat-tile .value .unit { font-size: 14px; color: var(--ink-soft); font-weight: 500; margin-left: 4px; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s ease;
}

.btn-gold {
  background: var(--gold);
  color: var(--sidebar-deep);
  box-shadow: var(--shadow-raised-sm);
}

.btn-gold:hover { transform: translateY(-2px); box-shadow: 0 10px 20px rgba(224, 168, 61, 0.35); }
.btn-gold:active { transform: translateY(0); }

.btn-ghost {
  background: var(--bg);
  color: var(--ink);
  box-shadow: var(--shadow-raised-sm);
}

.btn-ghost:hover { transform: translateY(-2px); }

.btn-danger {
  background: #fbe9e6;
  color: var(--danger);
  box-shadow: var(--shadow-raised-sm);
}

.btn-danger:hover { transform: translateY(-2px); }

.btn-sm { padding: 7px 14px; font-size: 13px; border-radius: var(--radius-sm); }

/* ---------- Forms ---------- */

.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field input:not([type="checkbox"]):not([type="radio"]),
.field select,
.field textarea {
  width: 100%;
  padding: 13px 16px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--bg);
  box-shadow: var(--shadow-inset);
  font-size: 14px;
  color: var(--ink);
  transition: box-shadow 0.2s ease;
}

.field input:not([type="checkbox"]):not([type="radio"]):focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  box-shadow: var(--shadow-inset), 0 0 0 3px rgba(224, 168, 61, 0.35);
}

.field textarea { resize: vertical; min-height: 90px; }

.field input[type="checkbox"],
.field input[type="radio"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  accent-color: var(--gold-deep);
  cursor: pointer;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0 20px;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); }

table.clay-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 640px;
}

.clay-table thead th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  padding: 14px 18px;
  background: var(--bg);
}

.clay-table thead th:first-child { border-top-left-radius: var(--radius-md); border-bottom-left-radius: var(--radius-md); }
.clay-table thead th:last-child { border-top-right-radius: var(--radius-md); border-bottom-right-radius: var(--radius-md); }

.clay-table tbody tr {
  animation: fadeSlideIn 0.4s ease both;
  transition: background 0.2s ease;
}

.clay-table tbody tr:hover { background: #f6f8f5; }

.clay-table tbody tr.row-overdue { background: #fbe9e6; }
.clay-table tbody tr.row-overdue:hover { background: #f8dcd7; }

.clay-table tbody tr.row-deleted { opacity: 0.55; }
.clay-table tbody tr.row-deleted:hover { background: transparent; }

.clay-table td {
  padding: 16px 18px;
  border-bottom: 1px solid #eef1ec;
  font-size: 14px;
}

.clay-table tbody tr:last-child td { border-bottom: none; }

.row-actions { display: flex; gap: 8px; }

.pill {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.pill-gold { background: #fbeed3; color: var(--gold-deep); font-size: 10px; }
.pill-teal { background: #e3ede9; color: var(--sidebar); }
.pill-danger { background: #fbe9e6; color: var(--danger); }

span.pill.pill-gold {
  font-size: 10px;
}

/* ---------- Custom clay dropdown (replaces native <select> chrome) ---------- */

.clay-select {
  position: relative;
  width: 100%;
}

.clay-select select.clay-select-native {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
}

.clay-select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 16px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--bg);
  box-shadow: var(--shadow-inset);
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: box-shadow 0.2s ease;
}

.items-table .clay-select-trigger {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
}

.clay-select.open .clay-select-trigger,
.clay-select-trigger:focus {
  outline: none;
  box-shadow: var(--shadow-inset), 0 0 0 3px rgba(224, 168, 61, 0.35);
}

.clay-select-arrow {
  font-size: 11px;
  color: var(--gold-deep);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.clay-select.open .clay-select-arrow { transform: rotate(180deg); }

.clay-select-panel {
  position: fixed;
  z-index: 400;
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-raised);
  padding: 8px;
  display: none;
  animation: fadeSlideIn 0.18s ease both;
}

.clay-select-panel.open { display: flex; flex-direction: column; gap: 6px; }

.clay-select-search {
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--bg);
  box-shadow: var(--shadow-inset);
  font-size: 14px;
  color: var(--ink);
}

.clay-select-search:focus {
  outline: none;
  box-shadow: var(--shadow-inset), 0 0 0 3px rgba(224, 168, 61, 0.35);
}

.clay-select-options {
  max-height: 220px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--gold) transparent;
}

.clay-select-options::-webkit-scrollbar { width: 6px; }
.clay-select-options::-webkit-scrollbar-track { background: transparent; }
.clay-select-options::-webkit-scrollbar-thumb {
  background: var(--gold);
  border-radius: 999px;
}

.clay-select-empty {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--ink-soft);
}

.clay-select-option {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.clay-select-option:hover { background: #fbeed3; }

.clay-select-option.selected {
  background: var(--gold);
  color: var(--sidebar-deep);
  font-weight: 600;
}

.clay-select-option.disabled {
  color: var(--ink-soft);
  cursor: default;
  pointer-events: none;
}

/* ---------- Line item builder (purchases & estimates) ---------- */

.items-table { min-width: 720px; }
.items-table th, .items-table td { padding: 12px 10px; vertical-align: middle; }
.items-table td:first-child { min-width: 200px; }

.items-table input {
  width: 100%;
  padding: 11px 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--bg);
  box-shadow: var(--shadow-inset);
  font-size: 14px;
  color: var(--ink);
  transition: box-shadow 0.2s ease;
  appearance: none;
  -webkit-appearance: none;
}

.items-table input:focus {
  outline: none;
  box-shadow: var(--shadow-inset), 0 0 0 3px rgba(224, 168, 61, 0.35);
}

.items-table input[readonly] {
  color: var(--ink-soft);
  box-shadow: none;
  background: transparent;
}

.js-unit {
  font-size: 13px;
  color: var(--ink-soft);
  text-transform: lowercase;
}

.js-row-total {
  font-weight: 600;
  color: var(--sidebar);
}

.items-total-row td {
  font-weight: 700;
  font-size: 15px;
  padding-top: 18px;
  border-top: 2px solid var(--bg);
}

.remove-row-btn {
  background: #fbe9e6;
  color: var(--danger);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-raised-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.remove-row-btn:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 8px 16px rgba(194, 86, 74, 0.25);
}

/* ---------- Estimate / print document ---------- */

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

.doc-meta { display: grid; grid-template-columns: repeat(2, minmax(140px, 1fr)); gap: 14px 30px; font-size: 14px; }
.doc-meta dt { color: var(--ink-soft); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.doc-meta dd { margin: 0; font-weight: 600; }

.doc-total {
  display: flex;
  justify-content: flex-end;
  padding: 18px 0 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--sidebar);
}

.notes-block {
  margin-top: 26px;
  padding: 18px 22px;
  background: var(--bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-inset);
  font-size: 14px;
  min-height: 70px;
  white-space: pre-wrap;
}

.signature-block {
  margin-top: 60px;
  display: flex;
  justify-content: flex-end;
}

.signature-line {
  width: 240px;
  text-align: center;
  border-top: 2px solid var(--ink);
  padding-top: 8px;
  font-size: 13px;
  color: var(--ink-soft);
}

/* ---------- Auth page ---------- */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--sidebar) 0%, var(--sidebar-deep) 55%, #1b2b25 100%);
  position: relative;
  overflow: hidden;
}

.auth-page::before,
.auth-page::after {
  content: "";
  position: absolute;
  border-radius: 50%;
}

.auth-page::before {
  width: 340px; height: 340px;
  background: radial-gradient(circle, rgba(224,168,61,0.4), transparent 70%);
  top: -120px; left: -100px;
}

.auth-page::after {
  width: 260px; height: 260px;
  background: radial-gradient(circle, rgba(255,255,255,0.08), transparent 70%);
  bottom: -100px; right: -60px;
}

.app-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 300;
  text-align: center;
  padding: 8px 12px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(6px);
  color: var(--ink-soft);
  pointer-events: none;
}

.app-footer a {
  color: var(--gold-deep);
  font-weight: 600;
  text-decoration: none;
  pointer-events: auto;
}

.app-footer a:hover { text-decoration: underline; }

.auth-card {
  position: relative;
  z-index: 1;
  width: 380px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-raised);
  padding: 40px 36px;
  animation: fadeSlideIn 0.6s ease both;
}

.auth-brand { text-align: center; margin-bottom: 26px; }
.auth-logo {
  display: block;
  height: 44px;
  width: auto;
  margin: 0 auto 14px;
}
.auth-brand p { font-size: 13px; color: var(--ink-soft); margin: 4px 0 0; }

.auth-card .btn-gold { width: 100%; justify-content: center; margin-top: 6px; }

/* ---------- Empty state ---------- */

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--ink-soft);
}

/* ---------- Animations ---------- */

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

.stat-tile:nth-child(1) { animation-delay: 0.02s; }
.stat-tile:nth-child(2) { animation-delay: 0.08s; }
.stat-tile:nth-child(3) { animation-delay: 0.14s; }
.stat-tile:nth-child(4) { animation-delay: 0.2s; }

.clay-table tbody tr:nth-child(1) { animation-delay: 0.02s; }
.clay-table tbody tr:nth-child(2) { animation-delay: 0.06s; }
.clay-table tbody tr:nth-child(3) { animation-delay: 0.1s; }
.clay-table tbody tr:nth-child(4) { animation-delay: 0.14s; }
.clay-table tbody tr:nth-child(5) { animation-delay: 0.18s; }

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(34, 48, 41, 0.35);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-backdrop.open { display: flex; }

.modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-raised);
  padding: 28px;
  width: 340px;
  animation: fadeSlideIn 0.3s ease both;
}

.modal-box h3 { margin: 0 0 10px; }
.modal-box p { color: var(--ink-soft); font-size: 14px; margin: 0 0 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ---------- Sliding pagination ---------- */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 26px;
}

.page-arrow {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  box-shadow: var(--shadow-raised-sm);
  color: var(--ink);
  font-size: 18px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.page-arrow:hover { transform: translateY(-2px); }

.page-arrow.disabled {
  opacity: 0.35;
  pointer-events: none;
}

.pagination-track {
  display: flex;
  gap: 8px;
  max-width: 320px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scroll-behavior: smooth;
  padding: 6px 10px;
  background: var(--bg);
  border-radius: 999px;
  box-shadow: var(--shadow-inset);
  scrollbar-width: none;
}

.pagination-track::-webkit-scrollbar { display: none; }

.page-pill {
  scroll-snap-align: center;
  flex-shrink: 0;
  min-width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.page-pill:hover { background: #fbeed3; color: var(--gold-deep); }

.page-pill.active {
  background: var(--gold);
  color: var(--sidebar-deep);
  box-shadow: var(--shadow-raised-sm);
  transform: scale(1.08);
}

/* ---------- Error page ---------- */

.error-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

/* ---------- Mobile navigation (drawer) ---------- */

.mobile-topbar {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

@media (max-width: 900px) {
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 150;
    padding: 12px 16px;
    background: linear-gradient(160deg, var(--sidebar) 0%, var(--sidebar-deep) 100%);
  }

  .mobile-topbar-logo { height: 24px; width: auto; }

  .mobile-menu-btn {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border: none;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
  }

  .mobile-menu-btn span {
    display: block;
    width: 20px;
    height: 2px;
    border-radius: 2px;
    background: #eef3f0;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 190;
    background: rgba(20, 28, 24, 0.45);
    backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease;
  }

  .sidebar-backdrop.open {
    opacity: 1;
    visibility: visible;
  }

  .shell { display: block; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    overflow-y: auto;
  }

  .sidebar.open { transform: translateX(0); }

  .main { padding: 20px 16px 48px; }

  .topbar {
    flex-wrap: wrap;
    gap: 12px;
  }

  .topbar h1 { font-size: 22px; }

  .field input,
  .field select,
  .field textarea,
  .clay-select-trigger {
    font-size: 16px;
  }

  .btn { min-height: 44px; }

  .chart-grid,
  .stat-grid { grid-template-columns: 1fr; }
}

/* ---------- List search ---------- */

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  max-width: 420px;
  margin-bottom: 18px;
}

.search-box .search-icon {
  position: absolute;
  left: 16px;
  color: var(--ink-soft);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 13px 76px 13px 44px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--bg);
  box-shadow: var(--shadow-inset);
  font-size: 14px;
  color: var(--ink);
  transition: box-shadow 0.2s ease;
}

.search-box input::-webkit-search-cancel-button { display: none; }

.search-box input:focus {
  outline: none;
  box-shadow: var(--shadow-inset), 0 0 0 3px rgba(224, 168, 61, 0.35);
}

.search-box .search-clear {
  position: absolute;
  right: 12px;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-soft);
  font-size: 18px;
  line-height: 1;
}

.search-box .search-clear:hover { background: rgba(33, 48, 41, 0.08); }

.search-box .search-spinner {
  position: absolute;
  right: 44px;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(224, 168, 61, 0.3);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: search-spin 0.7s linear infinite;
}

@keyframes search-spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  .search-box { max-width: none; }
}

/* ---------- Report remarks ---------- */

.report-remarks h3 { margin: 26px 0 0; font-size: 16px; }
.report-remarks .notes-block { margin-top: 12px; }
.report-remarks-empty { color: var(--ink-soft); font-style: italic; }
