.customer-portal {
  min-height:100vh; margin:0; color:var(--ink,#e4edf3); background:var(--bg,#101922);
  font:14px/1.5 system-ui,sans-serif;
  --portal-line:var(--line,#2c4254); --portal-panel:var(--panel,#172532);
  --portal-muted:var(--muted,#a7bacb); --portal-accent:var(--accent,#71dfc7);
}
.customer-portal * { box-sizing:border-box }
.customer-portal [hidden] { display:none !important }
.portal-layout { max-width:1060px; margin:0 auto; padding:12px 20px 28px }
.portal-registration { max-width:760px }
.portal-masthead,.portal-actions,.portal-filters,.chat-header { display:flex; align-items:center; flex-wrap:wrap; gap:10px }
.portal-masthead { justify-content:space-between; border-bottom:1px solid var(--portal-line); padding:3px 0 12px }
.portal-masthead .portal-brand { font-weight:750; font-size:17px; color:inherit }
.customer-portal a { color:var(--portal-accent); text-underline-offset:3px }
.customer-portal h1 { font-size:clamp(22px,3vw,30px); margin:14px 0 6px; line-height:1.25 }
.customer-portal h2 { font-size:16px; margin:0; overflow-wrap:anywhere }
.portal-muted,.customer-portal small { color:var(--portal-muted) }
.portal-card { min-width:0; padding:14px; background:var(--portal-panel); border:1px solid var(--portal-line); border-radius:9px }
.portal-form,.portal-requests { display:grid; gap:12px; margin:12px 0 }
.portal-form fieldset { min-width:0; margin:0; padding:0; border:0 }
.portal-form legend { font-weight:650; margin:0 0 7px; padding:0 }
.portal-fields,.portal-details { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px 12px }
.customer-portal label { display:grid; gap:4px; min-width:0; font-weight:550 }
.customer-portal input,.customer-portal select,.customer-portal textarea,.customer-portal button {
  color:inherit; background:#101c27; border:1px solid var(--portal-line); border-radius:6px; font:inherit; padding:6px 9px;
}
.customer-portal input,.customer-portal textarea { min-width:0; width:100% }
.customer-portal textarea { min-height:3.5em; max-height:11em; resize:vertical }
.customer-portal button,.customer-portal a.portal-button { cursor:pointer; min-height:33px }
.customer-portal button:disabled { opacity:.5; cursor:default }
.customer-portal input:focus-visible,.customer-portal textarea:focus-visible,.customer-portal button:focus-visible,.customer-portal a:focus-visible {
  outline:2px solid var(--portal-accent); outline-offset:2px;
}
.customer-portal button.portal-primary { background:#1d423e; border-color:#458c7d; color:#e3fff8; font-weight:650 }
.customer-portal button.portal-reject { color:#ffbfc3 }
.portal-terms { background:#2e2720; border:1px solid #735636; border-radius:7px; padding:10px 12px }
.portal-terms p { margin:5px 0 }
.customer-portal .portal-check { display:flex; gap:7px; align-items:flex-start; padding-top:7px }
.portal-check input { width:auto; margin-top:4px; accent-color:var(--portal-accent) }
.portal-status { padding:8px 11px; background:#1d3636; border:1px solid #448174; border-radius:6px; margin:10px 0; overflow-wrap:anywhere }
.portal-status[data-error="true"] { color:#ffc8cc; background:#3c2731; border-color:#8f5364 }
.portal-filters { align-items:end; margin:12px 0 }
.portal-filters p { margin:0 0 5px auto }
.portal-details { margin:8px 0 }
.portal-details dt { color:var(--portal-muted); font-size:12px }
.portal-details dd { margin:0; overflow-wrap:anywhere }
.portal-inbox { display:grid; grid-template-columns:minmax(0,1fr); gap:10px; align-items:start; margin-top:12px }
.portal-inbox:has(.portal-threads:not([hidden])) { grid-template-columns:250px minmax(0,1fr) }
.portal-threads { display:grid; gap:10px; max-height:min(72vh,620px); overflow:auto }
#thread-list { display:grid; gap:5px }
.chat-thread { width:100%; text-align:start; overflow-wrap:anywhere }
.chat-thread strong,.chat-thread small { display:block; line-height:1.4 }
.chat-thread[aria-current="true"] { background:#233c49; border-color:#5a8ba1 }
.chat-header { justify-content:space-between; padding:0 0 8px }
.chat-log { height:clamp(180px,45vh,520px); overflow:auto; display:flex; flex-direction:column; gap:8px; padding:10px; border:1px solid var(--portal-line); border-radius:6px; background:#111e29 }
.chat-bubble { align-self:flex-start; max-width:min(88%,37em); min-width:0; padding:6px 10px; background:#203244; border-radius:7px }
.chat-bubble[data-mine="true"] { align-self:flex-end; background:#1f423f }
.chat-bubble header,.chat-file { display:flex; flex-wrap:wrap; align-items:center; gap:6px 10px }
.chat-bubble .chat-delete { min-height:25px; margin-inline-start:auto; padding:2px 7px; font-size:12px }
.chat-bubble p { margin:4px 0 0; white-space:pre-wrap; overflow-wrap:anywhere }
.chat-file { padding:4px 0 2px; overflow-wrap:anywhere }
.chat-file a { padding:3px 6px; border-radius:4px; border:1px solid #5a968a; text-decoration:none }
.chat-composer { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,.55fr); gap:10px; padding-top:9px }
.chat-composer form { display:grid; align-content:start; gap:7px }
.chat-composer input[type=file] { max-width:100%; font-size:12px }
.portal-chat-drawer {
  position:fixed; right:calc(12px + env(safe-area-inset-right,0px)); bottom:calc(12px + env(safe-area-inset-bottom,0px));
  z-index:99; display:flex; flex-direction:column; min-height:0;
  width:min(465px,calc(100% - 24px - env(safe-area-inset-right,0px)));
  max-height:min(72dvh,610px); background:var(--portal-panel); border:1px solid #456275;
  border-radius:12px; box-shadow:0 12px 36px #0008; overflow:hidden;
}
.portal-chat-drawer:has(.portal-threads:not([hidden])) {
  width:min(690px,calc(100% - 24px - env(safe-area-inset-right,0px)));
}
.portal-chat-drawer-header {
  display:flex; align-items:center; justify-content:space-between; gap:8px; flex:none;
  padding:8px 11px 8px 14px; border-bottom:1px solid var(--portal-line);
}
.portal-chat-drawer .portal-chat-close { min-width:38px; min-height:36px; padding:2px 9px; font-size:21px; line-height:1 }
.portal-chat-drawer-content { min-height:0; overflow:auto; overscroll-behavior:contain; padding:10px 11px 12px }
.portal-chat-drawer .portal-inbox { margin-top:0; gap:8px }
.portal-chat-drawer .portal-card { padding:9px }
.portal-chat-drawer .portal-inbox:has(.portal-threads:not([hidden])) { grid-template-columns:175px minmax(0,1fr) }
.portal-chat-drawer .portal-threads { max-height:min(49dvh,390px) }
.portal-chat-drawer:has(#thread-pane[hidden]) :is(#chat-title,.chat-header:has(#older-messages[hidden])) { display:none }
.portal-chat-drawer .chat-log { height:clamp(125px,28dvh,300px) }
.portal-chat-drawer .chat-composer { grid-template-columns:minmax(0,1fr); gap:7px }
.portal-chat-drawer .chat-composer form { grid-template-columns:minmax(0,1fr) auto; align-items:end; gap:6px }
.portal-chat-drawer .chat-composer textarea { min-height:2.3em; max-height:5.5em }
@media(max-width:660px) {
  .portal-layout { padding:9px 10px 18px }
  .portal-card { padding:10px }
  .portal-inbox:has(.portal-threads:not([hidden])),.chat-composer { grid-template-columns:minmax(0,1fr) }
  .portal-threads { max-height:170px }
  .chat-log { height:clamp(160px,36vh,405px) }
  .portal-chat-drawer .portal-inbox:has(.portal-threads:not([hidden])) { grid-template-columns:minmax(0,1fr) }
  .portal-chat-drawer .portal-threads { max-height:142px }
  .portal-chat-drawer .chat-log { height:clamp(115px,25dvh,240px) }
}
@media(max-width:440px) {
  .portal-fields,.portal-details { grid-template-columns:minmax(0,1fr) }
}
