/* =====================================================================
   AmpliSkill CRM - stylesheet
   ===================================================================== */

:root {
  --bg:        #f6f7f9;
  --surface:   #ffffff;
  --surface-2: #f0f2f5;
  --border:    #e2e5ea;
  --border-2:  #cdd2da;
  --text:      #16181d;
  --muted:     #6b7280;
  --faint:     #9aa1ad;

  --accent:      #2563eb;
  --accent-soft: #eaf0fe;
  --accent-ink:  #1d4ed8;

  --green:  #15803d;  --green-soft:  #e6f4ea;
  --amber:  #b45309;  --amber-soft:  #fdf1de;
  --red:    #b91c1c;  --red-soft:    #fdeaea;
  --purple: #6d28d9;  --purple-soft: #f1ebfd;
  --slate:  #475569;  --slate-soft:  #eef1f5;

  --radius:  10px;
  --radius-s: 7px;
  --shadow:   0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  --shadow-l: 0 10px 32px rgba(16,24,40,.14);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #0f1115;
    --surface:   #171a21;
    --surface-2: #1e222b;
    --border:    #2a2f3a;
    --border-2:  #3a4150;
    --text:      #e8eaee;
    --muted:     #9aa3b2;
    --faint:     #6b7484;

    --accent-soft: #1b2740;
    --green-soft:  #16281c;
    --amber-soft:  #2c2110;
    --red-soft:    #2e1616;
    --purple-soft: #241a3a;
    --slate-soft:  #20252e;

    --green: #4ade80; --amber: #fbbf24; --red: #f87171;
    --purple: #c4b5fd; --slate: #cbd5e1; --accent: #60a5fa; --accent-ink: #93c5fd;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    --shadow-l: 0 12px 36px rgba(0,0,0,.55);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.011em; }

/* ---------------- login ---------------- */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, var(--accent-soft), var(--bg));
}
.login-card {
  width: 100%; max-width: 380px; text-align: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 40px 32px; box-shadow: var(--shadow-l);
}
.login-mark {
  width: 52px; height: 52px; margin: 0 auto 18px; border-radius: 14px;
  background: var(--accent); color: #fff; font-size: 24px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.login-card h1 { font-size: 21px; }
.login-sub { color: var(--muted); margin: 6px 0 26px; font-size: 13.5px; }
.login-note { color: var(--faint); font-size: 12.5px; margin: 18px 0 0; }
.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 11px 16px; font-size: 14.5px; font-weight: 550;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border-2); border-radius: var(--radius);
  cursor: pointer; transition: background .15s, border-color .15s;
}
.btn-google:hover { background: var(--surface-2); text-decoration: none; border-color: var(--faint); }

/* ---------------- shell ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 18px;
  padding: 0 20px; height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; font-size: 15px; white-space: nowrap; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700;
}
.nav { display: flex; gap: 2px; margin-left: 8px; overflow-x: auto; }
.nav a {
  padding: 6px 12px; border-radius: var(--radius-s); color: var(--muted);
  font-weight: 500; font-size: 13.5px; white-space: nowrap;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent-ink); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); object-fit: cover; }
.who { font-size: 13px; color: var(--muted); }
.who strong { color: var(--text); font-weight: 550; }

.wrap { max-width: 1400px; margin: 0 auto; padding: 22px 20px 60px; }

.page-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px;
}
.page-head h1 { font-size: 20px; }
.page-head .spacer { flex: 1; }
.page-sub { color: var(--muted); font-size: 13px; margin: 3px 0 0; }

/* ---------------- controls ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; font-size: 13.5px; font-weight: 550; font-family: inherit;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border-2); border-radius: var(--radius-s);
  cursor: pointer; transition: background .12s, border-color .12s, opacity .12s;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn-danger { color: var(--red); border-color: var(--border-2); }
.btn-danger:hover:not(:disabled) { background: var(--red-soft); }
.btn-sm { padding: 4px 9px; font-size: 12.5px; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }

input[type=text], input[type=search], input[type=email], input[type=url],
input[type=tel], input[type=number], input[type=date], input[type=datetime-local],
input[type=password], input:not([type]), select, textarea {
  width: 100%; padding: 8px 10px; font-family: inherit; font-size: 13.5px;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border-2); border-radius: var(--radius-s);
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 74px; }
label.field { display: block; margin-bottom: 13px; }
label.field > span {
  display: block; margin-bottom: 5px; font-size: 12px; font-weight: 600;
  color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 560px) { .field-row { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; margin-bottom: 13px; }
.check input { width: auto; }

.toolbar {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  margin-bottom: 16px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.toolbar input[type=search] { max-width: 260px; }
.toolbar select { width: auto; min-width: 130px; }

/* ---------------- cards / tables ---------------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px; border-bottom: 1px solid var(--border);
}
.card-head h2 { font-size: 14.5px; }
.card-head .spacer { flex: 1; }
.card-body { padding: 16px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
}
.tile .k { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.tile .v { font-size: 23px; font-weight: 650; margin-top: 4px; letter-spacing: -.02em; }
.tile .s { font-size: 12px; color: var(--faint); margin-top: 2px; }

.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.grid th {
  text-align: left; padding: 9px 14px; font-size: 11.5px; font-weight: 600;
  color: var(--muted); text-transform: uppercase; letter-spacing: .05em;
  background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.grid td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.grid tbody tr:last-child td { border-bottom: none; }
table.grid tbody tr:hover { background: var(--surface-2); }
table.grid td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.grid td.actions { text-align: right; white-space: nowrap; }
.row-title { font-weight: 550; }
.row-sub { color: var(--faint); font-size: 12.5px; }

/* ---------------- badges ---------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: var(--slate-soft); color: var(--slate);
}
.badge.green  { background: var(--green-soft);  color: var(--green); }
.badge.amber  { background: var(--amber-soft);  color: var(--amber); }
.badge.red    { background: var(--red-soft);    color: var(--red); }
.badge.blue   { background: var(--accent-soft); color: var(--accent-ink); }
.badge.purple { background: var(--purple-soft); color: var(--purple); }

.owner { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.owner img, .owner .ini {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  background: var(--accent-soft); color: var(--accent-ink);
  font-size: 10px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.owner .nm { font-size: 13px; }
.mine-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none; }

.lock {
  color: var(--faint); font-size: 12px; display: inline-flex; align-items: center; gap: 4px;
}

/* ---------------- pipeline board ---------------- */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.col {
  flex: 0 0 268px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; flex-direction: column; max-height: calc(100vh - 210px);
}
.col-head {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px; position: sticky; top: 0;
  background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0;
}
.col-head .nm { font-weight: 650; font-size: 13px; }
.col-head .ct { font-size: 11.5px; color: var(--muted); background: var(--surface); padding: 1px 7px; border-radius: 999px; }
.col-head .sum { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.col-body { padding: 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 9px; min-height: 60px; }
.col.drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; }

