/* TMS Mailer — dashboard styles. No external dependencies. */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e3e6eb;
  --text: #1c2230;
  --muted: #667085;
  --accent: #2f54eb;
  --accent-hover: #2140c4;
  --accent-soft: #eef2ff;
  --ok: #16794c;
  --ok-soft: #e7f6ee;
  --warn: #9a6200;
  --warn-soft: #fff6e0;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --sidebar: 232px;
  font-size: 15px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.45rem; font-weight: 650; }
h2 { font-size: 1.1rem; font-weight: 620; }
h3 { font-size: .98rem; font-weight: 620; }
p { margin: 0 0 .75rem; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; }
small, .muted { color: var(--muted); }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }

/* ---------- App shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar);
  background: #141a2a;
  color: #c8cedb;
  padding: 1.25rem .9rem;
  position: fixed; inset: 0 auto 0 0;
  display: flex; flex-direction: column; gap: 1.25rem;
}
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; font-weight: 650; font-size: 1.05rem; padding: 0 .5rem; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent);
  display: grid; place-items: center; color: #fff; font-size: .9rem;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a, .nav span {
  display: flex; align-items: center; justify-content: space-between;
  color: #c8cedb; padding: .55rem .7rem; border-radius: 8px; font-size: .93rem;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav a.active { background: rgba(255,255,255,.1); color: #fff; }
.nav span.disabled { color: #6c7489; cursor: default; }
.nav .soon { font-size: .68rem; border: 1px solid #3a4258; border-radius: 99px; padding: 0 .45rem; color: #8a92a8; }
.sidebar-foot { margin-top: auto; font-size: .8rem; color: #8a92a8; padding: 0 .5rem; }
.sidebar-foot a { color: #c8cedb; }

.main { margin-left: var(--sidebar); flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1.1rem 2rem; border-bottom: 1px solid var(--border); background: var(--surface);
}
.topbar .who { font-size: .88rem; color: var(--muted); }
.content { padding: 1.75rem 2rem 3rem; max-width: 1180px; }

/* ---------- Components ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.25rem 1.35rem;
}
.card + .card { margin-top: 1.25rem; }
.grid > .card + .card { margin-top: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .9rem; }
.card-head h2 { margin: 0; }

.grid { display: grid; gap: 1.1rem; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack > * + * { margin-top: 1.25rem; }

.stat .label { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 1.65rem; font-weight: 650; margin-top: .2rem; font-variant-numeric: tabular-nums; }
.stat .value small { font-size: .95rem; font-weight: 500; }
.stat .sub { font-size: .85rem; color: var(--muted); margin-top: .15rem; }
.progress { height: 6px; background: #edf0f4; border-radius: 99px; overflow: hidden; margin-top: .6rem; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

.badge {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .78rem; font-weight: 600; padding: .15rem .55rem; border-radius: 99px; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.idle { background: #eef0f3; color: var(--muted); }

.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
  padding: .8rem 0; border-top: 1px solid var(--border);
}
.checklist li:first-child { border-top: 0; padding-top: .2rem; }
.checklist .what { min-width: 0; }
.checklist .what strong { display: block; font-weight: 600; }
.checklist .what span { font-size: .87rem; color: var(--muted); overflow-wrap: anywhere; }

.alert { border-radius: var(--radius); padding: .8rem 1rem; margin-bottom: 1.1rem; font-size: .93rem; border: 1px solid; }
.alert.success { background: var(--ok-soft); border-color: #b7e3cb; color: #0f5132; }
.alert.error { background: var(--bad-soft); border-color: #f5c2bd; color: #7a1a12; }
.alert.info { background: var(--accent-soft); border-color: #cdd6ff; color: #1d2f80; }
.alert.warning { background: var(--warn-soft); border-color: #f3dca0; color: #6b4500; }

/* ---------- Forms ---------- */
.form { max-width: 640px; }
.field { margin-bottom: 1.05rem; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.field .hint { font-size: .83rem; color: var(--muted); margin-top: .3rem; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=time], input[type=url], select, textarea {
  width: 100%; font: inherit; color: inherit;
  background: var(--surface); border: 1px solid #cfd4dc; border-radius: 8px; padding: .55rem .7rem;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.days { display: flex; flex-wrap: wrap; gap: .4rem; }
.days label {
  display: inline-flex; align-items: center; gap: .35rem; font-weight: 500; margin: 0;
  border: 1px solid #cfd4dc; border-radius: 8px; padding: .35rem .65rem; cursor: pointer; background: var(--surface);
}
.check { display: flex; align-items: flex-start; gap: .55rem; font-weight: 500 !important; }
.check input { margin-top: .3rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer;
  border-radius: 8px; padding: .55rem 1rem; border: 1px solid transparent;
  background: var(--accent); color: #fff; text-decoration: none !important;
}
.btn:hover { background: var(--accent-hover); }
.btn.secondary { background: var(--surface); color: var(--text); border-color: #cfd4dc; }
.btn.secondary:hover { background: var(--surface-2); }
.btn.danger { background: var(--bad); }
.btn.block { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-top: 1.25rem; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; overflow-x: auto; }
.tabs a {
  padding: .6rem .9rem; color: var(--muted); font-weight: 550; font-size: .92rem; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }

.codebox {
  background: #0f1422; color: #dbe2f3; border-radius: 8px; padding: .75rem .9rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8rem;
  overflow-x: auto; white-space: pre; position: relative;
}
.copy { position: absolute; top: .4rem; right: .4rem; font-size: .72rem; padding: .2rem .5rem; border-radius: 6px;
  background: #2a3350; color: #dbe2f3; border: 0; cursor: pointer; }

table.simple { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.simple th, table.simple td { text-align: left; padding: .55rem .5rem; border-top: 1px solid var(--border); vertical-align: top; }
table.simple th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-top: 0; }

.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty h2 { color: var(--text); }

/* ---------- Auth / installer pages ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.auth-card { width: 100%; max-width: 410px; }
.auth-card .brand { color: var(--text); justify-content: center; margin-bottom: 1.25rem; font-size: 1.15rem; }

.wizard { max-width: 760px; margin: 0 auto; padding: 2rem 1.25rem 4rem; }
.wizard .brand { color: var(--text); margin-bottom: 1.5rem; padding: 0; }
.steps { display: flex; gap: .4rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.steps span {
  font-size: .8rem; font-weight: 600; padding: .3rem .7rem; border-radius: 99px;
  background: #eceff4; color: var(--muted);
}
.steps span.done { background: var(--ok-soft); color: var(--ok); }
.steps span.current { background: var(--accent); color: #fff; }

/* ---------- Mobile ---------- */
.menu-toggle { display: none; }
@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .sidebar { position: static; width: 100%; padding: .8rem 1rem; gap: .6rem; }
  .shell { flex-direction: column; }
  .main { margin-left: 0; }
  .nav { display: none; }
  .sidebar.open .nav { display: flex; }
  .sidebar-foot { display: none; }
  .sidebar-top { display: flex; align-items: center; justify-content: space-between; }
  .menu-toggle { display: inline-flex; background: transparent; border: 1px solid #3a4258; color: #fff; border-radius: 8px; padding: .3rem .65rem; font: inherit; }
  .topbar { padding: .9rem 1rem; }
  .content { padding: 1.1rem 1rem 2.5rem; }
  .row { grid-template-columns: 1fr; }
  .grid-4 { gap: .75rem; }
  .stat .value { font-size: 1.35rem; }
  .card { padding: 1rem; }
}

/* ---------- Mail account form ---------- */
.choices { display: flex; flex-direction: column; gap: .4rem; }
.choice {
  display: flex !important; align-items: center; gap: .6rem; font-weight: 500 !important; margin: 0 !important;
  border: 1px solid #cfd4dc; border-radius: 8px; padding: .55rem .75rem; cursor: pointer; background: var(--surface);
}
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
details.advanced { border: 1px solid var(--border); border-radius: 8px; padding: .7rem .9rem; margin-bottom: 1.05rem; background: var(--surface-2); }
details.advanced summary { cursor: pointer; font-weight: 600; font-size: .92rem; }
[hidden] { display: none !important; }

/* ---------- Contacts ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: end; margin-bottom: 1rem; }
.toolbar .field { margin: 0; }
.toolbar input[type=text], .toolbar select { width: auto; min-width: 150px; }
.toolbar .grow { flex: 1; min-width: 200px; }
.toolbar .grow input { width: 100%; }
.table-wrap { overflow-x: auto; margin: 0 -1.35rem; padding: 0 1.35rem; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td { text-align: left; padding: .6rem .55rem; border-top: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
table.data th { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-top: 0; }
table.data td.wrap { white-space: normal; }
table.data tr:hover td { background: var(--surface-2); }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data input[type=checkbox] { width: 16px; height: 16px; }
.bulkbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .7rem 0 0; }
.bulkbar select { width: auto; }
.pager { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: 1rem; align-items: center; }
.pager a, .pager span { padding: .35rem .65rem; border-radius: 6px; font-size: .88rem; }
.pager a { border: 1px solid var(--border); color: var(--text); background: var(--surface); }
.pager a.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pager a:hover { text-decoration: none; border-color: var(--accent); }
.pills { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.pill { display: inline-flex; gap: .4rem; align-items: baseline; padding: .4rem .8rem; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: .88rem; }
.pill strong { font-variant-numeric: tabular-nums; }
.pill.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.pill:hover { text-decoration: none; border-color: var(--accent); }
.progress.big { height: 12px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .6rem; margin-top: 1rem; }
.stats-grid div { border: 1px solid var(--border); border-radius: 8px; padding: .6rem .75rem; background: var(--surface-2); }
.stats-grid strong { display: block; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.stats-grid span { font-size: .82rem; color: var(--muted); }
.stats-grid .good strong { color: var(--ok); }
.stats-grid .bad strong { color: var(--bad); }
.mapping td { white-space: normal; }
.mapping .sample { color: var(--muted); font-size: .84rem; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.radio-list { display: flex; flex-direction: column; gap: .35rem; }
.radio-list label { display: flex; gap: .5rem; align-items: center; font-weight: 500 !important; margin: 0 !important; }
@media (max-width: 760px) {
  .table-wrap { margin: 0 -1rem; padding: 0 1rem; }
  .toolbar input[type=text], .toolbar select { min-width: 0; width: 100%; }
  .toolbar > .field { flex: 1 1 100%; }
  .toolbar > .btn { flex: 1 1 auto; }
  .mapping th:nth-child(2), .mapping td:nth-child(2) { display: none; }
  .mapping select { min-width: 150px; }
  .mapping td, .mapping th { white-space: normal; }
}
.grid-2.wide-left { grid-template-columns: 2fr 1fr; }
@media (max-width: 900px) { .grid-2.wide-left { grid-template-columns: 1fr; } }
