/* L A Comms brand: navy #161a45, red #d2232a, grey #939598, Open Sans */
:root {
  --navy: #161a45;
  --navy-2: #232864;
  --navy-tint: #eceef7;
  --red: #d2232a;
  --red-dark: #b01c22;
  --red-tint: #fcebec;
  --grey: #939598;
  --grey-text: #5f6268;      /* darker grey for readable body text */
  --line: #e2e3e8;
  --bg: #f6f7fa;
  --card: #ffffff;
  --ok: #1d7a46;
  --ok-tint: #e7f5ec;
  --warn: #8a5a00;
  --warn-tint: #fff5e0;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(22, 26, 69, .06), 0 2px 8px rgba(22, 26, 69, .05);
  --font: 'Open Sans', 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.45;
  color: var(--navy);
  background: var(--bg);
  min-height: 100vh;
}
a { color: var(--navy); }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--grey-text); }
.small { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }

/* ---- Top bar ---------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px;
  background: var(--navy);
  color: #fff;
  border-bottom: 3px solid var(--red);
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand img { border-radius: 6px; box-shadow: 0 0 0 1px rgba(255,255,255,.15); }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-title { font-weight: 700; font-size: 15px; letter-spacing: .2px; }
.brand-sub { font-size: 11px; color: #c4c6d6; letter-spacing: .4px; text-transform: uppercase; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%;
  border: 0; background: transparent; color: #fff; cursor: pointer;
}
.icon-btn:hover, .icon-btn:focus-visible { background: rgba(255,255,255,.12); outline: none; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--red); color: #fff; font-weight: 700; font-size: 12px;
  border: 0; cursor: pointer; flex-shrink: 0;
}
.avatar.lg { width: 38px; height: 38px; font-size: 14px; background: var(--navy); }
.avatar.client { background: var(--navy-2); }

.menu {
  position: absolute; right: 10px; top: 50px; z-index: 30;
  background: #fff; color: var(--navy); border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(22,26,69,.18); min-width: 200px; overflow: hidden;
  border: 1px solid var(--line);
}
.menu .menu-head { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.menu button { display: block; width: 100%; text-align: left; padding: 9px 12px; border: 0; background: none; cursor: pointer; }
.menu button:hover { background: var(--navy-tint); }

/* ---- Layout ----------------------------------------------------------- */
main { padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--line); padding: 12px;
}
.card h2 { font-size: 13px; margin: 0 0 8px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--grey-text); }
.row { display: flex; align-items: center; gap: 8px; }
.row.space { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.loading { display: flex; align-items: center; gap: 10px; justify-content: center; padding: 40px 0; color: var(--grey-text); }
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--red);
  animation: spin .8s linear infinite;
}
.btn .spinner { width: 14px; height: 14px; border-color: rgba(255,255,255,.4); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Welcome ---------------------------------------------------------- */
.welcome { text-align: center; padding: 22px 14px; }
.welcome img { margin-bottom: 8px; }
.welcome h1 { font-size: 17px; margin: 4px 0 6px; }
.welcome p { color: var(--grey-text); margin: 0 0 14px; }
.welcome ul { text-align: left; color: var(--grey-text); padding-left: 18px; margin: 14px 0 0; }
.welcome li { margin: 4px 0; }

/* ---- Buttons & inputs ------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 6px; border: 1px solid transparent;
  font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color .12s ease, border-color .12s ease;
}
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); }
.btn-secondary { background: #fff; color: var(--navy); border-color: var(--line); }
.btn-secondary:hover { border-color: var(--grey); }
.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover { background: var(--navy-2); }
.btn-link { background: none; border: 0; color: var(--navy); padding: 0; font-weight: 600; text-decoration: underline; cursor: pointer; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:focus-visible, .seg button:focus-visible, .ticket:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--red); outline-offset: 1px;
}

label.field { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 12px; color: var(--grey-text); }
input[type=text], input[type=search], input[type=number], select, textarea {
  width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--navy);
  font-weight: 400; font-size: 13px;
}
input:hover, select:hover { border-color: var(--grey); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 10px; cursor: pointer; padding: 4px 0; }
.switch input { appearance: none; width: 34px; height: 20px; border-radius: 10px; background: var(--line); position: relative; cursor: pointer; flex-shrink: 0; transition: background .15s; margin: 0; }
.switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: left .15s; }
.switch input:checked { background: var(--navy); }
.switch input:checked::after { left: 16px; }
.switch span { font-size: 13px; }
.switch small { display: block; color: var(--grey-text); font-size: 11px; }

/* ---- Contact card ----------------------------------------------------- */
.contact { display: flex; gap: 10px; align-items: flex-start; }
.contact-name { font-weight: 700; font-size: 14px; }
.contact-meta { color: var(--grey-text); font-size: 12px; }
.contact-links { display: flex; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.contact-links a { font-size: 12px; font-weight: 600; text-decoration: none; color: var(--red); }
.contact-links a:hover { text-decoration: underline; }
.stats { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.stat { background: var(--navy-tint); border-radius: 6px; padding: 5px 8px; font-size: 12px; }
.stat b { font-weight: 700; }

.banner { border-radius: 6px; padding: 8px 10px; font-size: 12px; display: flex; gap: 8px; align-items: flex-start; }
.banner.info { background: var(--navy-tint); }
.banner.ok { background: var(--ok-tint); color: var(--ok); }
.banner.warn { background: var(--warn-tint); color: var(--warn); }
.banner.red { background: var(--red-tint); color: var(--red-dark); }
.banner a { color: inherit; font-weight: 700; }

.chip {
  display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 600;
  background: var(--navy-tint); color: var(--navy); white-space: nowrap;
}
.chip.sig { background: var(--warn-tint); color: var(--warn); }

/* ---- Segmented control ------------------------------------------------ */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 3px; gap: 3px; }
.seg.two { grid-template-columns: repeat(2, 1fr); }
.seg button { border: 0; background: none; padding: 7px 4px; border-radius: 6px; font-weight: 600; font-size: 12px; cursor: pointer; color: var(--grey-text); }
.seg button[aria-selected=true] { background: var(--navy); color: #fff; }
.seg button:not([aria-selected=true]):hover { background: var(--navy-tint); color: var(--navy); }

/* ---- Tickets ---------------------------------------------------------- */
.tickets { display: flex; flex-direction: column; gap: 6px; }
.ticket {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: #fff; border: 1px solid var(--line); border-left: 3px solid transparent;
  border-radius: 6px; padding: 8px 10px;
}
.ticket:hover { border-color: var(--grey); border-left-color: var(--grey); }
.ticket[aria-pressed=true] { border-color: var(--navy); border-left-color: var(--red); background: #fbfbfe; }
.ticket-top { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--grey-text); }
.ticket-id { font-weight: 700; color: var(--navy); }
.ticket-summary { font-weight: 600; margin-top: 2px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ticket-open { margin-left: auto; color: var(--red); font-weight: 600; text-decoration: none; font-size: 12px; }
.empty { text-align: center; padding: 16px 8px; color: var(--grey-text); }

/* ---- Composer --------------------------------------------------------- */
.composer { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 4px; }
details.section { border: 1px solid var(--line); border-radius: 6px; background: #fff; }
details.section > summary { cursor: pointer; padding: 8px 10px; font-weight: 600; list-style: none; display: flex; align-items: center; justify-content: space-between; }
details.section > summary::-webkit-details-marker { display: none; }
details.section > summary::after { content: '▸'; color: var(--grey); transition: transform .15s; }
details.section[open] > summary::after { transform: rotate(90deg); }
details.section > .section-body { padding: 0 10px 10px; }
.note-editor {
  min-height: 110px; max-height: 320px; overflow: auto; padding: 8px; border: 1px solid var(--line); border-radius: 6px;
  background: #fff; font-size: 12px; line-height: 1.4; word-wrap: break-word;
}
.note-editor:focus { outline: 2px solid var(--navy); outline-offset: 0; }
.note-editor img { max-width: 100%; height: auto; }
.note-editor table { max-width: 100%; }
.att-list { display: flex; flex-direction: column; gap: 4px; }
.att { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 4px 0; }
.att input { margin: 0; accent-color: var(--navy); }
.att .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att .size { color: var(--grey-text); }

.sticky-actions { padding-top: 4px; }

/* ---- Toasts ----------------------------------------------------------- */
.toasts { position: fixed; left: 10px; right: 10px; bottom: 10px; display: flex; flex-direction: column; gap: 6px; z-index: 50; pointer-events: none; }
.toast {
  pointer-events: auto; background: var(--navy); color: #fff; border-radius: 8px; padding: 10px 12px;
  box-shadow: 0 6px 20px rgba(22,26,69,.25); display: flex; gap: 8px; align-items: flex-start; font-size: 12px;
  border-left: 4px solid var(--ok);
  animation: toastIn .18s ease-out;
}
.toast.error { border-left-color: var(--red); }
.toast a { color: #fff; font-weight: 700; }
.toast .x { margin-left: auto; background: none; border: 0; color: #c4c6d6; cursor: pointer; font-size: 14px; line-height: 1; }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- Dialog (sign-in result) / landing -------------------------------- */
body.dialog { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--navy); }
.dialog-card { background: #fff; border-radius: 10px; padding: 28px 24px; max-width: 380px; text-align: center; border-top: 4px solid var(--red); margin: 16px; }
.dialog-card h1 { font-size: 18px; margin: 10px 0 6px; }

.site { max-width: 860px; margin: 0 auto; padding: 24px 16px 48px; }
.site h1 { font-size: 24px; margin: 0 0 4px; }
.site h2 { font-size: 16px; margin: 28px 0 8px; }
.site .card { margin: 12px 0; }
.site code { background: var(--navy-tint); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.site table { border-collapse: collapse; width: 100%; font-size: 13px; }
.site td, .site th { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.status-ok { color: var(--ok); font-weight: 700; }
.status-bad { color: var(--red); font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
