/* Cloud CRM: shared styles for the login page and the board. Follows the device's light or dark setting. */
:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #eaeef4;
  --ink: #17212f;
  --muted: #5a6879;
  --line: #d9e0ea;
  --accent: #2459c4;
  --accent-ink: #ffffff;
  --nav: #14213b;
  --nav-ink: #e9eef7;
  --warn: #a8530a;
  --warn-bg: #fdf0e0;
  --bad: #b3261e;
  --bad-bg: #fbe7e5;
  --good: #1b7a50;
  --good-bg: #e0f3ea;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-head: "Space Grotesk", "Inter", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1522;
    --surface: #172133;
    --surface-2: #1f2b40;
    --ink: #e7edf6;
    --muted: #9aa8bb;
    --line: #2a3850;
    --accent: #6c9bff;
    --accent-ink: #0b1220;
    --nav: #0a1120;
    --nav-ink: #e9eef7;
    --warn: #f0b36b;
    --warn-bg: #3a2a14;
    --bad: #ff8f86;
    --bad-bg: #3d1b1a;
    --good: #6fd3a4;
    --good-bg: #14352a;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.45;
  min-height: 100vh;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 16px 40px;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  padding: 7px 12px;
  font-weight: 500;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 3px 8px; font-size: 12px; border-radius: 6px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ---------- login page ---------- */
