/* S. D Enterprise CRM — phone-first, high-contrast, no web fonts. */
:root {
  --ink: #0b1530; --ink-2: #14244a; --ink-3: #1d3260; --side-text: #c9d4e6;
  --bg: #f1f4f8; --card: #ffffff; --line: #d9e1eb; --line-2: #e9eef4;
  --text: #0f172a; --muted: #55657d; --faint: #8492a6;
  --blue: #0675d0; --blue-d: #055aa3; --blue-bg: #e8f2fc; --cyan: #169ed6;
  --green: #15803d; --green-2: #16a34a; --amber: #c26a05; --red: #c81e1e; --violet: #6d3fd6; --teal: #0d8f8a; --slate: #8a97a8;
  --r: 10px; --r-s: 7px;
  --sh: 0 1px 2px rgba(15, 23, 42, .06), 0 3px 10px rgba(15, 23, 42, .05);
  --gap: clamp(10px, 2.6vw, 18px);
  --side-w: 236px;
  --top-h: 52px;
  --bot-h: 60px;
}
*, *::before, *::after { box-sizing: border-box; }
:where(svg) { width: 1em; height: 1em; flex: 0 0 auto; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: clamp(18px, 4.6vw, 22px); font-weight: 700; }
h2 { font-size: 16px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; color: var(--muted); text-transform: none; }
p { margin: 0 0 8px; }
small, .muted { color: var(--muted); }
.faint { color: var(--faint); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.app { min-height: 100svh; }
.side {
  position: fixed; inset: 0 auto 0 0; width: var(--side-w); background: var(--ink); color: var(--side-text);
  display: flex; flex-direction: column; z-index: 40; transform: translateX(-100%); transition: transform .22s ease;
  overscroll-behavior: contain;
}
.side.open { transform: none; box-shadow: 8px 0 30px rgba(0, 0, 0, .25); }
.side-head { padding: 16px 16px 10px; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.side-head img { display: block; height: 34px; width: auto; }
.side-head small { display: block; margin-top: 6px; color: #8fa1bf; font-size: 12px; letter-spacing: .02em; }
.side nav { flex: 1; overflow-y: auto; padding: 8px 8px 16px; -webkit-overflow-scrolling: touch; }
.nav-group { margin-top: 10px; }
.nav-title { padding: 6px 10px 4px; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #8193b2; }
.nav-link {
  display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px 10px; border-radius: var(--r-s);
  color: var(--side-text); font-size: 14.5px;
}
.nav-link svg { width: 18px; height: 18px; opacity: .85; }
.nav-link:hover { background: var(--ink-2); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--ink-3); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 var(--cyan); }
.nav-link .count { margin-left: auto; font-size: 12px; color: #9fb2d1; font-variant-numeric: tabular-nums; }
.side-foot { padding: 10px 16px 14px; border-top: 1px solid rgba(255, 255, 255, .08); font-size: 12px; color: #8193b2; }
.side-foot a { color: #b7c7e2; }
.scrim { position: fixed; inset: 0; background: rgba(5, 10, 25, .45); z-index: 35; }

.top {
  position: sticky; top: 0; z-index: 30; height: var(--top-h); display: flex; align-items: center; gap: 8px;
  padding: 0 8px 0 4px; background: var(--ink); color: #fff;
}
.top h1 { font-size: 17px; font-weight: 650; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: var(--r-s);
  background: transparent; color: inherit; cursor: pointer;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:hover { background: rgba(255, 255, 255, .08); }

main { padding: var(--gap); padding-bottom: calc(var(--bot-h) + 24px); max-width: 1180px; margin: 0 auto; }

.bottom {
  position: fixed; inset: auto 0 0 0; height: var(--bot-h); display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card); border-top: 1px solid var(--line); z-index: 30; padding-bottom: env(safe-area-inset-bottom);
}
.bottom a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: 10.5px; font-weight: 600; text-decoration: none; min-width: 0;
}
.bottom a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: -.01em; }
.bottom a svg { width: 22px; height: 22px; }
.bottom a.active { color: var(--blue); }

@media (min-width: 960px) {
  .side { transform: none; }
  .scrim, .top .menu-btn, .bottom { display: none !important; }
  .shell { margin-left: var(--side-w); }
  .top { background: var(--card); color: var(--text); border-bottom: 1px solid var(--line); padding-left: 20px; }
  .top .icon-btn:hover { background: var(--line-2); }
  main { padding: 22px 24px 40px; }
}

/* ---------- building blocks ---------- */
.stack > * + * { margin-top: var(--gap); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh); }
.card-pad { padding: clamp(12px, 3.4vw, 18px); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line-2); }
.card-head h2 { font-size: 15px; }
.card-body { padding: 12px 14px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0 2px; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 620px) { .stats { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px) { .stats { grid-template-columns: repeat(5, 1fr); } }
.stat {
  display: block; padding: 12px 12px 10px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--sh); border-left: 4px solid var(--c, var(--blue)); color: var(--text); text-decoration: none; min-height: 72px;
}
.stat:hover { text-decoration: none; border-color: var(--c, var(--blue)); }
.stat .label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stat .value { font-size: clamp(22px, 6vw, 28px); font-weight: 750; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }

.grid2 { display: grid; gap: var(--gap); }
@media (min-width: 900px) { .grid2 { grid-template-columns: 1fr 1fr; } .grid2.wide-left { grid-template-columns: 1.35fr 1fr; } }

/* status: plain text with a small colour dot (no pill chips) */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 600; white-space: nowrap; }
.status::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--dot, var(--slate)); flex: 0 0 auto; }
.s-new { --dot: var(--blue); } .s-called { --dot: var(--violet); } .s-profile { --dot: var(--teal); }
.s-due { --dot: var(--amber); } .s-req { --dot: var(--green-2); } .s-quote { --dot: var(--cyan); }
.s-conv { --dot: var(--green); } .s-notrel { --dot: var(--slate); }
.c-new { --c: var(--blue); } .c-called { --c: var(--violet); } .c-profile { --c: var(--teal); } .c-due { --c: var(--amber); }
.c-req { --c: var(--green-2); } .c-quote { --c: var(--cyan); } .c-conv { --c: var(--green); } .c-notrel { --c: var(--slate); } .c-total { --c: var(--ink); }

