/* DealDepot Service Desk — follows the client portal: ink panel, warm paper, serif display,
   uppercase mono labels, Deal purple accent, lime highlight. */

:root {
  --ink: #0A0A0A;
  --ink-2: #2C2C2A;
  --paper: #F1EFE8;
  --card: #FAFAF7;
  --white: #FFFFFF;
  --line: rgba(10, 10, 10, 0.08);
  --line-2: rgba(10, 10, 10, 0.14);
  --muted: #6B6B66;
  --faint: #9A9A93;
  --accent: #5028E8;
  --accent-soft: rgba(80, 40, 232, 0.07);
  --accent-line: rgba(80, 40, 232, 0.22);
  --lime: #9BCB3B;
  --amber: #854F0B;
  --amber-soft: rgba(183, 121, 31, 0.08);
  --amber-line: rgba(183, 121, 31, 0.24);
  --red: #B42318;
  --red-soft: rgba(180, 35, 24, 0.07);
  --green: #1E7F4F;
  --green-soft: rgba(30, 127, 79, 0.08);

  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: Inter, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", "Courier New", Consolas, monospace;

  --r: 10px;
  --r-sm: 7px;
  --top: 56px;
}

* { box-sizing: border-box; }
html, body { height: 100%; overflow-x: hidden; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.mono { font-family: var(--mono); }
.label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.logo { font-family: var(--serif); font-size: 21px; font-weight: 500; letter-spacing: -0.01em; color: var(--white); }
.logo b { color: var(--accent); font-weight: 500; filter: brightness(1.35); }
.hidden { display: none !important; }

/* ─── Buttons and fields ─────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: var(--r-sm);
  border: 1px solid var(--line-2); background: var(--white); color: var(--ink);
  font-weight: 500; white-space: nowrap;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { border-color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--white); }
.btn-primary:hover { background: #222; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--white); }
.btn-accent:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); border-color: var(--line-2); }
.btn-block { width: 100%; height: 48px; font-size: 15px; }
kbd {
  font-family: var(--mono); font-size: 10px; padding: 1px 5px; border-radius: 4px;
  border: 1px solid currentColor; opacity: .55;
}

.field {
  width: 100%; border: 1px solid var(--line-2); background: var(--white);
  border-radius: var(--r-sm); padding: 10px 12px; outline: none;
}
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.field { resize: vertical; min-height: 120px; line-height: 1.55; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--muted);
  white-space: nowrap;
}
.chip-accent { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.chip-amber { color: var(--amber); border-color: var(--amber-line); background: var(--amber-soft); }
.chip-red { color: var(--red); border-color: rgba(180,35,24,.25); background: var(--red-soft); }
.chip-green { color: var(--green); border-color: rgba(30,127,79,.25); background: var(--green-soft); }

.notice {
  display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--r-sm);
  background: var(--amber-soft); border: 1px solid var(--amber-line); color: var(--ink-2); font-size: 13px;
}
.notice b { color: var(--amber); }
.error-text { color: var(--red); font-size: 13px; min-height: 18px; }

/* ─── Login ──────────────────────────────────────────────────────────── */

.login { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }
.login-brand {
  background: var(--ink); color: var(--white); padding: 48px 56px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.login-brand .top { display: flex; justify-content: space-between; align-items: center; }
.login-brand .top .label { color: var(--lime); }
.login-brand h1 {
  font-family: var(--serif); font-weight: 400; font-size: clamp(34px, 4vw, 52px);
  line-height: 1.08; letter-spacing: -0.015em; margin: 0 0 18px;
}
.login-brand h1 em { color: var(--lime); }
.login-brand p { color: rgba(255,255,255,.62); max-width: 430px; font-family: var(--serif); font-size: 17px; margin: 0; }
.login-brand .foot { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; border-top: 1px solid rgba(255,255,255,.12); padding-top: 18px; }
.login-brand .foot .label { color: rgba(255,255,255,.45); display: block; margin-bottom: 4px; }
.login-brand .foot span:last-child { font-family: var(--mono); font-size: 12px; }

.login-form { display: flex; align-items: center; justify-content: center; padding: 48px 24px; background: var(--card); }
.login-card { width: 100%; max-width: 380px; }
.login-card .step { color: var(--accent); display: flex; align-items: center; gap: 10px; }
.login-card .step i { display: inline-block; width: 14px; height: 2px; background: var(--accent); opacity: .3; }
.login-card .step i.on { opacity: 1; }
.login-card h2 { font-family: var(--serif); font-weight: 500; font-size: 34px; letter-spacing: -0.012em; margin: 10px 0 6px; }
.login-card .sub { color: var(--ink-2); margin: 0 0 24px; }
.phone { display: flex; align-items: stretch; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--white); overflow: hidden; }
.phone:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.phone span { display: flex; align-items: center; padding: 0 12px; font-family: var(--mono); color: var(--muted); border-right: 1px solid var(--line); }
.phone input { border: 0; outline: 0; padding: 14px 12px; font-family: var(--mono); font-size: 17px; letter-spacing: .08em; width: 100%; }
.otp {
  width: 100%; text-align: center; font-family: var(--mono); font-size: 30px; letter-spacing: .5em;
  padding: 14px 0 14px .5em; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--white); outline: none;
}
.otp:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-card .row { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; }
.login-card .link { background: none; border: 0; padding: 0; font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
.login-card .link[disabled] { color: var(--faint); cursor: default; }
.login-card .secure { margin-top: 26px; text-align: center; color: var(--green); }
.sent-to { display: flex; gap: 14px; align-items: center; padding: 14px 16px; border: 1px solid var(--line); background: var(--white); border-radius: var(--r-sm); margin-bottom: 18px; font-family: var(--mono); }

/* ─── App shell ──────────────────────────────────────────────────────── */

.shell { display: grid; grid-template-rows: var(--top) 1fr; grid-template-columns: minmax(0, 1fr); height: 100vh; }
.main > * { min-width: 0; }
.topbar {
  background: var(--ink); color: var(--white); display: flex; align-items: center; gap: 18px; padding: 0 18px;
}
.topbar .label { color: var(--lime); }
.topbar .spacer { flex: 1; }
.topbar .who { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--white); font-family: var(--mono); font-size: 12px; font-weight: 500;
}
.topbar .btn-ghost { color: rgba(255,255,255,.6); }
.topbar .btn-ghost:hover { color: var(--white); border-color: rgba(255,255,255,.3); }

