:root {
  --navy: #12233f;
  --navy-2: #1c3357;
  --copper: #b4703a;
  --copper-ink: #8f5628;
  --teal: #2c7a78;
  --sand: #ede3d0;
  --sand-bg: #f6f1e7;
  --paper: #ffffff;
  --ink: #1a1f2b;
  --muted: #6b7280;
  --line: #e4dccb;
  --danger: #b5482f;

  --st-open: #b4703a;
  --st-with_agent: #2c7a78;
  --st-escalated: #b5482f;
  --st-resolved: #2c7a78;
  --st-closed: #6b7280;

  --radius: 12px;
  --shadow: 0 1px 2px rgba(18, 35, 63, 0.06), 0 8px 24px rgba(18, 35, 63, 0.06);
  --font: "DM Sans", system-ui, sans-serif;
  --display: "DM Serif Display", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--sand-bg);
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }
a { color: var(--copper-ink); }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(44, 122, 120, 0.16), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(180, 112, 58, 0.14), transparent 55%),
    var(--navy);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--paper);
  border-radius: 16px;
  padding: 40px 34px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}
.brand {
  font-family: var(--display);
  font-size: 30px;
  color: var(--navy);
  letter-spacing: -0.01em;
}
.brand .dot { color: var(--copper); }
.logo-row { display: flex; align-items: center; gap: 11px; }
.logo-row img { display: block; width: 34px; height: 34px; }
.login-card .logo-row { justify-content: flex-start; margin-bottom: 2px; }
.login-card .logo-row img { width: 42px; height: 42px; }
.login-card p.sub { color: var(--muted); margin: 6px 0 26px; font-size: 14px; }

