/* Client portal (/portal). Self-contained: no external fonts, icons or scripts. */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/Inter-Regular.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/Inter-Medium.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/Inter-SemiBold.woff2") format("woff2");
}

:root {
  --ink: #16181d;
  --ink-soft: #3f4552;
  --muted: #6b7280;
  --line: #e4e6eb;
  --line-strong: #cfd3da;
  --bg: #f4f5f7;
  --card: #ffffff;
  --brand: #eb8603;
  --brand-ink: #a85d00;
  --brand-tint: #fff6e8;
  --black: #0d0d0f;
  --ok: #166534;
  --ok-tint: #ecfdf3;
  --danger: #b42318;
  --danger-tint: #fef3f2;
  --info-tint: #eef4ff;
  --info: #1d4ed8;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

h1,
h2,
h3,
p {
  margin: 0;
}

a {
  color: var(--brand-ink);
}

a:hover {
  color: var(--ink);
}

:focus-visible {
  outline: 3px solid rgba(235, 134, 3, 0.55);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--black);
  color: #fff;
  padding: 10px 16px;
  z-index: 10;
}

.skip-link:focus {
  left: 8px;
  top: 8px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------- header */

.portal-header {
  background: var(--card);
  border-top: 4px solid var(--brand);
  border-bottom: 1px solid var(--line);
}

.portal-header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.portal-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: var(--ink);
  min-width: 0;
}

.portal-brand img {
  display: block;
  height: 34px;
  width: auto;
  max-width: 200px;
}

.portal-brand-name {
  font-size: 1.15rem;
  font-weight: 600;
}

.portal-brand-tag {
  padding-left: 14px;
  border-left: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
}

.portal-account {
  display: flex;
  align-items: center;
  gap: 14px;
}

.portal-account-who {
  text-align: right;
  line-height: 1.3;
  min-width: 0;
}

.portal-account-who strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
}

.portal-account-who span {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
}

.portal-account form {
  margin: 0;
}

/* --------------------------------------------------------------- layout */

.portal-main {
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}