.main { display: grid; grid-template-columns: 216px 384px 1fr; min-height: 0; }

.rail { border-right: 1px solid var(--line); padding: 18px 10px; overflow-y: auto; background: var(--paper); }
.rail .label { padding: 0 10px; margin: 14px 0 6px; display: block; }
.rail .label:first-child { margin-top: 0; }
.nav {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  padding: 8px 10px; border-radius: var(--r-sm); border: 0; background: transparent; text-align: left; color: var(--ink-2);
}
.nav:hover { background: rgba(10,10,10,.04); }
.nav.on { background: var(--white); color: var(--ink); box-shadow: 0 0 0 1px var(--line); font-weight: 500; }
.nav .n { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.nav .n.hot { color: var(--accent); font-weight: 500; }

.list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--card); }
.list-head { padding: 16px 18px 12px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: baseline; }
.list-head h3 { margin: 0; font-family: var(--serif); font-weight: 500; font-size: 22px; letter-spacing: -0.01em; }
.list-body { overflow-y: auto; flex: 1; }
.item {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 14px 18px 14px 20px; border-bottom: 1px solid var(--line); position: relative;
}
.item:hover { background: rgba(10,10,10,.025); }
.item.on { background: var(--white); box-shadow: inset 3px 0 0 var(--accent); }
.item.unread::before {
  content: ""; position: absolute; left: 8px; top: 21px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}
