:root {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #17231d;
  background: #f3f6f4;
  --green-900: #123d2d;
  --green-700: #1d6b4d;
  --green-100: #e8f3ed;
  --line: #d8e0dc;
  --muted: #627069;
  --danger: #a32626;
  --shadow: 0 12px 36px rgba(22, 61, 45, .08);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, select, textarea { font: inherit; }
button, a, select { touch-action: manipulation; }

.portal-header {
  min-height: 104px; padding: 20px clamp(18px, 4vw, 48px); color: #fff;
  background: linear-gradient(130deg, #123d2d, #1d6047);
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
}
.portal-brand p { margin: 0 0 5px; font-size: 11px; letter-spacing: .14em; opacity: .72; }
.portal-brand h1 { margin: 0; font-size: clamp(22px, 3vw, 29px); line-height: 1.2; }
.portal-brand span { display: block; margin-top: 6px; font-size: 13px; opacity: .78; }
.header-actions { display: flex; align-items: flex-end; gap: 9px; }
.header-actions a, .header-actions button, .language-label select {
  min-height: 42px; border: 1px solid #ffffff47; border-radius: 10px; color: #fff;
  background: #ffffff17; padding: 9px 13px; text-decoration: none; cursor: pointer;
}
.header-actions a:hover, .header-actions button:hover, .language-label select:hover { background: #ffffff29; }
.language-label { display: grid; gap: 4px; }
.language-label span { padding-left: 2px; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; opacity: .7; }
.language-label select option { color: #17231d; }

.portal-main { max-width: 1480px; margin: 0 auto; padding: 24px clamp(16px, 3vw, 36px) 44px; }
.access-state { padding: 28px; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: var(--shadow); }
.scope-bar {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px;
  margin-bottom: 18px; padding: 14px 16px; border: 1px solid #bdd8c9; border-radius: 13px; background: #edf7f1;
}
.scope-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; color: #fff; background: var(--green-700); font-weight: 800; }
.scope-bar strong { display: block; font-size: 14px; }
.scope-bar p { margin: 3px 0 0; color: #4f655b; font-size: 12px; }
.role-pill { padding: 6px 10px; border: 1px solid #b2cebf; border-radius: 999px; color: #245b42; background: #fff; font-size: 12px; font-weight: 700; white-space: nowrap; }

.stats { display: grid; grid-template-columns: repeat(5, minmax(110px, 1fr)); gap: 11px; margin-bottom: 18px; }
.stat { padding: 15px 17px; border: 1px solid var(--line); border-radius: 13px; background: #fff; box-shadow: 0 5px 20px rgba(25,65,47,.04); }
.stat strong { display: block; font-size: 27px; line-height: 1.15; }
.stat span { color: var(--muted); font-size: 12px; }
.toolbar { display: grid; grid-template-columns: minmax(260px, 1fr) repeat(3, minmax(140px, 210px)); gap: 10px; margin-bottom: 18px; }
.filter-field { display: grid; gap: 5px; }
.filter-field > span { padding-left: 2px; color: var(--muted); font-size: 11px; font-weight: 700; }
.filter-field input, .filter-field select, .ticket-detail select, .ticket-detail textarea {
  width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; color: #17231d; background: #fff;
}
.filter-field input:focus, .filter-field select:focus, .ticket-detail select:focus, .ticket-detail textarea:focus {
  outline: 3px solid #1d6b4d24; border-color: var(--green-700);
}

.workspace {
  display: grid; grid-template-columns: 370px minmax(0, 1fr); min-height: 650px;
  border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: #fff; box-shadow: var(--shadow);
}
.workspace aside { min-width: 0; border-right: 1px solid var(--line); background: #fafcfb; }
.inbox-head { min-height: 58px; padding: 15px 17px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.inbox-head h2 { margin: 0; font-size: 16px; }
.inbox-head span { color: var(--muted); font-size: 12px; }
.ticket-list { max-height: 750px; overflow: auto; }
.ticket-row { width: 100%; padding: 15px 17px; border: 0; border-bottom: 1px solid #e5eae7; background: transparent; text-align: left; cursor: pointer; }
.ticket-row:hover { background: #f0f6f2; }
.ticket-row.active { background: var(--green-100); box-shadow: inset 3px 0 var(--green-700); }
.ticket-row-title { display: block; margin-bottom: 8px; line-height: 1.35; }
.ticket-row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; }
.ticket-row-footer { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; color: var(--muted); font-size: 11px; }
.type-dot { width: 7px; height: 7px; border-radius: 50%; background: #be602d; }
.type-dot.feature { background: #3869a9; }
.status-chip, .badge { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 999px; color: #225740; background: #e5f1ea; font-size: 11px; font-weight: 700; }
.status-chip.resolved, .status-chip.closed { color: #4e5961; background: #edf0f1; }
.status-chip.in_review { color: #725410; background: #fff3cf; }
.status-chip.planned { color: #315a8a; background: #e8f1fb; }

.ticket-detail { min-width: 0; padding: clamp(22px, 3vw, 36px); overflow: auto; }
.mobile-back { display: none; min-height: 42px; margin: -8px 0 18px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; color: var(--green-700); background: #fff; font-weight: 700; cursor: pointer; }
.empty { padding: 72px 18px; text-align: center; color: var(--muted); }
.detail-head { display: flex; justify-content: space-between; gap: 20px; }
.detail-head h2 { margin: 7px 0; font-size: clamp(22px, 3vw, 30px); line-height: 1.25; }
.meta { color: var(--muted); font-size: 12px; }
.description { white-space: pre-wrap; line-height: 1.65; }
.detail-section { margin-top: 24px; }
.detail-section h3 { margin: 0 0 9px; font-size: 15px; }
.detail-card { padding: 15px 17px; border: 1px solid #e0e6e3; border-radius: 12px; background: #f9fbfa; }
.images { display: flex; gap: 10px; overflow: auto; padding-bottom: 4px; }
.images img { width: 180px; height: 130px; object-fit: cover; border: 1px solid var(--line); border-radius: 11px; }
.review-grid { display: grid; grid-template-columns: 190px minmax(220px, 1fr) auto; align-items: end; gap: 10px; margin-top: 24px; padding: 16px; border-radius: 13px; background: #f0f6f2; }
.review-grid label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 700; }
.review-grid textarea { min-height: 72px; resize: vertical; }
.primary-button, .comment-form button { min-height: 44px; border: 0; border-radius: 10px; padding: 10px 16px; color: #fff; background: var(--green-700); font-weight: 700; cursor: pointer; }
.primary-button:hover, .comment-form button:hover { background: #15563d; }
.primary-button:disabled, .comment-form button:disabled { opacity: .55; cursor: wait; }
.read-only-note { margin-top: 24px; padding: 15px 17px; border: 1px solid var(--line); border-radius: 12px; background: #f8faf9; }
.read-only-note strong { display: block; margin-bottom: 6px; font-size: 13px; }
.read-only-note p { margin: 0; white-space: pre-wrap; color: var(--muted); font-size: 13px; }
.conversation { margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }
.conversation h3 { margin: 0 0 14px; font-size: 17px; }
.comment { margin: 10px 0; padding: 13px 15px; border-radius: 11px; background: #f3f6f4; }
.comment p { margin: 6px 0; white-space: pre-wrap; line-height: 1.5; }
.comment-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 10px; margin-top: 14px; }
.comment-form textarea { min-height: 82px; resize: vertical; }
.danger { min-height: 42px; margin-top: 26px; border: 1px solid #cf6262; border-radius: 10px; padding: 9px 13px; color: var(--danger); background: #fff; cursor: pointer; }
.danger:hover { background: #fff3f3; }
#toast { position: fixed; z-index: 10; right: 22px; bottom: 22px; max-width: calc(100vw - 44px); padding: 11px 16px; border-radius: 10px; color: #fff; background: #17221d; box-shadow: var(--shadow); opacity: 0; transform: translateY(5px); transition: .2s; pointer-events: none; }
#toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(5, minmax(105px, 1fr)); overflow-x: auto; padding-bottom: 5px; }
  .toolbar { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .workspace { display: block; min-height: 540px; }
  .workspace aside { border-right: 0; }
  .ticket-detail { display: none; min-height: 540px; }
  body.detail-open .workspace aside { display: none; }
  body.detail-open .ticket-detail { display: block; }
  .mobile-back { display: inline-flex; align-items: center; }
  .review-grid { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .portal-header { align-items: stretch; flex-direction: column; gap: 16px; }
  .header-actions { align-items: end; display: grid; grid-template-columns: 1fr 1fr; }
  .language-label { grid-column: 1 / -1; }
  .language-label select { width: 100%; }
  .header-actions a, .header-actions button { display: grid; place-items: center; min-height: 44px; }
  .portal-main { padding-top: 16px; }
  .scope-bar { grid-template-columns: auto minmax(0, 1fr); }
  .scope-bar .role-pill { grid-column: 2; justify-self: start; }
  .toolbar { grid-template-columns: 1fr; }
  .search-field { grid-column: auto; }
  .workspace { border-radius: 13px; }
  .ticket-list { max-height: none; }
  .detail-head { flex-direction: column; gap: 5px; }
  .detail-head > .status-chip { align-self: flex-start; }
  .ticket-detail { padding: 20px 17px 28px; }
  .comment-form { grid-template-columns: 1fr; }
  #toast { right: 16px; bottom: 16px; max-width: calc(100vw - 32px); }
}
