:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --ink: #1e2430;
  --ink-muted: #5b6472;
  --primary: #2b4c6f;
  --primary-dark: #1f384f;
  --accent: #c8862b;
  --border: #dde1e6;
  --radius: 4px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  color: var(--ink-muted);
}

/* Nav */
nav.app-nav {
  background: var(--primary);
  display: flex;
  align-items: center;
  padding: 0 1rem;
  flex-wrap: wrap;
  /* Stays pinned while a long page scrolls, so Customers is always one tap away. */
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}
nav.app-nav a {
  color: #fff;
  text-decoration: none;
  padding: 0.9rem 0.75rem;
  font-weight: 500;
  opacity: 0.9;
}
nav.app-nav a:hover,
nav.app-nav a:focus-visible {
  opacity: 1;
  text-decoration: underline;
}
nav.app-nav a.signout {
  margin-left: auto;
  opacity: 0.75;
}

main {
  max-width: 860px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 1.25rem;
}
h2 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

a {
  color: var(--primary);
}

.subtle {
  color: var(--ink-muted);
}

/* Data table */
table.data {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
table.data th,
table.data td {
  text-align: left;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--border);
}
table.data th {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink-muted);
}
table.data tr:last-child td {
  border-bottom: none;
}
table.data tr:hover td {
  background: var(--bg);
}
table.data td a {
  text-decoration: none;
  font-weight: 500;
}
table.data td a:hover {
  text-decoration: underline;
}

/* Item lists (interaction history, follow-ups) */
.item-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.item-list > li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin-bottom: 0.75rem;
}
.item-list > li p {
  margin: 0.5rem 0 0;
  color: var(--ink);
}
.item-list .meta {
  color: var(--ink-muted);
  font-size: 0.9rem;
}
.item-list .empty {
  color: var(--ink-muted);
  background: none;
  border: none;
  padding: 0.5rem 0;
}

/* Badges */
.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--ink-muted);
}
.badge-due {
  background: #fbf0de;
  border-color: var(--accent);
  color: #7a551a;
}

/* Forms */
form p {
  margin: 0 0 1rem;
}
label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.35rem;
}
input,
select,
textarea {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--ink);
}
textarea {
  min-height: 6rem;
  resize: vertical;
}
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

button,
.btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}
button:hover,
.btn:hover {
  background: var(--primary-dark);
}

.actions {
  margin-bottom: 1.25rem;
}

.contact-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.5rem;
}
.contact-block p {
  margin: 0.25rem 0;
}

.center-card {
  max-width: 420px;
  margin: 3rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  text-align: left;
}

@media (max-width: 480px) {
  main {
    padding: 1rem 0.75rem 2rem;
  }
  nav.app-nav a {
    padding: 0.8rem 0.6rem;
    font-size: 0.95rem;
  }
  table.data th,
  table.data td {
    padding: 0.55rem 0.6rem;
    font-size: 0.92rem;
  }
}

.login-card {
  max-width: 360px;
  margin: 12vh auto 0;
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}

.login-card h1 {
  margin: 0 0 0.5rem;
  font-size: 1.4rem;
  color: var(--primary);
}

.login-button {
  width: 100%;
  margin-top: 1rem;
  padding: 0.7rem 1rem;
  font-size: 1rem;
  color: #fff;
  background: var(--primary);
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}

.login-button:hover {
  background: var(--primary-dark);
}

.login-messages {
  list-style: none;
  padding: 0;
  color: #9b2c2c;
}

.email-body {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  margin: 0.5rem 0 0;
}

.search-form {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0 1.5rem;
}

.search-form input[type="search"] {
  flex: 1;
  min-width: 0;
  font-size: 1.1rem;
  padding: 0.7rem 0.9rem;
}


/* The owning company's name, shown small under a short name. */
.company-name {
  display: block;
  font-size: 0.85rem;
  color: var(--ink-muted);
}

p.company-name {
  margin: -0.75rem 0 1.25rem;
}

.working-contacts summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.1rem 0;
}

.working-contacts summary .preview {
  font-weight: 400;
  color: var(--ink-muted);
}

.working-contacts[open] summary {
  margin-bottom: 0.5rem;
}

.contact-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.75rem;
}

.contact-list .edit-link {
  margin-left: auto;
}

/* Contact status (red / amber / green / grey): the dot is decorative; the
   text label always carries the meaning. */
.status-dot {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  margin-right: 0.35rem;
  vertical-align: baseline;
  background: #9aa0a6;
}

.status-dot.status-red { background: #c0392b; }
.status-dot.status-amber { background: #e0a100; }
.status-dot.status-green { background: #2e8b57; }
.status-dot.status-grey { background: #9aa0a6; }

.status-label {
  display: block;
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.status-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin: 0 0 1rem;
}

.status-chip.active {
  font-weight: 700;
  border-bottom: 2px solid var(--primary);
}

.status-line {
  margin: 0 0 1rem;
}

.status-line .status-label {
  display: inline;
}