.item .l1 { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 3px; }
.item .ref { font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: .04em; }
.item .when { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.item .subj { font-weight: 500; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item.unread .subj { font-weight: 600; }
.item .who { color: var(--ink-2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .prev { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.item .tags { display: flex; gap: 5px; margin-top: 8px; flex-wrap: wrap; }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); }
.empty .big { font-family: var(--serif); font-size: 22px; color: var(--ink); margin-bottom: 6px; }

/* ─── Ticket detail ──────────────────────────────────────────────────── */

.detail { min-height: 0; overflow-y: auto; background: var(--paper); }
.detail-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 22px; padding: 22px 26px 40px; align-items: start; }
.detail-wrap > * { min-width: 0; }
.back { display: none; }
.t-head { grid-column: 1 / -1; }
.t-head .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.t-head h1 { font-family: var(--serif); font-weight: 500; font-size: 28px; line-height: 1.2; letter-spacing: -0.012em; margin: 10px 0 8px; }
.t-head .from { color: var(--ink-2); }
.t-head .from b { font-weight: 600; }
.actions {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 16px; padding: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
}
.actions .spacer { flex: 1; }
.owner-line { font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }

.thread { display: flex; flex-direction: column; gap: 12px; }
.msg { background: var(--white); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.msg.out { border-color: var(--accent-line); box-shadow: inset 3px 0 0 var(--accent); }
.msg-h { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); align-items: center; }
.msg-h .who { font-weight: 600; font-size: 13.5px; }
.msg-h .addr { color: var(--muted); font-size: 12.5px; }
.msg-h .when { font-family: var(--mono); font-size: 11px; color: var(--faint); white-space: nowrap; }
.msg-b { padding: 14px 16px 16px; white-space: pre-wrap; word-wrap: break-word; font-size: 14px; line-height: 1.6; color: var(--ink-2); }
.msg-b .quote { color: var(--faint); }
.msg-f { padding: 0 16px 14px; display: flex; gap: 6px; flex-wrap: wrap; }
.event { font-family: var(--mono); font-size: 11px; color: var(--muted); padding: 2px 4px; display: flex; gap: 8px; align-items: center; }
.event::before { content: ""; width: 14px; height: 1px; background: var(--line-2); }
.note {
  border: 1px dashed var(--amber-line); background: var(--amber-soft); border-radius: var(--r); padding: 12px 16px;
}
.note .label { color: var(--amber); }
.note .txt { white-space: pre-wrap; margin-top: 6px; color: var(--ink-2); }

.composer { background: var(--white); border: 1px solid var(--line-2); border-radius: var(--r); padding: 14px; margin-top: 4px; }
.composer.note-mode { background: #FFFDF7; border-color: var(--amber-line); }
.composer .top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 10px; flex-wrap: wrap; }
.composer .bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; gap: 10px; flex-wrap: wrap; }
.composer .hint { font-size: 12px; color: var(--muted); }
.composer textarea { min-height: 150px; }
.resolve-row { display: grid; grid-template-columns: 220px 1fr; gap: 10px; }

/* ─── Client panel ───────────────────────────────────────────────────── */

.side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 0; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.panel h4 { margin: 4px 0 2px; font-family: var(--serif); font-weight: 500; font-size: 19px; letter-spacing: -0.01em; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 6px 10px; margin-top: 12px; font-size: 13px; }
.kv dt { font-family: var(--mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); padding-top: 2px; }
.kv dd { margin: 0; color: var(--ink-2); word-break: break-word; }
.figure { font-family: var(--serif); font-size: 26px; letter-spacing: -0.01em; margin: 4px 0 0; }
.figure.neg { color: var(--red); }
.figure + .label { display: block; margin-top: 2px; }
.mini { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 12px; }
.mini td { padding: 6px 0; border-top: 1px solid var(--line); vertical-align: top; }
.mini td.r { text-align: right; font-family: var(--mono); white-space: nowrap; padding-left: 8px; }
.mini td .s { color: var(--muted); font-size: 11px; }
.related a { display: block; padding: 7px 0; border-top: 1px solid var(--line); color: var(--ink-2); text-decoration: none; font-size: 13px; }
.related a:hover { color: var(--accent); }
.placeholder { display: grid; place-items: center; height: 100%; color: var(--muted); text-align: center; padding: 40px; }
.placeholder .big { font-family: var(--serif); font-size: 26px; color: var(--ink); margin-bottom: 8px; }
.placeholder .keys { margin-top: 18px; display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; font-size: 12px; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--ink); color: var(--white); padding: 11px 18px; border-radius: 999px; font-size: 13px;
  transition: all .2s; z-index: 50; pointer-events: none; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.bad { background: var(--red); }

.skeleton { height: 64px; margin: 12px 18px; border-radius: var(--r-sm); background: linear-gradient(90deg, rgba(10,10,10,.04), rgba(10,10,10,.07), rgba(10,10,10,.04)); background-size: 200% 100%; animation: sh 1.2s infinite; }
@keyframes sh { to { background-position: -200% 0; } }

/* ─── Responsive ─────────────────────────────────────────────────────── */

@media (max-width: 1360px) {
  .detail-wrap { grid-template-columns: 1fr; }
  .side { position: static; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
}
@media (max-width: 1100px) {
  .main { grid-template-columns: 184px 330px 1fr; }
}
@media (max-width: 900px) {
  .login { grid-template-columns: 1fr; }
  .login-brand { padding: 28px 22px; gap: 28px; }
  .login-brand h1 { font-size: 32px; }
  .login-brand .foot { display: none; }
  .topbar { padding: 0 14px; gap: 12px; }
  .topbar .who .nm, .topbar .desk-label { display: none; }
  .main { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .rail { border-right: 0; border-bottom: 1px solid var(--line); display: flex; gap: 6px; overflow-x: auto; padding: 10px 12px; }
  .rail .label { display: none; }
  .nav { width: auto; white-space: nowrap; gap: 8px; }
  .list { border-right: 0; }
  .detail { position: fixed; inset: var(--top) 0 0 0; z-index: 20; transform: translateX(100%); transition: transform .2s; }
  .detail.open { transform: none; }
  .detail-wrap { padding: 14px 14px 40px; }
  .back { display: inline-flex; margin-bottom: 8px; }
  .resolve-row { grid-template-columns: 1fr; }
  .t-head h1 { font-size: 22px; }
  .shell { overflow: hidden; }
  .actions .spacer { flex-basis: 100%; height: 0; }
  .actions .btn { flex: 1; }
}

/* Utility classes (CSP forbids inline style attributes) */
.notice-green { background: var(--green-soft); border-color: rgba(30,127,79,.25); }
.green, .notice b.green { color: var(--green); }
.amber { color: var(--amber); }
.label.role { color: rgba(255,255,255,.45); }
.panel-note { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.chips { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.rel-ref { font-size: 11px; color: var(--muted); }
.skeleton-lg { height: 120px; margin: 26px; }
.gap-12 { height: 12px; }
.gap-8 { height: 8px; }
.mt-14 { margin-top: 14px; }
.phone-gap { margin: 8px 0 6px; }
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }

.chip-btn { cursor: pointer; font: inherit; font-family: var(--mono); font-size: 10px; letter-spacing: .08em; }
.chip-btn:hover { background: var(--accent); color: var(--white); }
.msg.wa:not(.out) { border-left: 3px solid #25D366; }
.hint.amber { color: var(--amber); }
