:root {
  --bg:          #f4f6fa;
  --surface:    #ffffff;
  --border:    #dde2eb;
  --text:      #0c1a33;
  --muted:    #5b6677;

  /* Brand: deep navy, derived from logo */
  --primary:   #0f2a52;
  --primary-d: #0a1f3d;
  --primary-l: #1a3a6c;
  --accent:    #2d62b0;

  --danger:    #c0392b;
  --ok:        #1f8a4d;
  --warn:      #b27500;

  --radius:    8px;
  --gap:       16px;
  --shadow:    0 1px 2px rgba(12, 26, 51, .05), 0 1px 1px rgba(12, 26, 51, .04);

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--text); font-weight: 600; }
.brand:hover { text-decoration: none; }
.brand__logo {
  height: 28px;
  width: auto;
  display: block;
}
.brand__name {
  font-size: 14px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--primary);
  border-left: 1px solid var(--border);
  padding-left: 12px;
}

.who { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.who__label { font-size: 12px; }
.who strong { color: var(--text); }
.who__form { margin: 0; }

/* ---------- Container ---------- */
.container {
  width: 100%;
  max-width: none;
  margin: 24px 0 64px;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* Reading-optimised pages (single ticket, login, new ticket) keep a sane width. */
.container--narrow {
  max-width: 1080px;
  margin: 24px auto 64px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card h1, .card h2, .card h3 { margin: 0 0 12px; color: var(--text); }
.card h1 { font-size: 20px; }
.card h2 { font-size: 16px; }
.card h3 { font-size: 14px; }

.login { max-width: 400px; margin: 60px auto 0; }
.login h1 { color: var(--primary); }

/* ---------- Toolbar / chips ---------- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.toolbar__filters { display: flex; gap: 8px; flex-wrap: wrap; }

.chip {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
}
.chip:hover { text-decoration: none; color: var(--text); }
.chip.is-active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { text-decoration: none; background: #f7f9fc; }
.btn--primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn--primary:hover { background: var(--primary-d); border-color: var(--primary-d); color: #fff; }
.btn--ghost { background: transparent; }
.btn--ghost:hover { background: #eef1f6; }

.btn--xs {
  padding: 4px 10px;
  font-size: 12px;
  line-height: 1.2;
  border-radius: 6px;
}
.btn--ghost.is-ok {
  background: #effaf2;
  border-color: #c2e7cf;
  color: var(--ok);
}
.btn--ghost.is-err {
  background: #fdecec;
  border-color: #f5c2c2;
  color: #b02121;
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
}
.card__head h2 { margin: 0; }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form--comment { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 20px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-weight: 500; font-size: 13px; }
.field small { font-size: 12px; }

input[type="text"], input[type="password"], textarea, select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font: inherit;
  color: var(--text);
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary-l);
  box-shadow: 0 0 0 3px rgba(15, 42, 82, .15);
}
textarea.mono { font-family: var(--mono); font-size: 12px; }

.picker { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 600px) { .picker { grid-template-columns: 1fr; } }

.actions { display: flex; gap: 10px; justify-content: flex-end; }

.inline-form { display: inline-flex; gap: 8px; align-items: center; }
.inline-form select { width: auto; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.table th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  background: #f7f9fc;
}
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .empty { text-align: center; color: var(--muted); padding: 24px; }

.table tr.row-link { cursor: pointer; transition: background-color .12s; }
.table tr.row-link:hover { background-color: #f3f6fb; }
.table tr.row-link:focus { outline: none; background-color: #eef2f9; }
.table tr.row-link:hover .link { color: var(--primary-d); }

.table td.col-thumb,
.table th.col-thumb { width: 76px; }
.table .row-thumb {
  display: block;
  width: 64px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #f7f9fc;
  overflow: hidden;
}
.table .row-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.table .row-thumb--empty {
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 11px; font-family: var(--mono);
}

.table td.col-snippet,
.table th.col-snippet { width: 320px; }
.table .row-snippet {
  display: block;
  font-family: var(--mono);
  font-size: 11.5px;
  color: #d6e1f0;
  background: #0a1426;
  border-radius: 4px;
  padding: 6px 8px;
  max-width: 320px;
  max-height: 44px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: pre;
  line-height: 1.35;
}
.table .row-snippet--empty {
  background: transparent;
  color: var(--muted);
  font-style: italic;
  padding: 0;
}
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.link { color: var(--primary); font-weight: 500; }
.link:hover { color: var(--primary-d); }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 2px 10px;
  font-size: 12px;
  border-radius: 999px;
  font-weight: 500;
  background: #eef0f4;
  color: var(--text);
}
.badge--open        { background: #e6ecf8; color: var(--primary); }
.badge--in_progress { background: #fff3d6; color: #8a5b00; }
.badge--waiting     { background: #f1e2fa; color: #6a2bb0; }
.badge--resolved    { background: #defbe6; color: #1f7a3f; }
.badge--closed      { background: #e1e4ea; color: #555a66; }

/* ---------- Ticket detail ---------- */
.back { display: inline-block; font-size: 13px; color: var(--muted); }
.back:hover { color: var(--primary); }
.ticket-head__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.ticket-head__top h1 { margin: 4px 0 6px; font-size: 22px; }
.ticket-head__status { display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }

.console {
  background: #0a1426;
  color: #e6edf3;
  padding: 14px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 12px;
  overflow: auto;
  max-height: 420px;
  white-space: pre-wrap;
  word-break: break-word;
}

.prose { white-space: normal; }

.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.thumb {
  display: block;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
  aspect-ratio: 4 / 3;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb--file {
  display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 12px; font-size: 12px; color: var(--text);
}
.thumb:hover { border-color: var(--primary); text-decoration: none; }

.attach-divider {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}
.form--attach { gap: 10px; }

/* ---------- Thread ---------- */
.thread { list-style: none; padding: 0; margin: 0 0 8px; display: flex; flex-direction: column; gap: 10px; }
.thread__item {
  background: #f7f9fc;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
}
.thread__head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  font-size: 13px;
}
.thread__head strong { color: var(--primary); }
.thread__body { white-space: pre-wrap; }

/* ---------- Info button + modal ---------- */
.field__label-row {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 4px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-family: "Times New Roman", Georgia, serif;
  font-style: italic;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  transition: background .15s, color .15s, border-color .15s;
}
.info-btn:hover,
.info-btn:focus {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  outline: none;
}

.info-modal {
  position: fixed;
  inset: 0;
  background: rgba(7, 13, 26, .55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}
.info-modal.is-open { display: flex; }
.info-modal__card {
  background: var(--surface);
  border-radius: 8px;
  padding: 28px 28px 24px;
  max-width: 580px;
  width: 100%;
  max-height: 86vh;
  overflow: auto;
  position: relative;
  box-shadow: 0 24px 60px rgba(7, 13, 26, .35);
}
.info-modal__close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.info-modal__close:hover { background: var(--bg); color: var(--text); }
.info-modal h3 { margin: 0 0 14px; color: var(--primary); font-size: 17px; }
.info-modal h4 { margin: 18px 0 6px; font-size: 13px; color: var(--text); }
.info-modal ul, .info-modal ol { padding-left: 20px; margin: 6px 0; }
.info-modal li + li { margin-top: 6px; }
.info-modal kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #f4f6fa;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
  vertical-align: middle;
  line-height: 1.4;
}
body.modal-locked { overflow: hidden; }

/* ---------- Lightbox ---------- */
.lb {
  position: fixed;
  inset: 0;
  background: rgba(7, 13, 26, .92);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  user-select: none;
}
.lb.is-open { display: flex; }
.lb__stage {
  position: relative;
  max-width: 92vw;
  max-height: 86vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lb__img {
  max-width: 92vw;
  max-height: 86vh;
  object-fit: contain;
  border-radius: 4px;
  background: #000;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
}
.lb__close,
.lb__nav {
  position: absolute;
  background: rgba(255, 255, 255, .08);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .15);
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, border-color .15s;
}
.lb__close:hover,
.lb__nav:hover {
  background: rgba(255, 255, 255, .18);
  border-color: rgba(255, 255, 255, .3);
}
.lb__close {
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  font-size: 22px;
  line-height: 1;
}
.lb__nav {
  top: 50%;
  width: 44px;
  height: 44px;
  font-size: 24px;
  transform: translateY(-50%);
}
.lb__nav--prev { left: 16px; }
.lb__nav--next { right: 16px; }
.lb__nav[hidden] { display: none; }
.lb__counter {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, .85);
  background: rgba(0, 0, 0, .35);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: .04em;
}
.lb__caption {
  position: absolute;
  top: -28px;
  left: 0;
  right: 0;
  text-align: center;
  color: rgba(255, 255, 255, .8);
  font-size: 12px;
  padding: 0 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.thumb { cursor: zoom-in; }
body.lb-locked { overflow: hidden; }

/* ---------- Flash ---------- */
.flash {
  padding: 10px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
}
.flash--error { border-color: #f3c2bd; background: #fff0ee; color: var(--danger); }
.flash--ok    { border-color: #c2e7cf; background: #effaf2; color: var(--ok); }
.flash--info  { border-color: #c8d8f6; background: #eff4fd; color: var(--primary); }
