/* ============================================================
   D³ back office — same tokens as the public site, denser layout
   ============================================================ */

:root {
  --ink: #04070c;
  --ink-2: #0a111d;
  --ice: #e7eef8;
  --muted: #7f8da3;
  --blue: #4d9fff;
  --blue-glow: #7cc0ff;
  --line: rgba(231, 238, 248, 0.1);
  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-body: "Instrument Sans", system-ui, sans-serif;
  --font-mono: "Spline Sans Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--ink);
  color: var(--ice);
  font-family: var(--font-body);
  font-size: 0.97rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ---------- shared bits ---------- */

.btn {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 0.7rem 1.4rem;
  cursor: pointer;
  transition: box-shadow 0.2s ease, background 0.2s ease;
}

.btn--solid {
  background: linear-gradient(180deg, var(--blue), #2f7fe6);
  color: #03060b;
  border: 1px solid var(--blue);
}

.btn--solid:hover {
  box-shadow: 0 0 24px rgba(77, 159, 255, 0.4);
}

.btn--ghost {
  background: transparent;
  color: var(--ice);
  border: 1px solid var(--line);
}

.btn--ghost:hover {
  border-color: var(--blue);
}

.btn--sm {
  padding: 0.5rem 1rem;
  font-size: 0.72rem;
}

.card {
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.2rem;
  margin-bottom: 1.4rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field > span {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.field input,
.field select,
.field textarea {
  background: rgba(4, 7, 12, 0.6);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  color: var(--ice);
  font-family: var(--font-body);
  font-size: 1rem; /* 16px floor prevents iOS focus zoom */
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 14px rgba(77, 159, 255, 0.2);
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0.6rem 0;
}

.hint--ok {
  color: var(--blue-glow);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- login ---------- */

.login {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(70% 50% at 50% -10%, rgba(31, 111, 235, 0.18), transparent 60%),
    var(--ink);
}

.login__card {
  width: min(360px, 100%);
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 2.2rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.login__mark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 2rem;
  color: var(--blue);
  margin: 0;
  text-shadow: 0 0 22px rgba(77, 159, 255, 0.5);
}

.login__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.3rem;
  margin: 0;
}

.login__error {
  color: #ff7d7d;
  font-size: 0.85rem;
  margin: 0;
}

/* ---------- app shell ---------- */

.app {
  display: grid;
  grid-template-columns: 215px 1fr;
  min-height: 100svh;
}

.side {
  border-right: 1px solid var(--line);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: sticky;
  top: 0;
  height: 100svh;
}

.side__mark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.4rem;
  color: var(--blue);
  margin: 0;
  padding-left: 0.6rem;
}

.side__mark span {
  display: block;
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 0.2rem;
}

.side__nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.side__nav button {
  text-align: left;
  background: none;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.side__nav button:hover {
  color: var(--ice);
}

.side__nav button.is-active {
  color: var(--blue-glow);
  border-color: var(--line);
  background: rgba(77, 159, 255, 0.08);
}

.side__logout {
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  text-align: left;
  padding: 0.5rem 0.8rem;
}

.side__logout:hover {
  color: var(--ice);
}

.main {
  padding: 2rem clamp(1.2rem, 3vw, 3rem);
  max-width: 1000px;
  min-width: 0; /* let the grid column shrink below table width */
}

/* tables scroll sideways inside their card instead of stretching the page */
#client-list,
#fin-list,
#price-list,
#quote-list {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

#client-list .table,
#fin-list .table,
#price-list .table,
#quote-list .table {
  min-width: 540px;
}

.pane__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.4rem;
}

.pane__head h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.6rem;
  margin: 0;
}

/* ---------- forms / tables ---------- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 1rem;
}

.form-grid__actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.6rem;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.table th {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  padding: 0.6rem 0.7rem;
  border-bottom: 1px solid var(--line);
}

.table td {
  padding: 0.7rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.table .num {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.rowact {
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  cursor: pointer;
  padding: 0.1rem 0.3rem;
}

.rowact:hover {
  color: var(--blue-glow);
}

.rowact--danger:hover {
  color: #ff7d7d;
}

.pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}

.pill--lead { color: var(--blue-glow); border-color: rgba(77, 159, 255, 0.4); }
.pill--active { color: #7dffb2; border-color: rgba(125, 255, 178, 0.35); }
.pill--paused { color: #ffd97d; border-color: rgba(255, 217, 125, 0.35); }
.pill--done { color: var(--muted); }

.empty {
  color: var(--muted);
  text-align: center;
  padding: 2.5rem 1rem;
  border: 1px dashed var(--line);
  border-radius: 16px;
}

/* ---------- notes ---------- */

.note-form__row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 1rem;
  margin-top: 0.9rem;
}

