/* LCD Team CRM — design system. No external dependencies (strict CSP). */

/* ---------- tokens ---------- */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --ink: #1a222d;
  --muted: #64707d;
  --line: #e5e8ec;
  --line-strong: #d5dae0;

  --brand: #15803d;
  --brand-hover: #116632;
  --brand-soft: #ecfdf3;
  --brand-ink: #ffffff;
  --ring: rgba(21, 128, 61, .22);

  --hl: #fffaeb;
  --hl-line: #f5d998;

  --open-bg: #eff6ff;   --open-ink: #1d4ed8;
  --prog-bg: #fff7e6;   --prog-ink: #b45309;
  --rev-bg:  #fef2f2;   --rev-ink:  #b91c1c;
  --done-bg: #eef0f3;   --done-ink: #5b6470;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .07);
  --shadow-md: 0 6px 16px rgba(16, 24, 40, .09);
}

/* ---------- base ---------- */
* { box-sizing: border-box; margin: 0; }
body {
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
main { max-width: 1120px; margin: 28px auto 64px; padding: 0 20px; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; letter-spacing: -.015em; }
h2 { font-size: .95rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 30px 0 10px; font-weight: 600; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.hidden { display: none !important; }
.grow { flex: 1; } .inline { display: inline; }
code { background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; font-size: .86em; }

/* ---------- top navigation ---------- */
nav.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; gap: 4px; align-items: center;
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 0 24px; height: 54px; box-shadow: var(--shadow);
}
nav.top .brand { font-size: 1.02rem; letter-spacing: .4px; margin-right: 18px; font-weight: 600; }
nav.top .brand b { color: var(--brand); }
nav.top a:not(.brand) {
  color: var(--muted); font-weight: 500; font-size: .92rem;
  padding: 0 12px; height: 54px; display: inline-flex; align-items: center;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
nav.top a:not(.brand):hover { color: var(--ink); text-decoration: none; }
nav.top a.active { color: var(--brand); border-bottom-color: var(--brand); }
nav.top .spacer { flex: 1; }
nav.top .who { color: var(--ink); }
nav.top .who em {
  color: var(--brand); font-style: normal; font-size: .74rem; font-weight: 600;
  border: 1px solid currentColor; border-radius: 999px; padding: 1px 8px; margin-left: 6px;
  text-transform: uppercase; letter-spacing: .04em;
}
.nudge {
  background: var(--hl); border-bottom: 1px solid var(--hl-line);
  padding: 9px 24px; font-size: .9rem;
}

/* ---------- layout ---------- */
.row-head { display: flex; align-items: center; gap: 14px; margin: 6px 0 16px; }
.row-head h1 { flex: 1; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin: 12px 0;
  box-shadow: var(--shadow);
}
.card p { margin: 4px 0; }
.body-text { white-space: pre-wrap; }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.form-grid .wide { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: 5px; font-size: .84rem; font-weight: 500; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 9px; color: var(--ink); font-weight: 400; font-size: .92rem; margin: 6px 0; }
label.check input { width: auto; accent-color: var(--brand); }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 9px 11px; width: 100%;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring);
}

button {
  font: inherit; font-weight: 500; color: var(--ink);
  border: 1px solid var(--line-strong); background: var(--surface);
  border-radius: var(--radius-sm); padding: 9px 16px; cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
button:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
button.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
button.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: var(--brand-ink); }
button.full { width: 100%; margin: 6px 0; }
.small-btn { padding: 4px 11px; font-size: .82rem; }

/* sidebar: everything stacks in a single column, full-width controls */
.side-col .card { margin: 0 0 14px; }
.side-col .form-grid { grid-template-columns: 1fr; }
.side-col form:not(.form-grid) { margin: 0 0 10px; }
.side-col button { width: 100%; }
.side-col .card form { margin: 8px 0 0; }

/* ---------- filters ---------- */
.filters { display: flex; gap: 10px; margin: 12px 0 16px; }
.filters input { flex: 1; }
.filters select { width: auto; }
.filters button { flex-shrink: 0; }

