/* Allywebsite application styles — designed for /app/ */

:root {
  --bg: #f3f6fb;
  --bg-elevated: #ffffff;
  --bg-soft: #e8eef8;
  --ink: #152033;
  --ink-muted: #5b6b84;
  --line: #d5deec;
  --line-strong: #b8c5d9;
  --brand: #1d4ed8;
  --brand-ink: #1e3a8a;
  --brand-soft: #dbe7ff;
  --accent: #c45c26;
  --accent-soft: #f8ebe3;
  --danger: #b42318;
  --danger-soft: #fceceb;
  --warn: #9a6700;
  --warn-soft: #fff6db;
  --ok: #1d4ed8;
  --ok-soft: #dbe7ff;
  --shadow: 0 10px 30px rgba(21, 32, 51, 0.06);
  --radius: 14px;
  --radius-sm: 10px;
  --font: "DM Sans", "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, serif;
  --sidebar: 248px;
  --focus: 0 0 0 3px rgba(29, 78, 216, 0.28);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #d7e4ff 0%, transparent 55%),
    radial-gradient(900px 420px at 100% 0%, #e8eef8 0%, transparent 50%),
    var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-ink); }
img { max-width: 100%; display: block; }
.hidden { display: none !important; }
.muted { color: var(--ink-muted); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

.skip-link {
  position: absolute; left: -999px; top: 0; background: var(--ink); color: #fff;
  padding: 0.6rem 1rem; z-index: 1000;
}
.skip-link:focus { left: 0.75rem; top: 0.75rem; }

.brand-wordmark {
  font-family: var(--display);
  font-weight: 650;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  color: var(--brand-ink);
  margin: 0;
  text-decoration: none;
}

/* Boot */
.boot-screen {
  min-height: 100vh;
  display: grid;
  place-content: center;
  gap: 0.75rem;
  text-align: center;
}
.boot-mark {
  font-family: var(--display);
  font-size: 2rem;
  color: var(--brand-ink);
  animation: rise 0.6s ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* Auth */
.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
}
.auth-shell {
  width: min(1040px, 100%);
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 2rem;
  align-items: center;
}
.auth-headline {
  font-family: var(--display);
  font-weight: 560;
  font-size: clamp(1.8rem, 3vw, 2.5rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 1rem 0 0.75rem;
  max-width: 18ch;
  animation: rise 0.7s ease both;
}
.auth-support {
  color: var(--ink-muted);
  max-width: 38ch;
  margin: 0;
  animation: rise 0.8s ease both;
}
.auth-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  animation: rise 0.65s ease both;
}
.auth-form-wrap h2 {
  margin: 0 0 1rem;
  font-size: 1.25rem;
}
.auth-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-top: 1rem;
  align-items: center;
}

label {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
  font-size: 0.92rem;
  font-weight: 500;
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.8rem;
}
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}
textarea { min-height: 120px; resize: vertical; }

.form-error { color: var(--danger); margin: 0 0 0.75rem; font-size: 0.92rem; }
.form-success { color: var(--ok); margin: 0 0 0.75rem; font-size: 0.92rem; }

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.7rem 1.1rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--bg-soft);
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); }
.btn-secondary { background: #fff; border-color: var(--line-strong); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.linkish {
  background: none; border: none; padding: 0; color: var(--brand-ink);
  font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
}

/* Shell */
.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
}
.sidebar {
  background: rgba(255,255,255,0.94);
  backdrop-filter: blur(10px);
  border-right: 1px solid var(--line);
  padding: 1.1rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.15rem 0.45rem 0.35rem;
}
.side-nav {
  display: grid;
  gap: 0.28rem;
  flex: 1;
  align-content: start;
}
.side-nav a {
  text-decoration: none;
  color: var(--ink);
  padding: 0.58rem 0.8rem;
  border-radius: 10px;
  font-weight: 560;
  font-size: 0.95rem;
  line-height: 1.35;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.15s ease, color 0.15s ease;
}
.side-nav a:hover,
.side-nav a:focus-visible {
  background: var(--bg-soft);
  color: var(--brand-ink);
}
.side-nav a.active {
  background: var(--brand-soft);
  color: var(--brand-ink);
}
.nav-badge {
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  min-width: 1.25rem;
  height: 1.25rem;
  display: inline-grid;
  place-items: center;
  font-size: 0.7rem;
  padding: 0 0.3rem;
}
.sidebar-foot { display: grid; gap: 0.5rem; }
.credit-pill {
  background: var(--brand-soft);
  color: var(--brand-ink);
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
  font-weight: 650;
  font-size: 0.9rem;
  text-align: center;
}

