:root {
  --ink: #1c2b2c;
  --paper: #f6f4ef;
  --panel: #ffffff;
  --teal: #1f3a3d;
  --teal-light: #2f5457;
  --terracotta: #c96a4f;
  --good: #2f7d5e;
  --bad: #b0463a;
  --line: #e2ded3;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

h1, h2 { font-family: "Iowan Old Style", "Georgia", serif; margin: 0; }

/* ---------------- AUTH ---------------- */
#auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-box {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
}
.auth-box h1 { font-size: 24px; margin-bottom: 4px; }
.auth-sub { color: #6b6b60; font-size: 14px; margin: 0 0 20px; }
#login-form { display: flex; flex-direction: column; gap: 14px; }
#login-form label { font-size: 13px; color: #4a4a42; display: flex; flex-direction: column; gap: 6px; }
.auth-error { color: var(--bad); font-size: 13px; min-height: 16px; }

/* ---------------- INPUTS (shared) ---------------- */
input, select, textarea {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--teal-light);
  outline-offset: 1px;
}

.btn-primary, .btn-secondary, .btn-ghost, .btn-small {
  font: inherit;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
}
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-light); }
.btn-secondary { background: transparent; border: 1px solid var(--teal); color: var(--teal); margin-top: 4px; }
.btn-ghost { background: transparent; color: var(--teal); border: 1px solid var(--line); }
.btn-small { padding: 6px 12px; font-size: 13px; border: 1px solid var(--line); background: #fff; }
.btn-danger { color: var(--bad); border-color: #e6c9c2; }

/* ---------------- TOPBAR / TOOLBAR ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--teal);
  color: #fff;
}
.topbar h1 { font-size: 20px; color: #fff; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.sync-badge { font-size: 12px; opacity: 0.9; }
.topbar .btn-ghost { color: #fff; border-color: rgba(255,255,255,0.4); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.toolbar input[type="search"] { flex: 1 1 200px; min-width: 160px; }
.filter-interest-label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #4a4a42; }
.filter-interest-label input { width: 60px; }
#add-customer-btn { margin-left: auto; }

.list-meta { padding: 10px 20px 0; font-size: 13px; color: #6b6b60; }

/* ---------------- CUSTOMER LIST ---------------- */
.customer-list {
  padding: 14px 20px 60px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}
.customer-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.customer-card.is-dropped { opacity: 0.6; }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card-name { font-weight: 600; font-size: 16px; }
.card-phone { color: var(--teal); text-decoration: none; font-size: 14px; display: inline-block; margin-top: 2px; }
.card-phone:hover { text-decoration: underline; }

.interest-pill {
  --pct: 0;
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--teal);
  background: conic-gradient(var(--terracotta) calc(var(--pct) * 1%), #eee 0);
}
.interest-pill::before {
  content: "";
  position: absolute;
}

.card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 6px; }
.tag { font-size: 11px; padding: 3px 8px; border-radius: 100px; background: #eee; color: #444; }
.tag-stage { background: #e4ecec; color: var(--teal); }
.tag-good { background: #e2f0e8; color: var(--good); }
.tag-bad { background: #f5e3e0; color: var(--bad); }
.tag-menh { background: #f2e8da; color: #7a5a2f; }

.card-notes { font-size: 13px; color: #4a4a42; margin: 6px 0; white-space: pre-wrap; }
.card-actions { display: flex; gap: 8px; margin-top: 10px; }

.empty-state { text-align: center; padding: 60px 20px; color: #8a8a7d; }

/* ---------------- FORM MODAL ---------------- */
dialog#form-modal {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  width: min(640px, 92vw);
  max-height: 88vh;
}
dialog#form-modal::backdrop { background: rgba(20, 30, 30, 0.5); }
#customer-form { padding: 24px; overflow-y: auto; max-height: 88vh; }
#customer-form h2 { margin-bottom: 16px; font-size: 20px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #4a4a42; }
.span-2 { grid-column: 1 / -1; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
legend { font-size: 12px; color: #6b6b60; padding: 0 6px; }
.menh-preview { padding: 10px 12px; background: #f2e8da; border-radius: 8px; font-size: 13px; color: #7a5a2f; }

.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
  .toolbar { position: static; }
}