/* ---------- tables ---------- */
table.tasks {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  margin: 4px 0 8px;
}
table.tasks th {
  text-align: left; font-size: .74rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted);
  padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fafbfc;
}
table.tasks td { padding: 11px 14px; border-bottom: 1px solid var(--line); }
table.tasks tr:last-child td { border-bottom: 0; }
table.tasks tbody tr:hover td, table.tasks tr:hover td { background: #fafbfc; }
table.tasks tr.hl td { background: var(--hl); }
.overdue { color: var(--rev-ink); font-weight: 600; }

/* ---------- badges & priority ---------- */
.badge {
  font-size: .76rem; font-weight: 600; padding: 3px 10px; border-radius: 999px;
  white-space: nowrap; letter-spacing: .01em;
}
.b-open { background: var(--open-bg); color: var(--open-ink); }
.b-in_progress { background: var(--prog-bg); color: var(--prog-ink); }
.b-review_requested { background: var(--rev-bg); color: var(--rev-ink); }
.b-closed { background: var(--done-bg); color: var(--done-ink); }
.cs-active { background: var(--brand-soft); color: var(--brand-hover); }
.cs-prospect { background: var(--open-bg); color: var(--open-ink); }
.cs-paused { background: var(--prog-bg); color: var(--prog-ink); }
.cs-lost { background: var(--done-bg); color: var(--done-ink); }

.pri { display: inline-block; width: 9px; height: 9px; border-radius: 50%; }
.pri-low { background: #c7cdd6; } .pri-normal { background: #60a5fa; }
.pri-high { background: #f59e0b; } .pri-urgent { background: #dc2626; }

/* ---------- comments / discussion ---------- */
.comment {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 15px; margin: 10px 0;
  box-shadow: var(--shadow);
}
.comment .meta { display: flex; align-items: center; gap: 9px; font-size: .86rem; margin-bottom: 6px; }
.comment .meta .muted { margin-left: auto; font-size: .8rem; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 27px; height: 27px; border-radius: 50%; flex-shrink: 0;
  background: var(--brand-soft); color: var(--brand-hover);
  font-weight: 700; font-size: .8rem;
}

.activity { list-style: none; padding-left: 0; font-size: .86rem; }
.activity li { padding: 6px 0 6px 14px; border-left: 2px solid var(--line); margin-left: 4px; }
.activity li + li { margin-top: 2px; }

/* ---------- status banners ---------- */
.error { background: var(--rev-bg); color: var(--rev-ink); border-radius: var(--radius-sm); padding: 9px 13px; margin: 8px 0; }
.ok { background: var(--brand-soft); color: var(--brand-hover); border-radius: var(--radius-sm); padding: 9px 13px; margin: 8px 0; }
.awaiting { background: var(--prog-bg); color: var(--prog-ink); border-radius: var(--radius-sm); padding: 9px 13px; margin: 8px 0; }
.internal { background: var(--hl); border-left: 3px solid #f59e0b; padding: 7px 11px; border-radius: 5px; }
.key-banner { background: var(--hl); }
.key-banner code { display: block; margin-top: 6px; word-break: break-all; }

/* ---------- login ---------- */
.login-box {
  max-width: 380px; margin: 12vh auto; background: var(--surface);
  border: 1px solid var(--line); border-radius: 16px; padding: 34px 30px;
  display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow-md);
}
.login-box h1 { text-align: center; font-size: 1.3rem; }
.login-box h1 b { color: var(--brand); }
.login-box form { display: flex; flex-direction: column; gap: 12px; }

/* ---------- misc ---------- */
.actions form { margin-left: 4px; }
.qr { text-align: center; padding: 8px 0; }
.qr svg { width: 200px; height: 200px; }
ul.backup { list-style: none; padding-left: 0; columns: 2; margin-top: 6px; }
ul.backup li { padding: 2px 0; }

/* ---------- mobile ---------- */
@media (max-width: 900px) {
  .cols { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  main { margin: 14px auto 40px; padding: 0 12px; }
  nav.top { flex-wrap: wrap; height: auto; padding: 8px 14px; gap: 2px 10px; }
  nav.top a:not(.brand) { height: 40px; }
  nav.top .spacer { display: none; }
  nav.top .who { margin-left: auto; }
  h1 { font-size: 1.25rem; }

  .form-grid { grid-template-columns: 1fr; }
  input, select, textarea, button { font-size: 16px; } /* stops iOS zoom-on-focus */
  .filters { flex-wrap: wrap; }
  .filters input { flex-basis: 100%; }

  /* tables become stacked cards */
  table.tasks { border: 0; background: transparent; box-shadow: none; }
  table.tasks tr:first-child { display: none; }
  table.tasks tr {
    display: block; background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); margin: 10px 0; padding: 6px 14px; box-shadow: var(--shadow);
  }
  table.tasks td {
    display: flex; justify-content: space-between; align-items: center;
    gap: 14px; padding: 7px 0; border: 0; border-bottom: 1px dashed var(--line);
  }
  table.tasks tr td:last-child { border-bottom: 0; }
  table.tasks td::before {
    content: attr(data-label); font-weight: 600; color: var(--muted);
    font-size: .74rem; text-transform: uppercase; letter-spacing: .05em;
  }
  table.tasks td:not([data-label])::before { content: ""; }
  table.tasks td[data-label="Task"] { font-size: 1.02rem; }
  table.tasks td.center { justify-content: center; }
  table.tasks tr:hover td { background: transparent; }
}