.shell-main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(243,246,251,0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
}
.topbar-title {
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 560;
  flex: 1;
}
.main {
  padding: 0.35rem 1.5rem 2.5rem;
  width: 100%;
  max-width: none;
  box-sizing: border-box;
}
.icon-btn {
  border: 1px solid var(--line);
  background: #fff;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1.2rem;
}
.mobile-only { display: none; }

/* Content primitives */
.page-hero {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.85rem;
  align-items: end;
  margin-bottom: 1.1rem;
}
.page-hero h1 {
  font-family: var(--display);
  font-size: clamp(1.55rem, 2.4vw, 2rem);
  margin: 0;
  letter-spacing: -0.02em;
  color: var(--brand-ink);
}
.lead { color: var(--ink-muted); margin: 0.35rem 0 0; max-width: 52ch; }

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.stack { display: grid; gap: 1rem; }

.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem;
}
.panel h2, .panel h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 650;
}
.panel-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.panel-title-row h2, .panel-title-row h3 { margin: 0; }

.credit-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.credit-hero .balance {
  font-family: var(--display);
  font-size: 3rem;
  line-height: 1;
  color: var(--brand-ink);
}
.help-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
}
.help-tile {
  text-align: left;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  border-radius: 12px;
  padding: 0.9rem;
  cursor: pointer;
  font-weight: 600;
}
.help-tile:hover { border-color: var(--brand); background: var(--brand-soft); }

.list { display: grid; gap: 0.55rem; }
.list-item {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
}
.list-item:last-child { border-bottom: 0; padding-bottom: 0; }
.list-item:first-child { padding-top: 0; }
.list-item a { color: inherit; text-decoration: none; font-weight: 650; }
.list-item a:hover { color: var(--brand-ink); }

.site-card {
  display: grid;
  gap: 0.55rem;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #fff, var(--bg-soft));
}
.site-card + .site-card { margin-top: 0.65rem; }
.site-card-top {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: start;
}
.site-card-host {
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: -0.01em;
  word-break: break-word;
}
.site-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.55rem;
}
.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: 999px;
  padding: 0.22rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 650;
  background: var(--bg-soft);
  color: var(--brand-ink);
  border: 1px solid var(--line);
}
.meta-chip.ok { background: var(--ok-soft); }
.meta-chip.warn { background: var(--warn-soft); color: var(--warn); }
.site-url {
  color: var(--ink-muted);
  font-size: 0.88rem;
  word-break: break-all;
}
.site-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.15rem;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.8rem;
  font-weight: 650;
  background: var(--bg-soft);
  white-space: nowrap;
}
.status::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: currentColor;
}
.status-submitted, .status-needs_review { color: var(--warn); background: var(--warn-soft); }
.status-in_progress, .status-diagnosing, .status-approved { color: var(--brand-ink); background: var(--brand-soft); }
.status-waiting_for_customer, .status-estimate_ready { color: var(--accent); background: var(--accent-soft); }
.status-completed { color: var(--ok); background: var(--ok-soft); }
.status-cancelled, .status-declined { color: var(--danger); background: var(--danger-soft); }

.empty {
  padding: 1.25rem 0.25rem;
  color: var(--ink-muted);
}
.empty strong { display: block; color: var(--ink); margin-bottom: 0.25rem; }