.field--inline {
  flex-direction: column;
}

.seg {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.seg label {
  cursor: pointer;
}

.seg input {
  position: absolute;
  opacity: 0;
}

.seg span {
  display: inline-block;
  padding: 0.45rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.seg input:checked + span {
  background: rgba(77, 159, 255, 0.15);
  color: var(--blue-glow);
}

.day {
  margin-bottom: 1.3rem;
}

.day__date {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.5rem;
}

.note {
  display: flex;
  gap: 0.8rem;
  align-items: baseline;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 0.5rem;
  background: var(--ink-2);
}

.note__text {
  flex: 1;
  white-space: pre-wrap;
}

.note__meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
}

/* ---------- finances ---------- */

.totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 1.4rem;
}

.totals__cell {
  background: var(--ink-2);
  padding: 1.1rem 1.2rem;
}

.totals__label {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.totals__num {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.7rem;
  margin-top: 0.2rem;
}

.totals__num--income { color: #7dffb2; }
.totals__num--expense { color: #ff9d7d; }
.totals__num--net { color: var(--blue-glow); }

/* ---------- agent ---------- */

.pane--agent .agent {
  display: flex;
  flex-direction: column;
  height: min(640px, calc(100svh - 180px));
  padding: 0;
  overflow: hidden;
}

.agent__log {
  flex: 1;
  overflow-y: auto;
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.agent__msg {
  max-width: 85%;
  padding: 0.65rem 0.9rem;
  border-radius: 14px;
  white-space: pre-wrap;
}

.agent__msg--user {
  align-self: flex-end;
  background: linear-gradient(180deg, var(--blue), #2f7fe6);
  color: #03060b;
  border-bottom-right-radius: 4px;
}

.agent__msg--assistant {
  align-self: flex-start;
  background: rgba(231, 238, 248, 0.07);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}

.agent__msg--system {
  align-self: center;
  color: var(--muted);
  font-size: 0.85rem;
  background: none;
}

.agent__actions {
  align-self: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.agent__chip {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--blue-glow);
  border: 1px solid rgba(77, 159, 255, 0.4);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
}

.agent__bar {
  display: flex;
  gap: 0.6rem;
  padding: 0.9rem;
  border-top: 1px solid var(--line);
}

.agent__bar input {
  flex: 1;
  min-width: 0;
  background: rgba(4, 7, 12, 0.6);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.65rem 1rem;
  color: var(--ice);
  font-size: 1rem; /* 16px floor prevents iOS focus zoom */
  font-family: var(--font-body);
}

.agent__bar input:focus {
  outline: none;
  border-color: var(--blue);
}

/* ---------- settings ---------- */

.check {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 1rem 0;
  color: var(--ice);
  cursor: pointer;
}

.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
}

#settings-form .btn {
  margin-top: 0.4rem;
}

/* ---------- pricing ---------- */

.sub-head {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  margin: 2rem 0 1rem;
}

.price-tier {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--blue-glow);
}

.calc__inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.calc__out {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.calc__cell {
  background: var(--ink-2);
  padding: 0.9rem 1rem;
}

.calc__cell .k {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.calc__cell .v {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.5rem;
  margin-top: 0.2rem;
}

.calc__cell .v.floor { color: #ffd97d; }
.calc__cell .v.suggest { color: #7dffb2; }

.quote__add {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.quote__add select {
  flex: 1;
  min-width: 12rem;
  background: rgba(4, 7, 12, 0.6);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.8rem;
  color: var(--ice);
  font-family: var(--font-body);
  font-size: 1rem;
}

.qline {
  display: grid;
  grid-template-columns: 1fr 6.5rem 6.5rem auto;
  gap: 0.6rem;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
}

.qline input {
  background: rgba(4, 7, 12, 0.6);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  color: var(--ice);
  font-family: var(--font-body);
  font-size: 0.95rem;
  width: 100%;
}

.qline .num { font-family: var(--font-mono); }

.quote__totals {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  padding: 1rem 0;
  font-family: var(--font-display);
  font-weight: 700;
}

.quote__totals b { color: var(--blue-glow); }

.quote__save {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.8rem;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}

/* ---------- small screens ---------- */

@media (max-width: 760px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr; /* header hugs content; main takes the rest */
  }

  .side {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 0.9rem 1rem;
  }

  .side__mark span {
    display: none;
  }

  .side__nav {
    flex-direction: row;
    flex-wrap: wrap;
    flex: 1 1 100%;
    order: 3;
  }

  .side__logout {
    margin-left: auto;
  }
}