/* lists */
.list { list-style: none; margin: 0; padding: 0; }
.item { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-top: 1px solid var(--line-2); }
.item:first-child { border-top: 0; }
a.item { color: var(--text); text-decoration: none; }
a.item:hover { background: #f7f9fc; }
.item .title { font-weight: 650; font-size: 15px; line-height: 1.3; }
.item .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.item .meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; font-size: 12.5px; color: var(--muted); align-items: center; }
.item .side-actions { display: flex; gap: 6px; align-items: center; flex: 0 0 auto; }
.item input[type=checkbox] { margin-top: 3px; }
.empty { padding: 22px 14px; text-align: center; color: var(--muted); font-size: 14px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 42px; padding: 0 14px;
  border-radius: var(--r-s); border: 1px solid var(--line); background: var(--card); color: var(--text);
  font-weight: 600; font-size: 14.5px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn svg { width: 17px; height: 17px; }
.btn:hover { text-decoration: none; border-color: #b9c6d6; background: #f8fafc; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-d); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.danger { color: var(--red); border-color: #f0c4c4; }
.btn.small { min-height: 36px; padding: 0 10px; font-size: 13.5px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (min-width: 620px) { .actions { display: flex; flex-wrap: wrap; } }
.actions .btn { padding: 0 8px; }

/* forms */
.field { display: block; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=date], input[type=time], input[type=number], input[type=tel], input[type=url], select, textarea {
  width: 100%; min-height: 44px; padding: 9px 11px; border: 1px solid #c8d3e0; border-radius: var(--r-s); background: #fff;
  font-size: 16px; color: var(--text);
}
textarea { min-height: 120px; line-height: 1.5; resize: vertical; }
textarea.tall { min-height: 300px; font-size: 15px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 3px solid rgba(6, 117, 208, .28); outline-offset: 1px; border-color: var(--blue); }
.form-grid { display: grid; gap: 12px; }
@media (min-width: 640px) { .form-grid.two { grid-template-columns: 1fr 1fr; } .form-grid .span2 { grid-column: 1 / -1; } }
.check { display: flex; align-items: center; gap: 10px; min-height: 40px; font-size: 14.5px; }
.check input { width: 20px; height: 20px; }
fieldset { border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px 14px; margin: 0; }
legend { padding: 0 6px; font-weight: 700; font-size: 14px; }

.filters { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 760px) { .filters { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px) { .filters { grid-template-columns: repeat(6, 1fr); } }
.searchbar { display: flex; gap: 8px; }
.searchbar input { flex: 1; }

/* tabs: underline style */
.tabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a, .tabs button {
  padding: 10px 12px; border: 0; background: none; color: var(--muted); font-weight: 650; font-size: 14px; white-space: nowrap;
  border-bottom: 3px solid transparent; cursor: pointer; text-decoration: none;
}
.tabs .on { color: var(--blue); border-bottom-color: var(--blue); }

/* key/value details */
.kv { display: grid; grid-template-columns: minmax(110px, 34%) 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; }
.timeline li { position: relative; padding: 0 0 14px 22px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--dot, var(--slate)); }
.timeline li::after { content: ""; position: absolute; left: 8px; top: 18px; bottom: 0; width: 2px; background: var(--line-2); }
.timeline li:last-child::after { display: none; }
.timeline .t-title { font-weight: 650; font-size: 14px; }
.timeline .t-detail { color: var(--muted); font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.timeline .t-when { color: var(--faint); font-size: 12px; }
.ev-email { --dot: var(--blue); } .ev-reply { --dot: var(--green-2); } .ev-bounce { --dot: var(--red); } .ev-status { --dot: var(--violet); }
.ev-note { --dot: var(--amber); } .ev-task { --dot: var(--teal); } .ev-sequence { --dot: var(--ink); } .ev-delivery { --dot: var(--cyan); }

/* notices */
.notice { padding: 10px 12px; border-radius: var(--r-s); border: 1px solid #c9dcf2; background: var(--blue-bg); font-size: 14px; }
.notice.warn { border-color: #f1d3a7; background: #fff6e8; }
.notice.bad { border-color: #f1c0c0; background: #fdf0f0; }
.notice.ok { border-color: #bfe3cb; background: #eefaf2; }
.notice strong { font-weight: 700; }

.progress { height: 10px; border-radius: 6px; background: var(--line-2); overflow: hidden; }
.progress > div { height: 100%; background: var(--blue); width: 0; transition: width .2s; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.simple { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.simple th, table.simple td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
table.simple th { color: var(--muted); font-weight: 650; background: #f7f9fc; }

.preview-frame { width: 100%; min-height: 460px; border: 1px solid var(--line); border-radius: var(--r-s); background: #fff; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-row button { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 5px 8px; font-size: 12.5px; cursor: pointer; color: var(--blue-d); }

/* login */
.login-wrap { min-height: 100svh; display: grid; place-items: center; padding: 20px 16px; background: linear-gradient(180deg, #0b1530 0 38%, var(--bg) 38%); }
.login { width: 100%; max-width: 380px; }
.login .card { padding: 22px 20px 20px; }
.login img { display: block; height: 44px; width: auto; margin: 0 auto 14px; }
.login h1 { text-align: center; font-size: 18px; margin-bottom: 4px; }
.login p { text-align: center; color: var(--muted); font-size: 13.5px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--bot-h) + 14px); transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: #fff; padding: 10px 14px; border-radius: var(--r-s); font-size: 14px; max-width: calc(100% - 32px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .2);
}
.toast.bad { background: var(--red); }
@media (min-width: 960px) { .toast { bottom: 24px; } }

.foot { margin-top: 26px; text-align: center; font-size: 12.5px; color: var(--faint); }
.foot a { color: var(--muted); }
.foot a:hover { color: var(--blue); }
.loading { padding: 28px; text-align: center; color: var(--muted); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mt { margin-top: var(--gap); }
.hide-sm { display: none; }
@media (min-width: 760px) { .hide-sm { display: initial; } }
