/* Show Low Ford - Customer Relations Letters */
:root {
  --navy: #0b2440;
  --navy-2: #12355e;
  --blue: #0f66ab;
  --blue-600: #0b5591;
  --blue-50: #eef5fc;
  --blue-100: #d8e8f7;
  --ink: #1c2430;
  --ink-2: #3a4453;
  --muted: #677285;
  --border: #e2e7ee;
  --bg: #f2f4f8;
  --card: #ffffff;
  --ok: #1d7a46;
  --ok-bg: #e7f5ec;
  --warn: #8a5a00;
  --warn-bg: #fff6e0;
  --err: #b42318;
  --err-bg: #fdecea;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
  --font: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--navy); margin: 0; line-height: 1.25; }
h1 { font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 17px; font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Top bar ---------- */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(16, 24, 40, .02);
  position: sticky; top: 0; z-index: 10;
}
.topbar::after {
  content: ""; display: block; height: 3px;
  background: linear-gradient(90deg, var(--navy), var(--blue) 60%, #3a8fd6);
}
.topbar-inner {
  max-width: 1240px; margin: 0 auto; padding: 10px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 14px; color: inherit; }
.brand:hover { text-decoration: none; }
.brand img { height: 46px; width: auto; display: block; }
.brand-text { display: flex; flex-direction: column; border-left: 1px solid var(--border); padding-left: 14px; }
.brand-kicker { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--blue); }
.brand-title { font-size: 17px; font-weight: 650; color: var(--navy); }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a {
  color: var(--ink-2); font-weight: 550; font-size: 14px;
  padding: 8px 12px; border-radius: 8px;
}
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.active { color: var(--blue); background: var(--blue-50); }
.nav-user { display: flex; align-items: center; gap: 8px; margin-left: 10px; padding-left: 14px; border-left: 1px solid var(--border); font-size: 14px; color: var(--ink-2); }
.nav a.signout { color: var(--muted); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--navy), var(--blue));
  color: #fff; font-weight: 700; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.avatar-sm { width: 34px; height: 34px; }

/* ---------- Layout ---------- */
.container { width: 100%; max-width: 1240px; margin: 0 auto; padding: 28px 24px 16px; flex: 1; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 6px 0 0; }
.stats { display: flex; gap: 12px; }
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 16px; min-width: 150px; display: flex; flex-direction: column;
}
.stat-num { font-size: 22px; font-weight: 700; color: var(--navy); line-height: 1.1; }
.stat-label { font-size: 12px; color: var(--muted); }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-section { padding: 22px 24px; border-bottom: 1px solid var(--border); }
.card-section:last-of-type { border-bottom: 0; }
.section-title { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-size: 15px; }
.step {
  width: 22px; height: 22px; border-radius: 50%; background: var(--navy); color: #fff;
  font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}
.card-actions { padding: 18px 24px 22px; display: flex; gap: 10px; align-items: center; }

.compose { display: grid; grid-template-columns: minmax(360px, 440px) minmax(0, 1fr); gap: 22px; align-items: start; }
.history { margin-top: 22px; }
.history-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 18px 24px 12px; }
.add-user-form { display: grid; grid-template-columns: 1.2fr 1fr 1.4fr auto auto; gap: 14px; align-items: end; }
.add-user-form .field, .add-user-form .check { margin: 0; }
.add-user-form .check { padding-bottom: 4px; }
.add-user-form .btn { height: 42px; }
.users-table { margin-top: 22px; }

/* ---------- Forms ---------- */
.form .field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.field small { font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], input[type=password] {
  width: 100%; font: inherit; color: var(--ink);
  padding: 10px 12px; border: 1px solid #cfd6e0; border-radius: 8px; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: #a3acb9; }
input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(15, 102, 171, .15); }
.row-3 { display: grid; grid-template-columns: 90px 1fr 1.4fr; gap: 10px; }