.portal-footer {
  border-top: 1px solid var(--line);
  padding: 18px 20px 26px;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.portal-footer a {
  color: var(--ink-soft);
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.page-head h1 {
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.page-head p {
  color: var(--muted);
  margin-top: 4px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
}

.back-link:hover {
  color: var(--ink);
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-pad {
  padding: 24px;
}

/* -------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid var(--black);
  border-radius: 8px;
  background: var(--black);
  color: #fff;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:hover {
  background: #2a2c31;
  border-color: #2a2c31;
  color: #fff;
}

.btn-secondary {
  background: var(--card);
  border-color: var(--line-strong);
  color: var(--ink);
}

.btn-secondary:hover {
  background: var(--bg);
  border-color: var(--ink-soft);
  color: var(--ink);
}

.btn-small {
  padding: 7px 12px;
  font-size: 0.85rem;
}

.btn-block {
  width: 100%;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex: none;
}

/* --------------------------------------------------------------- alerts */

.alert {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  margin-bottom: 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 0.95rem;
}

.alert-success {
  background: var(--ok-tint);
  border-color: #abefc6;
  color: var(--ok);
}

.alert-error {
  background: var(--danger-tint);
  border-color: #fecdca;
  color: var(--danger);
}

.alert-info {
  background: var(--info-tint);
  border-color: #c7d7fe;
  color: #1e3a8a;
}

/* ---------------------------------------------------------------- forms */

.field {
  margin-bottom: 18px;
}

.field label,
.field legend {
  display: block;
  margin-bottom: 6px;
  padding: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
}

.field .hint {
  display: block;
  margin: -2px 0 8px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 400;
}

.field fieldset,
fieldset.field {
  border: 0;
  padding: 0;
  margin-left: 0;
  margin-right: 0;
  min-width: 0;
}

.input,
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field select,
.field textarea {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  line-height: 1.45;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field textarea {
  min-height: 150px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(235, 134, 3, 0.22);
}

.field.has-error input,
.field.has-error select,
.field.has-error textarea {
  border-color: var(--danger);
}

.field-error {
  display: block;
  margin-top: 6px;
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 500;
}

.field-note {
  margin-top: -8px;
  color: var(--muted);
  font-size: 0.85rem;
}

/* Radio options shown as selectable rows (".field .choice" so these win
   over the plain ".field label" rule above) */
.field .choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  margin-bottom: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
}

.field .choice:hover {
  border-color: var(--ink-soft);
}

.field .choice input {
  width: 16px;
  height: 16px;
  margin: 3px 0 0;
  accent-color: var(--brand);
  flex: none;
}

.field .choice:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-tint);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 20px;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

/* ----------------------------------------------------------- auth pages */

.auth-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  border-top: 4px solid var(--brand);
}

.auth-logo {
  margin-bottom: 22px;
  text-align: center;
}

.auth-logo img {
  height: 44px;
  width: auto;
  max-width: 260px;
}

.auth-logo .portal-brand-name {
  font-size: 1.5rem;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  padding: 32px;
}

.auth-card h1 {
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.auth-card .lead {
  margin: 6px 0 22px;
  color: var(--muted);
  font-size: 0.95rem;
}

.auth-card .alert {
  margin-top: 16px;
  margin-bottom: 0;
}

.auth-card .lead + .alert {
  margin-top: 0;
  margin-bottom: 18px;
}

.auth-links {
  margin-top: 18px;
  text-align: center;
  font-size: 0.9rem;
}

.auth-help {
  max-width: 420px;
  margin-top: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ---------------------------------------------------------- ticket list */

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
}

.tab:hover {
  color: var(--ink);
}

.tab[aria-current="page"] {
  border-bottom-color: var(--brand);
  color: var(--ink);
  font-weight: 600;
}

.tab .count {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #e9ebef;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
}

.ticket-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

.ticket-list li + li {
  border-top: 1px solid var(--line);
}

.ticket-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  color: inherit;
  text-decoration: none;
}

.ticket-row:hover {
  background: #fafafb;
  color: inherit;
}

.ticket-row-main {
  min-width: 0;
}

.ticket-subject {
  display: block;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.ticket-meta {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.85rem;
}

.ticket-row-side {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.chevron {
  width: 16px;
  height: 16px;
  color: var(--line-strong);
}

.list-note {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.empty {
  padding: 56px 24px;
  text-align: center;
}

.empty svg {
  width: 44px;
  height: 44px;
  color: var(--line-strong);
  margin-bottom: 12px;
}

.empty h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.empty p {
  max-width: 420px;
  margin: 6px auto 20px;
  color: var(--muted);
}

/* ---------------------------------------------------------------- chips */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.chip::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.chip-open {
  background: var(--info-tint);
  color: var(--info);
}

.chip-in-progress {
  background: #fff4d6;
  color: #92500a;
}

.chip-closed {
  background: #eceef1;
  color: #4b5563;
}

.chip-reply {
  background: var(--brand-tint);
  color: var(--brand-ink);
}

.chip-reply::before {
  display: none;
}

/* -------------------------------------------------------- ticket detail */

.ticket-head {
  margin-bottom: 20px;
}

.ticket-head h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.ticket-head-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.ticket-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px 24px;
  margin: 0 0 20px;
  padding: 18px 24px;
}

.ticket-facts dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ticket-facts dd {
  margin: 2px 0 0;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.section-title {
  margin: 28px 0 12px;
  font-size: 1.05rem;
  font-weight: 600;
}

.user-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.thread {
  list-style: none;
  margin: 0;
  padding: 0;
}

.message {
  padding: 16px 20px;
  margin-bottom: 12px;
}

.message-staff {
  border-left: 4px solid var(--brand);
}

.message-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  margin-bottom: 6px;
}

.message-author {
  font-weight: 600;
}

.message-tag {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--brand-tint);
  color: var(--brand-ink);
  font-size: 0.75rem;
  font-weight: 600;
}

.message-time {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.82rem;
}

.event {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0 16px;
  color: var(--muted);
  font-size: 0.85rem;
}

.event::before,
.event::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.thread-empty {
  padding: 18px 20px;
  color: var(--muted);
  font-size: 0.95rem;
}

.reply-card {
  margin-top: 20px;
}

.reply-card h2 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.reply-card .hint {
  display: block;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.reply-card textarea {
  min-height: 120px;
}

/* ----------------------------------------------------------- responsive */

@media (max-width: 640px) {
  .portal-main {
    padding: 22px 14px 40px;
  }

  .portal-header-inner {
    padding: 12px 14px;
  }

  .portal-brand img {
    height: 28px;
    max-width: 150px;
  }

  .portal-brand-tag,
  .portal-account-who span {
    display: none;
  }

  .page-head {
    flex-direction: column;
    align-items: stretch;
  }

  .page-head h1 {
    font-size: 1.4rem;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .card-pad,
  .auth-card {
    padding: 20px;
  }

  /* Stack each row: subject on top, status chips underneath */
  .ticket-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 14px 16px;
  }

  .ticket-row-side {
    flex-wrap: wrap;
  }

  .ticket-row .chevron {
    display: none;
  }

  .message-time {
    margin-left: 0;
    width: 100%;
  }

  .form-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }
}
