/* G&G CRM — plain stylesheet, no build step. Mobile-first. */

:root {
  --navy: #012552;
  --navy-light: #0a3a75;
  --ink: #1a2433;
  --muted: #5b6b80;
  --line: #dbe3ec;
  --bg: #eef2f6;
  --card: #ffffff;
  --amber-bg: #fff4d6;
  --amber-line: #e3b505;
  --red: #b42318;
  --red-bg: #fdeceb;
  --green: #067647;
  --green-bg: #e6f4ea;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--navy-light); }

.hidden { display: none !important; }

/* ------------------------------------------------------------ header ----- */
.topbar {
  background: var(--navy);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.topbar h1 { font-size: 20px; margin: 0; }
.topbar .userline { font-size: 14px; opacity: 0.9; }
.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 9px 14px;
  min-height: 44px;
}
.btn:hover { background: #f4f7fa; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
.btn-primary:hover { background: var(--navy-light); }
.btn-danger { color: var(--red); border-color: #f0b3ae; }
.btn-danger:hover { background: var(--red-bg); }
.btn-small { min-height: 36px; padding: 6px 10px; font-size: 14px; }
.btn-ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.5);
  color: #fff;
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.12); }

/* ------------------------------------------------------------- layout ---- */
.wrap { max-width: 1440px; margin: 0 auto; padding: 16px; }
.notice {
  background: var(--amber-bg);
  border: 1px solid var(--amber-line);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
}
.notice h2 { margin: 0 0 6px; font-size: 17px; }
.notice p { margin: 6px 0; }
.notice code {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 13px;
}
.error { color: var(--red); font-weight: 600; }

/* -------------------------------------------------------------- login ----- */
.login-wrap {
  max-width: 440px;
  margin: 48px auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}
.login-wrap h2 { margin-top: 0; }
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
}
.field textarea { min-height: 80px; resize: vertical; }
.field .hint { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* --------------------------------------------------------------- tabs ------ */
.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 12px;
}
.tab-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 9px 16px;
  min-height: 44px;
  font-weight: 600;
}
.tab-btn.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.tab-search { margin-left: auto; }
.tab-search input {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  width: 220px;
  max-width: 100%;
}

/* ------------------------------------------------------------ summary ----- */
.summary {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.stat .label { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.02em; }
.stat .value { font-size: 22px; font-weight: 700; margin-top: 2px; }
.stat .sub { font-size: 13px; color: var(--muted); }

/* ------------------------------------------------------------ filters ----- */
.filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: end;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
}
.filters .field { margin-bottom: 0; }
.filters .field label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.02em; color: var(--muted); }
.filters .field select { min-width: 170px; }
.showing { font-size: 14px; color: var(--muted); margin: 4px 0 0; }
.filters-note { font-size: 13px; color: var(--muted); flex-basis: 100%; margin: 0; }

/* -------------------------------------------------------------- board ----- */
.stage-pills { display: none; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; }
.stage-pills button {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  min-height: 40px;
  font-weight: 600;
}
.stage-pills button.active { background: var(--navy); color: #fff; border-color: var(--navy); }

.board {
  display: grid;
  grid-template-columns: repeat(6, minmax(250px, 1fr));
  gap: 12px;
  align-items: start;
  overflow-x: auto;
  padding-bottom: 8px;
}
.column { background: #e3e9f0; border-radius: var(--radius); padding: 10px; min-width: 250px; }
.column h3 { margin: 0 0 10px; font-size: 15px; }
.column h3 .count { color: var(--muted); font-weight: 500; }
.column h3 .col-total { display: block; font-size: 13px; color: var(--muted); font-weight: 500; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
  cursor: pointer;
}
.card:hover { border-color: var(--navy-light); }
.card .code { font-size: 13px; font-weight: 700; color: var(--navy); }
.card .client { font-weight: 700; margin-top: 2px; }
.card .desc { font-size: 14px; color: var(--ink); margin-top: 4px; }
.card .meta { font-size: 13px; color: var(--muted); margin-top: 6px; }
.card .amount { font-size: 17px; font-weight: 700; margin-top: 6px; }
.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 8px;
  margin-top: 6px;
}
.badge-overdue { background: var(--red-bg); color: var(--red); }
.badge-today { background: var(--amber-bg); color: #7a5b00; }
.card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}
.card-foot .stage-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  min-width: 40px;
  min-height: 36px;
  font-size: 16px;
}
.card-foot .stage-btn:disabled { opacity: 0.35; cursor: default; }
.card-foot .drive-link { font-size: 13px; }

.empty {
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

/* ------------------------------------------------------------ contacts ---- */
.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.contact-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.contact-card h3 { margin: 0 0 4px; }
.contact-card p { margin: 4px 0; font-size: 14px; }
.contact-card .linked { font-size: 13px; color: var(--muted); }

/* ------------------------------------------------------------- archive ---- */
.archive-table { width: 100%; border-collapse: collapse; background: var(--card); }
.archive-table th, .archive-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  vertical-align: top;
}
.archive-table th { background: #f4f7fa; font-size: 13px; text-transform: uppercase; letter-spacing: 0.02em; color: var(--muted); }
.archive-table .row-actions { white-space: nowrap; }
.archive-totals { display: flex; gap: 16px; flex-wrap: wrap; font-weight: 600; margin-bottom: 12px; }

/* -------------------------------------------------------------- modal ----- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 24px 12px;
  z-index: 50;
}
.sheet {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 640px;
  padding: 20px;
  margin: auto 0;
}
.sheet h2 { margin-top: 0; }
.sheet .form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 14px;
}
.sheet .form-grid .full { grid-column: 1 / -1; }
.sheet-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.sheet-actions .spacer { flex: 1; }
.inline-contact {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  margin-top: 8px;
  background: #f8fafc;
}
.inline-contact h3 { margin: 0 0 10px; font-size: 15px; }

/* --------------------------------------------------------------- toast ----- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  max-width: calc(100vw - 32px);
  text-align: center;
  z-index: 100;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}

/* --------------------------------------------------------- responsiveness -- */
@media (max-width: 1100px) {
  .summary { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
  .wrap { padding: 12px; }
  .summary { grid-template-columns: 1fr 1fr; }
  .stat .value { font-size: 19px; }
  .tab-search { margin-left: 0; width: 100%; }
  .tab-search input { width: 100%; }
  .stage-pills { display: flex; }
  .board { display: block; overflow-x: visible; }
  .column { min-width: 0; margin-bottom: 12px; }
  .column[data-stage] { display: none; }
  .column[data-stage].mobile-active { display: block; }
  .sheet .form-grid { grid-template-columns: 1fr; }
  /* Archive table becomes stacked cards on mobile. */
  .archive-table, .archive-table tbody, .archive-table tr, .archive-table td { display: block; width: 100%; }
  .archive-table thead { display: none; }
  .archive-table tr {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 12px;
    padding: 6px 0;
  }
  .archive-table td { border-bottom: none; padding: 6px 12px; }
  .archive-table td::before {
    content: attr(data-label);
    display: block;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--muted);
    font-weight: 600;
  }
  .archive-table .row-actions { white-space: normal; }
  .filters .field select { min-width: 0; width: 100%; }
}