.deal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-s); padding: 10px 11px; box-shadow: var(--shadow);
  cursor: pointer; transition: border-color .12s, transform .08s;
}
.deal:hover { border-color: var(--border-2); }
.deal.draggable { cursor: grab; }
.deal.dragging { opacity: .45; }
.deal.locked { background: var(--surface-2); }
.deal .t { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.deal .c { font-size: 12px; color: var(--muted); margin-bottom: 7px; }
.deal .m { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.deal .v { font-weight: 650; font-size: 13px; font-variant-numeric: tabular-nums; }
.deal .next { margin-top: 7px; padding-top: 7px; border-top: 1px dashed var(--border); font-size: 12px; color: var(--muted); }

/* ---------------- modal ---------------- */
.modal-back {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15,17,21,.5); backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto;
}
.modal {
  width: 100%; max-width: 620px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-l); animation: pop .13s ease-out;
}
.modal.wide { max-width: 860px; }
@keyframes pop { from { opacity: 0; transform: translateY(-8px); } }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 16px; }
.modal-head .spacer { flex: 1; }
.modal-body { padding: 20px; }
.modal-foot {
  display: flex; gap: 8px; align-items: center;
  padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2);
  border-radius: 0 0 14px 14px;
}
.modal-foot .spacer { flex: 1; }

/* ---------------- misc ---------------- */
.alert { padding: 10px 13px; border-radius: var(--radius-s); font-size: 13px; margin-bottom: 14px; }
.alert-error { background: var(--red-soft); color: var(--red); }
.alert-info  { background: var(--accent-soft); color: var(--accent-ink); }
.alert-warn  { background: var(--amber-soft); color: var(--amber); }

.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty .big { font-size: 15px; font-weight: 550; color: var(--text); margin-bottom: 4px; }

.toast-host { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 11px 15px; border-radius: var(--radius-s); font-size: 13.5px; max-width: 380px;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow-l);
  animation: pop .13s ease-out;
}
.toast.err { background: var(--red); color: #fff; }
.toast.ok  { background: var(--green); color: #fff; }

.spinner {
  width: 18px; height: 18px; border: 2px solid var(--border-2); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading { padding: 50px; text-align: center; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 12px 0; border-bottom: 1px solid var(--border); display: flex; gap: 11px; }
.timeline li:last-child { border-bottom: none; }
.timeline .ic {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 13px;
  background: var(--surface-2);
}
.timeline .bd { flex: 1; min-width: 0; }
.timeline .hd { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 3px; }
.timeline .tx { white-space: pre-wrap; overflow-wrap: anywhere; }
.timeline .na {
  margin-top: 6px; font-size: 12.5px; padding: 5px 9px; border-radius: 6px;
  background: var(--amber-soft); color: var(--amber); display: inline-flex; align-items: center; gap: 7px;
}
.timeline .na.done { background: var(--green-soft); color: var(--green); text-decoration: line-through; }
.timeline .na.overdue { background: var(--red-soft); color: var(--red); }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.detail-grid .k { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.detail-grid .v { margin-top: 2px; overflow-wrap: anywhere; }

.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

.bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--accent); }

.hint { font-size: 12.5px; color: var(--faint); margin-top: 4px; }
.mono { font-variant-numeric: tabular-nums; }