.package-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
}
.package {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  background: #fff;
  display: grid;
  gap: 0.35rem;
}
.package.popular { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.package .price {
  font-family: var(--display);
  font-size: 1.8rem;
  color: var(--brand-ink);
}
.package .meta { color: var(--ink-muted); font-size: 0.92rem; }

.wizard-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.wizard-steps span {
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  background: var(--bg-soft);
  color: var(--ink-muted);
  font-size: 0.85rem;
  font-weight: 600;
}
.wizard-steps span.active { background: var(--brand-soft); color: var(--brand-ink); }

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
th, td {
  text-align: left;
  padding: 0.7rem 0.5rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th { color: var(--ink-muted); font-weight: 650; font-size: 0.8rem; text-transform: uppercase; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}
.filters input, .filters select { width: auto; min-width: 140px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}
.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem;
}
.stat .n {
  font-family: var(--display);
  font-size: 1.8rem;
  line-height: 1;
  margin-top: 0.35rem;
}
.stat .l { color: var(--ink-muted); font-size: 0.85rem; font-weight: 650; text-transform: uppercase; }

.timeline { display: grid; gap: 0.65rem; }
.timeline-item {
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 0.7rem;
}
.timeline-item::before {
  content: "";
  width: 10px;
  height: 10px;
  margin-top: 0.4rem;
  border-radius: 50%;
  background: var(--brand);
}
.msg {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 0.95rem;
  background: #fafafa;
}
.msg.admin { background: #f4f4f5; border-color: #e4e4e7; }
.msg.customer { background: #fff; }
.msg.system {
  background: transparent;
  border: 0;
  text-align: center;
  color: var(--ink-muted);
  font-size: 0.85rem;
  padding: 0.35rem;
}
.msg .meta { color: var(--ink-muted); font-size: 0.82rem; margin-bottom: 0.35rem; }
.msg .author { font-weight: 700; color: var(--ink); margin-right: 0.35rem; }
.msg.internal, .msg.private {
  border-style: solid;
  background: #fff7ed;
  border-color: #fed7aa;
}
.composer-note {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}
.vault-group { display: grid; gap: 0.75rem; margin-bottom: 1.25rem; }
.vault-group h3 { margin: 0 0 0.35rem; font-size: 1rem; }
.secret-mask {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.08em;
}
.share-list { display: grid; gap: 0.45rem; }
.share-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.welcome-banner {
  background: linear-gradient(135deg, var(--brand-soft), #fff 55%, var(--accent-soft));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem 1.25rem;
  margin-bottom: 1rem;
}
.welcome-banner ol { margin: 0.5rem 0 0; padding-left: 1.15rem; color: var(--ink-muted); }

.profile-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  background: var(--warn-soft);
  border: 1px solid #efd9a4;
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.95rem;
  margin-bottom: 1rem;
  color: #6b4e00;
  font-weight: 600;
  font-size: 0.95rem;
}

.auth-notice {
  margin: 0.85rem 0 0;
  padding: 0.75rem 0.9rem;
  background: var(--warn-soft);
  border: 1px solid #efd9a4;
  border-radius: var(--radius-sm);
  color: #6b4e00;
  font-size: 0.92rem;
}

.form-section-title {
  margin: 1rem 0 0.35rem;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}
.form-section-title:first-child { margin-top: 0; }

.profile-onboard-form label { margin-bottom: 0.55rem; }
.tax-field { display: grid; gap: 0.55rem; margin: 0.75rem 0; }

.task-progress-inline {
  font-size: 0.85rem;
  margin-top: 0.2rem;
}

.progress-block { display: grid; gap: 0.4rem; margin-bottom: 0.85rem; }
.progress-label { font-weight: 600; font-size: 0.95rem; }
.progress-track {
  height: 8px;
  background: var(--bg-soft);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--brand);
  border-radius: inherit;
  transition: width 0.25s ease;
}

.checklist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}
.checklist li {
  display: grid;
  grid-template-columns: 1.25rem 1fr;
  gap: 0.55rem;
  align-items: start;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.checklist li.done { background: var(--ok-soft); border-color: #c7d7ff; }
.checklist .check-mark {
  font-weight: 700;
  color: var(--brand-ink);
  line-height: 1.4;
}

.attach-list { display: grid; gap: 0.45rem; margin-bottom: 0.85rem; }
.attach-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.attach-upload {
  margin-top: 0.5rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 0.55rem;
}

.note {
  background: var(--accent-soft);
  border: 1px solid #efd3c2;
  border-radius: 12px;
  padding: 0.85rem 1rem;
  color: #6a3414;
}

/* Toast / modal */
.toast-region {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  display: grid;
  gap: 0.5rem;
  z-index: 80;
  width: min(360px, calc(100vw - 2rem));
}
.toast {
  background: var(--ink);
  color: #fff;
  border-radius: 12px;
  padding: 0.8rem 0.95rem;
  box-shadow: var(--shadow);
  animation: rise 0.25s ease both;
}
.toast.error { background: var(--danger); }

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(21, 32, 43, 0.45);
}
.modal-panel {
  position: relative;
  width: min(560px, 100%);
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  max-height: min(85vh, 800px);
  overflow: auto;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1rem 0.25rem;
}
.modal-head h2 { margin: 0; font-size: 1.15rem; }
.modal-body { padding: 0.75rem 1rem 1.15rem; }

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(21,32,43,0.35);
  z-index: 35;
}

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

@media (max-width: 960px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand { text-align: left; }
  .grid-3, .help-grid, .package-grid, .stat-grid { grid-template-columns: 1fr 1fr; }
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, 300px);
    z-index: 40;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
  }
  .sidebar.open { transform: none; }
  .mobile-only { display: inline-grid; place-items: center; }
  .main, .topbar { padding-inline: 1.1rem; }
}

@media (max-width: 640px) {
  .grid-2, .grid-3, .help-grid, .package-grid, .stat-grid { grid-template-columns: 1fr; }
  .main { padding-inline: 1rem; padding-bottom: 2rem; }
  .credit-hero { flex-direction: column; align-items: start; }
  .topbar-title { font-size: 1.15rem; }
  .site-card-top { flex-direction: column; }
}