.login-wrap { max-width: 420px; margin: 0 auto; padding-top: 4vh; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.login-wrap .logo { width: 150px; height: auto; max-width: 60%; }
.login-wrap h1 { margin: 4px 0 0; font-family: var(--font-head); font-size: 32px; letter-spacing: 0.01em; }
.login-wrap .by { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.auth-card { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px; text-align: left; }
.auth-tabs { display: flex; gap: 4px; margin-bottom: 14px; background: var(--surface-2); border-radius: 9px; padding: 3px; }
.auth-tabs button { flex: 1; border: 0; background: transparent; border-radius: 7px; padding: 7px 10px; font-weight: 500; color: var(--muted); }
.auth-tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(8, 14, 26, 0.12); }
.auth-card form { display: flex; flex-direction: column; gap: 12px; }
.auth-card .btn.primary { padding: 9px 12px; }
.check { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.form-err { color: var(--bad); font-size: 13px; min-height: 1.2em; }
.hint { color: var(--muted); font-size: 12px; }

/* ---------- board header ---------- */
.top {
  background: var(--nav);
  color: var(--nav-ink);
  border-radius: 10px;
  padding: 12px 14px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}
.top-row { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.top-row .logo { height: 44px; width: auto; }
.who-box { display: flex; align-items: center; gap: 10px; font-size: 12px; opacity: 0.95; }
.who-box .btn { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.25); color: var(--nav-ink); }
.who-box .btn:hover { background: rgba(255,255,255,0.2); }
.brand { font-family: var(--font-head); font-weight: 700; font-size: 24px; letter-spacing: 0.01em; overflow-wrap: anywhere; }
.search {
  width: 100%;
  max-width: 440px;
  min-width: 0;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.18);
  color: var(--nav-ink);
  border-radius: 8px;
  padding: 8px 12px;
}
.search::placeholder { color: rgba(233,238,247,0.6); }

.tabs { display: flex; gap: 4px; margin: 16px 0 12px; flex-wrap: wrap; align-items: center; }
.tab { border: 1px solid transparent; background: transparent; padding: 6px 12px; border-radius: 8px; font-weight: 500; color: var(--muted); }
.tab[aria-selected="true"] { background: var(--surface); border-color: var(--line); color: var(--ink); }
.tabs .note { margin-left: auto; color: var(--muted); font-size: 12px; }
.tabs #addBtn { margin-left: 8px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-family: var(--font-head); font-weight: 700; font-size: 22px; font-variant-numeric: tabular-nums; }
.stat.alert .v { color: var(--bad); }

.banner { background: var(--surface); border: 1px dashed var(--line); border-radius: 10px; padding: 14px; margin-bottom: 14px; display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
.banner p { margin: 0; flex: 1 1 260px; }
.banner.err { border-style: solid; border-color: var(--bad); background: var(--bad-bg); }

/* ---------- board ---------- */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.col { flex: 0 0 272px; background: var(--surface-2); border-radius: 10px; padding: 8px; display: flex; flex-direction: column; gap: 8px; min-height: 160px; }
.col.over { outline: 2px dashed var(--accent); outline-offset: -2px; }
.col-head { padding: 4px 6px 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.col-head h3 { margin: 0; font-family: var(--font-head); font-size: 14px; font-weight: 700; }
.col-head .count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.col-head .sum { flex-basis: 100%; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.col-head .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); align-self: center; }
.col.s-won .dot, .col.s-ongoing .dot { background: var(--good); }
.col.s-lost .dot { background: var(--muted); }
.empty-col { color: var(--muted); font-size: 12px; text-align: center; padding: 18px 6px; border: 1px dashed var(--line); border-radius: 8px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 10px 8px; display: flex; flex-direction: column; gap: 6px; cursor: grab; min-width: 0; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.card:hover { border-color: var(--accent); }
.card.dragging { opacity: 0.4; }
.card.ghost { position: fixed; z-index: 40; pointer-events: none; margin: 0; opacity: 0.96; cursor: grabbing; transform: rotate(2deg); box-shadow: 0 10px 26px rgba(8, 14, 26, 0.3); border-color: var(--accent); }
.card .co { font-weight: 600; overflow-wrap: anywhere; }
.card .who { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { background: var(--surface-2); border-radius: 999px; padding: 1px 8px; font-size: 11px; font-weight: 500; color: var(--muted); }
.chip.ex { background: var(--warn-bg); color: var(--warn); }
.val { font-variant-numeric: tabular-nums; font-size: 12px; font-weight: 500; }
.fu { font-size: 12px; border-radius: 6px; padding: 2px 7px; background: var(--surface-2); color: var(--muted); align-self: flex-start; }
.fu.today { background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.fu.over { background: var(--bad-bg); color: var(--bad); font-weight: 600; }
.last { font-size: 11px; color: var(--muted); }
.card-actions { display: flex; gap: 4px; align-items: center; margin-top: 2px; }
.card-actions .sp { margin-left: auto; }

/* ---------- follow-ups ---------- */
.group { margin-bottom: 18px; }
.group h3 { margin: 0 0 8px; font-family: var(--font-head); font-size: 15px; }
.group h3 .count { color: var(--muted); font-weight: 500; font-family: var(--font-body); font-size: 12px; margin-left: 6px; }
.list { display: grid; gap: 8px; }
.item { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; align-items: center; }
.item .main { min-width: 0; }
.item .co { font-weight: 600; overflow-wrap: anywhere; }
.item .meta { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; user-select: text; }
.item .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.none { color: var(--muted); padding: 12px; border: 1px dashed var(--line); border-radius: 8px; }

/* ---------- modal, form fields, toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(8, 14, 26, 0.55); display: flex; align-items: flex-start; justify-content: center; padding: 24px 12px; overflow-y: auto; z-index: 20; }
.overlay[hidden] { display: none; }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; width: 100%; max-width: 560px; padding: 18px; }
.modal h2 { margin: 0 0 12px; font-family: var(--font-head); font-size: 18px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid2 .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: 12px; font-weight: 500; color: var(--muted); }
.field input, .field select, .field textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; min-width: 0; }
.field textarea { min-height: 84px; resize: vertical; }
.field .err { color: var(--bad); font-size: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; align-items: center; }
.actions .sp { margin-left: auto; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); background: var(--nav); color: var(--nav-ink); padding: 9px 14px; border-radius: 8px; z-index: 50; max-width: calc(100vw - 32px); box-shadow: 0 6px 20px rgba(0,0,0,0.25); }
.toast[hidden] { display: none; }

@media (max-width: 520px) {
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .item { grid-template-columns: minmax(0, 1fr); }
  .item .acts { justify-content: flex-start; }
  .col { flex-basis: 84vw; }
  .top-row { justify-content: center; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }

/* ---------- team, companies, quotes, small parts ---------- */
[hidden] { display: none !important; }
.tabs .filter { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; max-width: 180px; }
.mgr { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 500; color: var(--muted); }
.avatar { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 9px; font-weight: 700; letter-spacing: 0.02em; }
.sub { margin: 0 0 6px; font-family: var(--font-head); font-size: 14px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 10px; max-width: 640px; }
.panel p { margin: 0; }
.team { max-width: 760px; }
.team .err, .quotes .err { color: var(--bad); font-size: 12px; min-height: 0; }
.item.pending { border-color: var(--warn); background: var(--warn-bg); }
.item .inline { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.item .inline input { width: 64px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; }
.item select { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; max-width: 100%; }
.linkbox { margin-top: 6px; display: flex; flex-direction: column; gap: 6px; }
.linkbox input { flex: 1 1 220px; min-width: 0; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; font-size: 12px; }
.quotes { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.quote-list { display: grid; gap: 6px; }
.quote-row { display: flex; gap: 8px; align-items: center; justify-content: space-between; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.quote-row .qmain { min-width: 0; }
.quote-row a { color: var(--accent); font-weight: 500; overflow-wrap: anywhere; }
.quote-row .meta { color: var(--muted); font-size: 12px; }
.quote-add { display: grid; grid-template-columns: minmax(0, 1fr) 150px auto; gap: 8px; align-items: end; }
.quote-add input[type="file"] { font-size: 12px; padding: 5px; }
.hint.full { grid-column: 1 / -1; margin: 0; }
.linklike { border: 0; background: transparent; color: var(--accent); padding: 4px 0; font-size: 13px; text-align: center; text-decoration: underline; }
.form-ok { color: var(--good); font-size: 13px; min-height: 0; }
.notice-title { margin: 0 0 8px; font-family: var(--font-head); font-size: 18px; }
.note-line { margin: 0; line-height: 1.5; }
.login-wrap code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.login-wrap .btn { text-decoration: none; display: inline-block; }
@media (max-width: 520px) {
  .quote-add { grid-template-columns: minmax(0, 1fr); }
  .tabs .filter { max-width: 100%; }
}
