.portal { background: var(--bg); }
.portal-nav { margin-left: auto; display: flex; align-items: center; gap: 22px; }
.portal-nav a, .portal-nav .link-btn { color: var(--muted); text-decoration: none; font-size: 0.92rem; }
.portal-nav a:hover, .portal-nav .link-btn:hover { color: var(--text); }
.inline { display: inline; margin: 0; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; color: var(--muted); text-decoration: underline; }
.portal-main { max-width: 860px; margin: 0 auto; padding: 36px clamp(16px, 4vw, 32px) 80px; }
.portal-title { font-family: var(--font-head); font-weight: 600; font-size: clamp(1.5rem, 3vw, 2rem); line-height: 1.25; margin: 0 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.back { display: inline-block; font-size: 0.9rem; color: var(--muted); text-decoration: none; margin-bottom: 14px; }
.back:hover { color: var(--text); }
h2 { font-size: 1.05rem; margin: 0 0 12px; }
.panel h2 + * { margin-top: 0; }
.panel h2:not(:first-child) { margin-top: 22px; }

label { display: block; font-size: 0.9rem; font-weight: 500; margin-bottom: 16px; }
input, select, textarea { display: block; width: 100%; margin-top: 6px; font: inherit; font-weight: 400; color: var(--text); background: #fff; border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); border-color: var(--accent); }
input:disabled { background: var(--soft); color: var(--muted); }
textarea { resize: vertical; line-height: 1.6; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }

.btn { display: inline-flex; align-items: center; justify-content: center; font: inherit; font-weight: 500; font-size: 0.95rem; padding: 10px 20px; border-radius: 9px; border: 1px solid transparent; cursor: pointer; text-decoration: none; }
.btn--primary { background: var(--text); color: #fff; }
.btn--primary:hover { background: #000; }
.btn--primary:disabled { opacity: 0.6; cursor: default; }
.btn--block { width: 100%; }

.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 20px; font-size: 0.93rem; }
.alert--ok { background: #E9F4ED; color: #24593A; border: 1px solid #C6E2D0; }
.alert--err { background: #FBEBE7; color: #8A2E1B; border: 1px solid #F0C6BC; }
.tip-box { background: var(--soft); border-radius: 10px; padding: 12px 16px; font-size: 0.92rem; margin: 16px 0 20px; }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 22px 24px; margin-bottom: 18px; }

/* Auth */
.auth-card { max-width: 420px; margin: 4vh auto 0; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 32px 30px; }
.auth-card h1 { font-family: var(--font-head); font-weight: 600; font-size: 1.7rem; margin: 0 0 6px; }
.auth-card > .muted { margin: 0 0 22px; }
.auth-foot { text-align: center; font-size: 0.9rem; color: var(--muted); margin: 18px 0 0; }

/* Ticket list */
.list-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 24px; }
.list-head .muted { margin: 0; }
.tickets { list-style: none; padding: 6px 0; }
.tickets li { display: flex; align-items: center; gap: 14px; padding: 0 20px; border-top: 1px solid var(--soft); }
.tickets li:first-child { border-top: 0; }
.tickets a { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 14px 0; text-decoration: none; color: var(--text); min-width: 0; }
.tickets__subject { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tickets__meta { font-size: 0.83rem; }
.tickets li.is-unread .tickets__subject { font-weight: 600; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 8px; vertical-align: middle; }
.empty { text-align: center; padding: 40px 24px; }
.empty p { margin: 0 0 6px; }

.status { flex-shrink: 0; font-size: 0.75rem; font-weight: 500; padding: 3px 10px; border-radius: 20px; }
.status--open { background: #FFF2D9; color: #85600F; }
.status--answered { background: #E4F1E8; color: #2D6B43; }
.status--closed { background: var(--soft); color: var(--muted); }

/* Thread */
.ticket-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 22px; }
.thread { display: flex; flex-direction: column; gap: 14px; margin-bottom: 22px; }
.msg { border: 1px solid var(--border); border-radius: 14px; padding: 16px 20px; background: var(--panel); }
.msg--staff { background: color-mix(in srgb, var(--accent) 7%, #fff); border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }
.msg__meta { font-size: 0.88rem; margin-bottom: 8px; }
.staff-tag { font-size: 0.72rem; background: var(--accent); color: #fff; padding: 2px 8px; border-radius: 20px; margin-left: 4px; }
.msg__body { font-size: 0.97rem; line-height: 1.7; overflow-wrap: anywhere; }
.msg__files { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.msg__files img { width: 140px; height: 100px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.reply__bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.reply label:first-of-type { margin-bottom: 12px; }
.file-pick { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-weight: 400; margin: 0 0 16px; cursor: pointer; }
.reply__bar .file-pick { margin: 0; }
.file-pick input { width: auto; margin: 0; padding: 6px; font-size: 0.85rem; }
.close-form { text-align: center; }

@media (max-width: 700px) {
  .two { grid-template-columns: 1fr; }
  .portal-nav { gap: 14px; }
  .portal-nav a[href="../"] { display: none; }
  .list-head, .ticket-head { flex-direction: column; }
}