.type-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.type-option input { position: absolute; opacity: 0; pointer-events: none; }
.type-card {
  display: flex; flex-direction: column; gap: 2px; cursor: pointer; height: 100%;
  border: 1.5px solid var(--border); border-radius: 10px; padding: 14px 14px 12px;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.type-card svg { width: 26px; height: 26px; color: var(--muted); margin-bottom: 6px; }
.type-name { font-weight: 700; color: var(--navy); }
.type-desc { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.type-card:hover { border-color: #b8c7da; }
.type-option input:checked + .type-card { border-color: var(--blue); background: var(--blue-50); box-shadow: 0 0 0 3px rgba(15, 102, 171, .12); }
.type-option input:checked + .type-card svg { color: var(--blue); }
.type-option input:focus-visible + .type-card { outline: 2px solid var(--blue); outline-offset: 2px; }

.segmented { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.segmented[hidden] { display: none; }
.segmented-label { font-size: 13px; font-weight: 600; color: var(--ink-2); margin-right: 4px; }
.segmented label input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label span {
  display: inline-block; padding: 6px 14px; border: 1px solid #cfd6e0; border-radius: 999px;
  font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; background: #fff;
}
.segmented label input:checked + span { background: var(--navy); border-color: var(--navy); color: #fff; }
.segmented label input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }

.check { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 18px; font-size: 14px; cursor: pointer; }
.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--blue); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: 14px; line-height: 1;
  padding: 10px 16px; border-radius: 8px; border: 1px solid transparent; cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
  text-decoration: none !important; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--blue); color: #fff; box-shadow: 0 1px 2px rgba(11, 36, 64, .2); }
.btn-primary:hover { background: var(--blue-600); }
.btn-lg { padding: 13px 22px; font-size: 15px; }
.btn-block { width: 100%; padding: 12px 16px; }
.btn-ghost { background: #fff; border-color: #cfd6e0; color: var(--ink-2); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger-ghost { background: #fff; border-color: #f0c8c3; color: var(--err); }
.btn-danger-ghost:hover { background: var(--err-bg); }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.btn[disabled] { opacity: .7; cursor: progress; }

/* ---------- Alerts ---------- */
.alert { border-radius: 10px; padding: 12px 16px; margin-bottom: 18px; font-size: 14px; border: 1px solid transparent; }
.alert-success { background: var(--ok-bg); color: var(--ok); border-color: #bfe3cc; }
.alert-error { background: var(--err-bg); color: var(--err); border-color: #f5c6c0; }
.alert-warn { background: var(--warn-bg); color: var(--warn); border-color: #f1dca4; margin: 0 24px 4px; }

/* ---------- Preview ---------- */
.preview-card { overflow: hidden; position: sticky; top: 92px; }
.preview-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--border); background: #fafbfd;
}
.preview-label {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--blue); background: var(--blue-50); border-radius: 4px; padding: 2px 7px; margin-right: 8px;
}
.preview-subject { font-weight: 600; color: var(--ink); }
.preview-to { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 45%; }
#preview { display: block; width: 100%; height: 760px; border: 0; background: #eef1f5; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 10px 24px; background: #fafbfd; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.table td { padding: 12px 24px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfd; }
.table .num { text-align: right; }
.table tr.is-inactive td { opacity: .55; }
.actions-col, .table th.actions-col { text-align: right; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }
.row-actions form { margin: 0; }
.user-cell { display: flex; align-items: center; gap: 12px; }
.empty { padding: 8px 24px 24px; color: var(--muted); margin: 0; }

.badge { display: inline-block; white-space: nowrap; font-size: 12px; font-weight: 650; padding: 3px 9px; border-radius: 999px; }
.badge-sales { background: var(--blue-50); color: var(--blue); }
.badge-service { background: #eef0f3; color: var(--navy); }
.badge-admin { background: var(--navy); color: #fff; }
.badge-user { background: var(--blue-50); color: var(--blue); }
.badge-muted { background: #eef0f3; color: var(--muted); }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status-ok { color: var(--ok); }
.status-fail { color: var(--err); cursor: help; }

/* ---------- Sign-in pages ---------- */
.auth-wrap {
  flex: 1; display: flex; align-items: center; justify-content: center; padding: 48px 16px;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(15, 102, 171, .18), transparent 70%),
    linear-gradient(180deg, #e9eef5 0%, var(--bg) 100%);
}
.auth-card { width: 100%; max-width: 410px; background: #fff; border-radius: 14px; box-shadow: 0 10px 40px rgba(11, 36, 64, .14); overflow: hidden; }
.auth-brand { padding: 30px 24px 22px; text-align: center; border-bottom: 1px solid var(--border); position: relative; }
.auth-brand::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: linear-gradient(90deg, var(--navy), var(--blue)); }
.auth-brand img { width: 200px; height: auto; }
.auth-body { padding: 28px 32px 30px; }
.auth-body h1 { font-size: 22px; margin-bottom: 4px; }
.auth-body > p.muted { margin: 0 0 20px; }
.auth-link { text-align: center; margin: 18px 0 0; font-size: 14px; }

/* ---------- Footer ---------- */
.site-footer { text-align: center; font-size: 12.5px; color: var(--muted); padding: 22px 16px 28px; }
.site-footer .sep { margin: 0 8px; color: #c3cad5; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .add-user-form { grid-template-columns: 1fr 1fr; }
  .add-user-form .btn { grid-column: 1 / -1; }
}
@media (max-width: 1000px) {
  .compose { grid-template-columns: 1fr; }
  .preview-card { position: static; }
}
@media (max-width: 640px) {
  .container { padding: 18px 16px 8px; }
  .topbar-inner { padding: 8px 16px; flex-wrap: wrap; }
  .brand img { height: 38px; }
  .brand-text { display: none; }
  .nav-user-name { display: none; }
  .nav-user { margin-left: 4px; padding-left: 8px; }
  .stats { width: 100%; }
  .stat { flex: 1; min-width: 0; }
  .card-section, .card-actions { padding-left: 18px; padding-right: 18px; }
  .row-3 { grid-template-columns: 80px 1fr; }
  .row-3 .field:last-child { grid-column: 1 / -1; }
  .table th, .table td { padding-left: 16px; padding-right: 16px; }
  .auth-body { padding: 24px 22px 26px; }
  #preview { height: 640px; }
}
