/* Solestima dashboard (app.solestima.com). Tokens match site/assets/css/styles.css. */

:root {
  --ink: #0f1f33;
  --ink-2: #3d4b5c;
  --muted: #6b7686;
  --line: #e3e7ec;
  --bg: #ffffff;
  --bg-alt: #f6f8fa;
  --navy: #0f2a47;
  --sun: #ed6f25;
  --sun-dark: #da6522;
  --sun-soft: #fdeee4;
  --accent: #1d6fd8;
  --danger: #c62828;
  --danger-soft: #fdecec;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 31, 51, .06), 0 12px 32px rgba(15, 31, 51, .10);
  --font: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-heading: "Arvo", Georgia, "Times New Roman", serif;
  --font-logo: "Suez One", Georgia, serif;
  --logo-red: #e11d2a;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg-alt);
  -webkit-font-smoothing: antialiased;
}

h1 { font-family: var(--font-heading); font-weight: 700; line-height: 1.2; margin: 0 0 .4em; font-size: 1.75rem; }
p { margin: 0 0 1em; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.container { width: 100%; max-width: 1140px; margin: 0 auto; padding: 0 20px; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Header */
.app-header { background: var(--bg); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 68px; }
.header-inner form { margin: 0; }
.logo { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; }
.logo > span {
  font-family: var(--font-logo); font-size: 22px;
  color: var(--sun);
  background: linear-gradient(90deg, var(--sun), var(--logo-red));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.logo-mark { width: 28px; height: 28px; color: var(--sun); }
.header-actions { display: flex; align-items: center; gap: 12px; }

/* Hamburger toggle (dashboard, mobile only) */
.nav-toggle {
  display: none; position: relative; width: 44px; height: 44px; padding: 0;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--ink); cursor: pointer;
}
.nav-toggle-bars, .nav-toggle-bars::before, .nav-toggle-bars::after {
  position: absolute; left: 50%; width: 20px; height: 2px; margin-left: -10px;
  background: currentColor; border-radius: 1px; transition: transform .2s, opacity .2s;
}
.nav-toggle-bars { top: 50%; margin-top: -1px; }
.nav-toggle-bars::before, .nav-toggle-bars::after { content: ""; left: 0; margin-left: 0; }
.nav-toggle-bars::before { top: -6px; }
.nav-toggle-bars::after { top: 6px; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bars { background: transparent; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bars::before { transform: translateY(6px) rotate(45deg); background: var(--ink); }
.nav-toggle[aria-expanded="true"] .nav-toggle-bars::after { transform: translateY(-6px) rotate(-45deg); background: var(--ink); }
@media (prefers-reduced-motion: reduce) { .nav-toggle-bars, .nav-toggle-bars::before, .nav-toggle-bars::after { transition: none; } }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 13px 24px; border-radius: 10px;
  font: 500 16px var(--font); text-decoration: none; cursor: pointer;
  border: 2px solid transparent;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn-primary { background: var(--sun); color: #fff; }
.btn-primary:hover { background: var(--sun-dark); }
.btn-secondary { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { border-color: var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a31f1f; }
.btn-sm { padding: 8px 16px; font-size: 15px; }
.btn-block { display: flex; width: 100%; }
.btn.is-loading { position: relative; color: transparent; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 1.1em; height: 1.1em; border-radius: 50%;
  border: 2px solid #fff; border-right-color: transparent;
  animation: btn-spin .7s linear infinite;
}
.btn-secondary.is-loading::after { border-color: var(--ink); border-right-color: transparent; }
@keyframes btn-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .btn.is-loading::after { animation-duration: 2s; } }

/* Auth pages */
.auth { display: flex; justify-content: center; padding: 56px 16px 72px; }
.auth-card {
  width: 100%; max-width: 440px;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 36px 32px;
}
.auth-card form { margin-top: 24px; }
.auth-switch { margin: 24px 0 0; text-align: center; font-size: 15px; color: var(--ink-2); }

.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 500; font-size: 15px; margin-bottom: 6px; }
.field input {
  width: 100%; padding: 11px 14px;
  font: 16px var(--font); color: var(--ink);
  background: var(--bg); border: 1px solid #c9d1db; border-radius: var(--radius-sm);
}
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(29, 111, 216, .2); }
.field.has-error input { border-color: var(--danger); }
.field-hint { margin: 6px 0 0; font-size: 14px; color: var(--muted); }
.field-error { margin: 6px 0 0; font-size: 14px; color: var(--danger); }

.alert { padding: 12px 16px; border-radius: var(--radius-sm); background: var(--sun-soft); margin: 16px 0; font-size: 15px; }
.alert-error { background: var(--danger-soft); color: var(--danger); }

/* Shared bits */
h2 { font-family: var(--font-heading); font-size: 1.15rem; line-height: 1.3; margin: 0 0 .7em; }
.small { font-size: 14px; }
.nowrap { white-space: nowrap; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.alert-success { background: #e8f6ee; color: #14532d; }
.alert-inline { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.alert-inline form { margin: 0; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.actions form { margin: 0; }
.link-button { padding: 0; text-align: left; border: 0; background: none; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }
.auth-switch-tight { margin-top: 8px; }
.field select, .field textarea {
  width: 100%; padding: 10px 12px; font: 16px var(--font); color: var(--ink);
  background: var(--bg); border: 1px solid #c9d1db; border-radius: var(--radius-sm);
}
.field textarea { resize: vertical; }
.field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(29, 111, 216, .2); }
.field input[type="color"] { width: 64px; height: 44px; padding: 4px; cursor: pointer; }
.field input[type="file"] { padding: 8px; }

/* Dashboard layout */
.dash { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 40px; padding-top: 32px; padding-bottom: 64px; }
.dash-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 24px; align-self: start; }
.dash-nav a { padding: 8px 12px; border-radius: var(--radius-sm); color: var(--ink-2); text-decoration: none; font-weight: 500; }
.dash-nav a:hover { background: var(--bg); color: var(--ink); }
.dash-nav a[aria-current="page"] { background: var(--bg); color: var(--ink); box-shadow: inset 3px 0 0 var(--sun); }
.dash-main > .alert:first-child { margin-top: 0; }
.trial-note { font-size: 14px; color: var(--muted); margin: 0 0 8px; }
.flash { margin-top: 20px; margin-bottom: 0; }

.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.page-head h1 { margin: 0; }

.panel { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin: 0 0 24px; }
.panel > :last-child { margin-bottom: 0; }
.panel h2:not(:first-child) { margin-top: 28px; }
.panel > input[type="hidden"]:first-child + h2 { margin-top: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.panel-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; margin-bottom: 24px; }
.panel-grid .panel { margin: 0; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 20px 0 24px; }
.stat { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.stat-label { display: block; font-size: 14px; color: var(--muted); }
.stat-value { display: block; font-size: 2rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }

/* Overview "Get set up" links */
.setup .panel-head form { margin: 0; }
.setup-steps { list-style: none; padding: 0; margin: 0 -12px; }
.setup-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--ink); text-decoration: none;
}
.setup-row:hover { background: var(--bg-alt); }
.setup-text { flex: 1; min-width: 0; }
.setup-label { display: block; font-weight: 500; }
.setup-optional { font-size: 14px; font-weight: 400; color: var(--muted); }
.setup-hint { display: block; font-size: 14px; color: var(--muted); }
.setup-arrow { flex: none; font-size: 24px; line-height: 1; color: var(--muted); }

.copy-field { display: flex; gap: 8px; margin-bottom: 12px; }
.copy-field input { flex: 1; min-width: 0; padding: 8px 12px; font: 14px var(--font); border: 1px solid #c9d1db; border-radius: var(--radius-sm); background: var(--bg-alt); }
.code { display: block; width: 100%; margin: 4px 0 10px; padding: 10px 12px; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; border: 1px solid #c9d1db; border-radius: var(--radius-sm); background: var(--bg-alt); resize: vertical; }
.preview { display: flex; align-items: center; min-height: 84px; padding: 18px; margin-bottom: 16px; border: 1px dashed #c9d1db; border-radius: var(--radius-sm); background: var(--bg-alt); }
.preview > div { flex: 1; }
.share { display: flex; justify-content: space-between; gap: 24px; align-items: center; }
.share > div { flex: 1; min-width: 0; }
.qr { flex: none; border: 1px solid var(--line); border-radius: var(--radius-sm); }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); }
.panel .table-wrap { border: 0; border-radius: 0; margin: 0 -24px -24px; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; font-size: 13px; font-weight: 500; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--bg-alt); }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 500; background: var(--bg-alt); color: var(--ink-2); white-space: nowrap; }
.badge-new { background: #e7f0fd; color: #1d4ed8; }
.badge-contacted { background: var(--sun-soft); color: #9a3412; }
.badge-quoted { background: #f3e8ff; color: #6b21a8; }
.badge-won { background: #e8f6ee; color: #14532d; }
.badge-lost { background: var(--danger-soft); color: var(--danger); }

.filters { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: 12px; align-items: end; margin: 20px 0 8px; }
.filters .field { margin: 0; }
.filters .field input, .filters .field select { padding: 8px 10px; font-size: 15px; }
.filters-actions { display: flex; align-items: center; gap: 12px; padding-bottom: 4px; }
#leads-results { transition: opacity .15s; }
#leads-results.is-loading { opacity: .5; pointer-events: none; }
.pager { display: flex; justify-content: center; gap: 24px; margin: 20px 0; font-size: 15px; }

.status-form { display: flex; align-items: center; gap: 8px; margin: 0; }
.status-form label { font-size: 14px; color: var(--muted); }
.status-form select { padding: 7px 10px; font: 15px var(--font); border: 1px solid #c9d1db; border-radius: var(--radius-sm); }
.details { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0; }
.details dt { color: var(--muted); font-size: 14px; padding-top: 1px; }
.details dd { margin: 0; overflow-wrap: anywhere; }

#incentives-hint {margin-bottom: 12px;}
/* Settings forms */
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.field-row-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0 12px; }
.check { display: block; position: relative; padding-left: 27px; margin: 0 0 10px; cursor: pointer; }
.check input { position: absolute; left: 0; top: .2em; width: 17px; height: 17px; margin: 0; accent-color: var(--sun); }
.input-money { position: relative; }
.input-money span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.field .input-money input { padding-left: 26px; }
.radio-group, .area-states { border: 0; padding: 0; margin: 0 0 20px; }
.radio-group legend, .area-states legend { font-weight: 500; margin-bottom: 10px; }
.state-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0 12px; }
.state-grid .check { font-size: 15px; margin-bottom: 6px; }
.logo-row { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.logo-row form { margin: 0; }
.logo-preview { display: flex; align-items: center; justify-content: center; min-width: 160px; height: 72px; padding: 8px 16px; border: 1px dashed #c9d1db; border-radius: var(--radius-sm); }
.logo-preview img { max-height: 56px; max-width: 220px; }
.logo-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-width: 0; }
.file-picker {
  display: inline-flex; align-items: center; gap: 12px; min-width: 0; max-width: 100%;
  padding: 4px 14px 4px 4px; cursor: pointer;
  background: var(--bg); border: 1px solid #c9d1db; border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
.file-picker:hover { border-color: var(--ink); }
.file-picker-btn {
  flex: none; padding: 6px 12px; border-radius: 6px;
  background: var(--bg-alt); color: var(--ink); font-weight: 500; font-size: 15px;
}
.file-picker:hover .file-picker-btn { background: var(--line); }
.file-picker-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; color: var(--muted); }
.file-picker-name.has-file { color: var(--ink); }
.file-input:focus-visible + .file-picker { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(29, 111, 216, .2); }

/* Admin */
.admin { padding-top: 32px; padding-bottom: 64px; }
.admin .stats { grid-template-columns: repeat(4, 1fr); }
.admin .stat .small { display: block; margin-top: 2px; }
.tabs { display: flex; gap: 4px; }
.tabs a { padding: 6px 12px; border-radius: var(--radius-sm); color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: 15px; }
.tabs a:hover { background: var(--bg-alt); color: var(--ink); }
.tabs a[aria-current="page"] { background: var(--bg-alt); color: var(--ink); }

@media (max-width: 900px) {
  .dash { grid-template-columns: minmax(0, 1fr); gap: 20px; padding-top: 20px; }
  .nav-toggle { display: inline-block; }
  .dash { position: relative; }
  .dash-nav {
    display: none; position: absolute; z-index: 20; top: 8px; left: 16px; right: 16px;
    padding: 8px; background: var(--bg); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
  }
  .dash-nav.is-open { display: flex; }
  .dash-nav a { padding: 12px 14px; font-size: 16px; }
  .dash-nav a[aria-current="page"] { background: var(--sun-soft); }
  .panel-grid { grid-template-columns: minmax(0, 1fr); }
  .admin .stats { grid-template-columns: repeat(2, 1fr); }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .field:first-child { grid-column: 1 / -1; }
  .field-row-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .auth { padding: 32px 16px 48px; }
  .stats, .admin .stats { grid-template-columns: 1fr; gap: 10px; }
  .stat-value { font-size: 1.6rem; }
  .panel { padding: 18px 16px; }
  .panel .table-wrap { margin: 0 -16px -18px; }
  .share { flex-direction: column; align-items: flex-start;gap:8px; }
  .details { grid-template-columns: 1fr; gap: 2px; }
  .details dd { margin-bottom: 8px; }
  .field-row { grid-template-columns: 1fr; }
  .auth-card { padding: 28px 20px; }
  .container { padding: 0 16px; }
  .container.dash {margin-bottom:32px;margin-top:18px;}
  .logo-preview { width: 100%; min-width: 0; }
  .logo-preview img { max-width: 100%; }

  /* Lead tables become one card per lead */
  .lead-table, .lead-table tbody { display: block; }
  .lead-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .lead-table tr {
    display: grid; grid-template-columns: auto auto 1fr auto; gap: 2px 14px;
    grid-template-areas: "name name name status" "address address address address" "bill system date date";
    padding: 14px 16px; border-bottom: 1px solid var(--line);
  }
  .lead-table tr:last-child { border-bottom: 0; }
  .lead-table td { display: block; padding: 0; border: 0; text-align: left; overflow-wrap: anywhere; }
  .lead-table .lt-name { grid-area: name; font-weight: 500; }
  .lead-table .lt-name .small { font-weight: 400; }
  .lead-table .lt-status { grid-area: status; }
  .lead-table .lt-address { grid-area: address; color: var(--ink-2); font-size: 14px; }
  .lead-table .lt-bill { grid-area: bill; font-size: 14px; }
  .lead-table .lt-bill::before { content: "Bill "; color: var(--muted); }
  .lead-table .lt-system { grid-area: system; font-size: 14px; }
  .lead-table .lt-date { grid-area: date; justify-self: end; font-size: 14px; color: var(--muted); }
}

/* Billing */
.price-line { margin: 8px 0 4px; }
.price-line .price-amount { font-family: var(--font-heading); font-size: 2rem; font-weight: 700; }
.meter { height: 10px; background: var(--bg-alt); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; margin: 0 0 10px; }
.meter-fill { display: block; height: 100%; background: var(--sun); border-radius: 999px; }
.meter-fill.is-over { background: var(--danger); }