label { display: block; font-size: 13px; font-weight: 600; margin: 0 0 6px; color: var(--navy); }
.field { margin-bottom: 16px; }
input, textarea, select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--copper);
  box-shadow: 0 0 0 3px rgba(180, 112, 58, 0.15);
}
textarea { resize: vertical; min-height: 96px; }

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 600;
  background: var(--copper);
  color: #fff;
  transition: background 0.15s, transform 0.05s;
}
.btn:hover { background: var(--copper-ink); }
.btn:active { transform: translateY(1px); }
.btn.full { width: 100%; }
.btn.ghost { background: transparent; color: var(--navy); border-color: var(--line); }
.btn.ghost:hover { background: var(--sand-bg); }
.btn.teal { background: var(--teal); }
.btn.teal:hover { filter: brightness(0.94); }
.btn.sm { padding: 7px 11px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.err { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 16px; }

/* ---------- app shell ---------- */
.topbar {
  height: 62px;
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .brand { font-size: 22px; color: #fff; }
.topbar .brand .dot { color: var(--copper); }
.topbar .right { display: flex; align-items: center; gap: 14px; }
.who { text-align: right; line-height: 1.2; }
.who .nm { font-weight: 600; font-size: 14px; }
.who .rl { font-size: 11px; color: #a9b6cc; text-transform: capitalize; }

.bell { position: relative; background: transparent; border: none; color: #fff; font-size: 19px; padding: 6px; border-radius: 8px; }
.bell:hover { background: var(--navy-2); }
.bell .count {
  position: absolute; top: -2px; right: -2px;
  background: var(--copper); color: #fff; font-size: 10px; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 8px; display: grid; place-items: center; padding: 0 4px;
}

.tabs { display: flex; gap: 4px; }
.tab {
  background: transparent; border: none; color: #c2cde0; font-size: 13px; font-weight: 600;
  padding: 7px 12px; border-radius: 8px;
}
.tab:hover { background: var(--navy-2); color: #fff; }
.tab.active { background: var(--copper); color: #fff; }

.layout { max-width: 1200px; margin: 0 auto; padding: 22px; }

/* ---------- ticket list + detail split ---------- */
.split { display: grid; grid-template-columns: 380px 1fr; gap: 20px; align-items: start; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } }

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.panel-head h2 { font-family: var(--display); font-size: 18px; color: var(--navy); margin: 0; }
.panel-body { padding: 16px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.filters select, .filters input { width: auto; flex: 1 1 120px; padding: 8px 10px; font-size: 13px; }

.ticket-row {
  padding: 13px 16px; border-bottom: 1px solid var(--line); cursor: pointer;
  transition: background 0.12s;
}
.ticket-row:last-child { border-bottom: none; }
.ticket-row:hover { background: var(--sand-bg); }
.ticket-row.active { background: var(--sand); }
.ticket-row .t-sub { font-weight: 600; font-size: 14px; color: var(--navy); margin-bottom: 5px; }
.ticket-row .t-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; text-transform: capitalize;
  padding: 3px 9px; border-radius: 20px; color: #fff; white-space: nowrap;
}
.pill.status-open { background: var(--st-open); }
.pill.status-with_agent { background: var(--st-with_agent); }
.pill.status-escalated { background: var(--st-escalated); }
.pill.status-resolved { background: var(--st-resolved); }
.pill.status-closed { background: var(--st-closed); }
.pill.ghost { background: var(--sand); color: var(--navy); }
.pri { font-weight: 700; text-transform: capitalize; }
.pri.urgent, .pri.high { color: var(--danger); }
.pri.medium { color: var(--copper-ink); }
.pri.low { color: var(--muted); }

.empty { padding: 40px 20px; text-align: center; color: var(--muted); font-size: 14px; }
.empty .big { font-family: var(--display); font-size: 18px; color: var(--navy); display: block; margin-bottom: 6px; }

/* ---------- detail ---------- */
.detail-head { padding: 18px 20px; border-bottom: 1px solid var(--line); }
.detail-head h1 { font-family: var(--display); font-size: 22px; color: var(--navy); margin: 0 0 10px; line-height: 1.2; }
.detail-head .row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 20px; border-bottom: 1px solid var(--line); background: var(--sand-bg); }
.actions select { width: auto; padding: 7px 10px; font-size: 13px; }

.detail-body { display: grid; grid-template-columns: 1fr 240px; gap: 0; }
@media (max-width: 720px) { .detail-body { grid-template-columns: 1fr; } }
.convo { padding: 18px 20px; }
.desc { background: var(--sand-bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 18px; font-size: 14px; color: #33405a; }

.msg { padding: 12px 0; border-bottom: 1px dashed var(--line); }
.msg:last-child { border-bottom: none; }
.msg .m-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.msg .m-who { font-weight: 600; font-size: 13px; color: var(--navy); }
.msg .m-time { font-size: 11px; color: var(--muted); }
.msg .m-body { font-size: 14px; white-space: normal; color: #2a3346; overflow-wrap: anywhere; }
.msg .m-body img { max-width: 100%; height: auto; border-radius: 6px; margin: 6px 0; }
.msg .m-body a { color: var(--copper-ink); word-break: break-word; }
.msg .m-body table { border-collapse: collapse; max-width: 100%; }
.msg .m-body td, .msg .m-body th { border: 1px solid var(--line); padding: 4px 8px; }
.desc img { max-width: 100%; height: auto; border-radius: 6px; }
.desc a { color: var(--copper-ink); word-break: break-word; }
.msg.note { background: #fbf4e9; border: 1px solid #ecd9b6; border-radius: 8px; padding: 12px; }
.msg.note .tag { font-size: 10px; font-weight: 700; color: var(--copper-ink); text-transform: uppercase; letter-spacing: 0.04em; }

.reply { margin-top: 16px; }
.book-wrap { min-height: 100vh; display: flex; align-items: flex-start; justify-content: center; padding: 48px 16px; background: var(--sand-bg); }
.book-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 30px; width: 100%; max-width: 460px; box-shadow: 0 8px 30px rgba(18,35,63,.08); }
.book-card .logo-row { justify-content: center; }
.book-card .sub { text-align: center; color: var(--muted); margin: 6px 0 18px; }
.book-back { display: inline-block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.evt-list { display: flex; flex-direction: column; gap: 10px; }
.evt-item { text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; cursor: pointer; transition: border-color .15s, box-shadow .15s; font-family: inherit; }
.evt-item:hover { border-color: var(--copper); box-shadow: 0 3px 12px rgba(18,35,63,.08); }
.evt-name { font-weight: 600; color: var(--navy); }
.evt-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.evt-desc { font-size: 13px; color: #4a5568; margin-top: 6px; }
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; margin-top: 6px; max-height: 320px; overflow-y: auto; }
.slot-btn { padding: 9px 6px; border: 1px solid var(--teal); color: var(--teal); background: #fff; border-radius: 8px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 600; }
.slot-btn:hover { background: var(--teal); color: #fff; }
.book-tick { width: 52px; height: 52px; border-radius: 50%; background: var(--teal); color: #fff; font-size: 28px; line-height: 52px; margin: 0 auto 4px; }
.day-row { display: flex; flex-wrap: wrap; gap: 6px; }
.day-chip { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); border-radius: 8px; padding: 5px 9px; font-size: 13px; }
.day-chip input { width: auto; }
.btn.xs { padding: 3px 9px; font-size: 12px; margin-left: 4px; }
.rep-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.rep-controls select { padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; }
.rep-head-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; margin-bottom: 12px; font-size: 14px; color: var(--navy); }
.rep-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.rep-stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.rep-stat .rs-val { font-size: 26px; font-weight: 700; color: var(--navy); line-height: 1; }
.rep-stat .rs-label { font-size: 12px; color: var(--muted); margin-top: 6px; font-weight: 600; }
.cust-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #eef5f4; border: 1px solid #cfe3e1; border-radius: 8px; padding: 8px 12px; margin: 0 0 10px; font-size: 13px; color: #2a4b49; }
.cust-banner a { color: var(--copper-ink); font-weight: 600; }
.cust-link { color: var(--copper-ink); text-decoration: none; border-bottom: 1px dotted var(--copper); }
.cust-link:hover { border-bottom-style: solid; }
.dash-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 4px; }
.dash-date { font-size: 13px; color: var(--muted); font-weight: 600; }
.dash-date input { margin-left: 6px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.dash-sec { font-family: var(--display); color: var(--navy); font-size: 15px; margin: 20px 0 10px; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.dash-card { text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; cursor: pointer; transition: box-shadow .15s, transform .05s; font-family: inherit; }
.dash-card:hover { box-shadow: 0 4px 16px rgba(18,35,63,.10); transform: translateY(-1px); }
.dash-card .dc-val { font-size: 30px; font-weight: 700; color: var(--navy); line-height: 1; }
.dash-card .dc-label { font-weight: 600; margin-top: 8px; color: #2a3346; }
.dash-card .dc-hint { font-size: 12px; color: var(--muted); margin-top: 2px; }
.dash-card.warn .dc-val { color: var(--copper-ink); }
.dash-card.danger .dc-val { color: var(--danger); }
.dash-breakdowns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.bar-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: 13px; }
.bar-key { width: 84px; color: #2a3346; text-transform: capitalize; }
.bar-track { flex: 1; height: 10px; background: var(--sand-bg); border-radius: 6px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--teal); border-radius: 6px; }
.bar-val { width: 28px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 640px) { .dash-breakdowns { grid-template-columns: 1fr; } }
.attachments { margin-top: 16px; display: flex; flex-direction: column; gap: 6px; }
.att-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--sand-bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; font-size: 13px; }
.att-name { color: var(--navy); font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.attach-btn { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--copper-ink); border: 1px dashed var(--copper); border-radius: 8px; padding: 7px 12px; background: #fff; }
.attach-btn:hover { background: var(--sand-bg); }
.reply .tabs-mini { display: flex; gap: 6px; margin-bottom: 8px; }
.reply .tabs-mini button { font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 7px; border: 1px solid var(--line); background: #fff; color: var(--navy); }
.reply .tabs-mini button.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.reply .send-row { display: flex; justify-content: flex-end; margin-top: 8px; }

/* ---------- escalation ladder (signature) ---------- */
.ladder { border-left: 1px solid var(--line); padding: 18px 18px 18px 20px; }
.ladder h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 14px; }
.step { position: relative; padding: 0 0 18px 24px; }
.step:before {
  content: ""; position: absolute; left: 6px; top: 3px; bottom: -3px; width: 2px; background: var(--line);
}
.step:last-child:before { display: none; }
.step .node {
  position: absolute; left: 0; top: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: 2px solid var(--line);
}
.step.done .node { background: var(--teal); border-color: var(--teal); }
.step.esc .node { background: var(--copper); border-color: var(--copper); box-shadow: 0 0 0 4px rgba(180,112,58,0.16); }
.step.resolved .node { background: var(--teal); border-color: var(--teal); box-shadow: 0 0 0 4px rgba(44,122,120,0.16); }
.step .s-label { font-size: 13px; font-weight: 600; color: var(--navy); }
.step .s-time { font-size: 11px; color: var(--muted); margin-top: 2px; }
.step .s-level { display: inline-block; margin-top: 3px; font-size: 11px; font-weight: 700; color: var(--copper-ink); }

/* ---------- notifications drawer ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(18,35,63,0.35); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: 340px; max-width: 90vw;
  background: #fff; z-index: 41; box-shadow: -10px 0 40px rgba(0,0,0,0.2);
  display: flex; flex-direction: column;
}
.drawer .d-head { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.drawer .d-head h3 { font-family: var(--display); color: var(--navy); margin: 0; font-size: 18px; }
.notif { padding: 13px 18px; border-bottom: 1px solid var(--line); font-size: 13px; }
.notif.unread { background: var(--sand-bg); }
.notif .n-msg { color: var(--navy); }
.notif .n-time { color: var(--muted); font-size: 11px; margin-top: 3px; }

/* ---------- modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(18,35,63,0.4); z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 460px; box-shadow: 0 30px 70px rgba(0,0,0,0.3); }
.modal .m-head { padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal .m-head h2 { font-family: var(--display); color: var(--navy); margin: 0; font-size: 20px; }
.modal .m-body { padding: 20px 22px; }
.modal .m-foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- manage tables ---------- */
.tablewrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th { text-align: left; padding: 10px 12px; background: var(--sand-bg); color: var(--navy); font-weight: 700; border-bottom: 1px solid var(--line); }
table.grid td { padding: 10px 12px; border-bottom: 1px solid var(--line); }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 11px 18px; border-radius: 10px;
  font-size: 14px; z-index: 80; box-shadow: var(--shadow);
}
.section-title { font-family: var(--display); font-size: 20px; color: var(--navy); margin: 0 0 14px; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.mt16 { margin-top: 16px; }
