:root {
  --bg: #0d0f12;
  --panel: #15181d;
  --panel-2: #1b1f25;
  --line: #2a3038;
  --text: #f2f4f7;
  --muted: #969da8;
  --accent: #a9824d;
  --accent-2: #d1ae77;
  --user: #242a32;
  --danger: #ff6b6b;
  --safe: #66d19e;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; color: var(--text); background: var(--bg); overflow: hidden; }
button, textarea, input { font: inherit; }
button { color: inherit; }

.app-shell { display: grid; grid-template-columns: 270px 1fr; height: 100%; min-height: 100dvh; }
.sidebar { display: flex; flex-direction: column; min-width: 0; padding: max(18px, env(safe-area-inset-top)) 14px max(16px, env(safe-area-inset-bottom)); background: #111419; border-right: 1px solid var(--line); }
.brand-row { display: flex; gap: 12px; align-items: center; padding: 0 6px 18px; }
.brand-row strong, .brand-row span { display: block; }
.brand-row span { margin-top: 2px; color: var(--muted); font-size: 12px; }
.brand-mark, .hero-mark { display: block; object-fit: cover; background: var(--bg); box-shadow: 0 0 0 1px #e7c89433, 0 8px 26px #0008; }
.brand-mark { width: 38px; height: 38px; border-radius: 12px; font-weight: 800; }
.new-chat { display: flex; gap: 9px; align-items: center; width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel); cursor: pointer; }
.new-chat:hover { border-color: #4b5562; }
.new-chat span { color: var(--accent-2); font-size: 20px; line-height: 14px; }
.agent-open { margin-top: 8px; border-color: #a9824d66; }
.section-label { padding: 24px 9px 8px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.sessions { min-height: 0; overflow-y: auto; }
.session { display: block; width: 100%; margin: 2px 0; padding: 10px 11px; overflow: hidden; border: 0; border-radius: 9px; color: #cbd0d7; background: transparent; text-align: left; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.session:hover { background: #ffffff0a; }
.session.active { color: #fff; background: #ffffff10; box-shadow: inset 3px 0 var(--accent); }
.session small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.sidebar-footer { display: grid; gap: 3px; margin-top: auto; padding: 14px 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.secure-label { color: var(--muted); font-size: 11px; }

.workspace { position: relative; display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; min-width: 0; min-height: 0; background: linear-gradient(90deg, #0d0f12eb 0%, #0d0f12cf 55%, #0d0f12a6 100%), url("branding/background-v1.jpg") right center / cover no-repeat, var(--bg); }
.topbar { display: flex; align-items: center; gap: 12px; height: 64px; padding: max(8px, env(safe-area-inset-top)) 18px 8px; border-bottom: 1px solid var(--line); background: #0d0f12dd; backdrop-filter: blur(18px); }
.title-block { min-width: 0; flex: 1; }
.title-block strong, .title-block span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title-block strong { font-size: 14px; }
.title-block span { margin-top: 3px; color: var(--muted); font-size: 11px; }
#connection i { display: inline-block; width: 6px; height: 6px; margin-right: 4px; border-radius: 50%; background: var(--muted); }
#connection.online i { background: var(--safe); box-shadow: 0 0 8px #66d19e88; }
.icon-button { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 10px; color: var(--muted); background: transparent; cursor: pointer; }
.icon-button:hover { color: var(--text); background: #ffffff0b; }
#menu { display: none; }

.messages { min-height: 0; overflow-y: auto; padding: 28px max(20px, calc((100% - 820px) / 2)) 160px; scroll-behavior: smooth; }
.welcome { display: grid; justify-items: center; max-width: 500px; margin: min(18vh, 140px) auto 20px; text-align: center; }
.hero-mark { width: 62px; height: 62px; border-radius: 19px; font-size: 25px; font-weight: 800; }
.welcome h1 { margin: 22px 0 8px; font-size: clamp(26px, 5vw, 38px); letter-spacing: -.04em; }
.welcome p { margin: 0; color: var(--muted); line-height: 1.55; }
.message { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 12px; max-width: 820px; margin: 0 auto 26px; }
.avatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; color: #17120b; background: linear-gradient(145deg, var(--accent-2), #765732); font-size: 12px; font-weight: 800; }
.message.user .avatar { color: #d4d9df; background: #343b45; }
.avatar img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.bubble { min-width: 0; padding-top: 4px; color: #e8eaed; font-size: 15px; line-height: 1.62; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.user .bubble { padding: 12px 14px; border: 1px solid #353c47; border-radius: 14px; background: var(--user); }
.message.pending { opacity: .65; }
.message-meta { display: block; margin-top: 6px; color: var(--muted); font-size: 10px; }
.typing { display: inline-flex; gap: 4px; padding: 8px 0; }
.typing i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent-2); animation: pulse 1s infinite alternate; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes pulse { to { opacity: .25; transform: translateY(-3px); } }

.notice { margin: 0 max(20px, calc((100% - 820px) / 2)) 8px; padding: 10px 12px; border: 1px solid #744; border-radius: 10px; color: #ffd7d7; background: #3b2024; font-size: 13px; }
.composer { position: absolute; right: max(20px, calc((100% - 820px) / 2)); bottom: max(18px, env(safe-area-inset-bottom)); left: max(20px, calc((100% - 820px) / 2)); padding: 12px 52px 25px 15px; border: 1px solid #39414c; border-radius: 17px; background: #1a1e24ee; box-shadow: 0 18px 50px #000a; backdrop-filter: blur(18px); }
.composer:focus-within { border-color: #927043; box-shadow: 0 18px 50px #000a, 0 0 0 1px #a9824d55; }
textarea { display: block; width: 100%; max-height: 150px; padding: 0; resize: none; border: 0; outline: 0; color: var(--text); background: transparent; line-height: 1.5; }
textarea::placeholder { color: #818894; }
.send { position: absolute; right: 11px; bottom: 17px; display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 10px; color: #19130d; background: var(--accent-2); font-size: 20px; font-weight: 800; cursor: pointer; }
.send:disabled { opacity: .35; cursor: default; }
.model-open { display: flex; align-items: center; gap: 10px; max-width: 100%; margin: 0 0 12px; padding: 4px 0; border: 0; background: none; color: var(--accent-2); font-size: 14px; cursor: pointer; }
#model-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#model-display { cursor: default; }
.rental-plans { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 18px 0; }
.rental-plans > div { padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.rental-plans strong, .rental-plans span { display: block; font-size: 16px; line-height: 1.5; }
.rental-plans span, .rental-price { color: var(--accent-2); }
.rental-form { display: grid; gap: 16px; padding-top: 16px; }
.rental-form label { display: grid; gap: 8px; font-size: 14px; }
.rental-form input, .rental-form select { box-sizing: border-box; min-width: 0; width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: var(--bg); font-size: 16px; }
.rental-form input:disabled { opacity: .45; }
.rental-form .rental-check { display: flex; align-items: center; line-height: 1.5; }
.rental-check input { width: 20px; height: 20px; flex: 0 0 20px; }
.rental-members { padding-left: 20px; line-height: 1.8; font-size: 14px; }
.rental-create summary, .rental-history summary { cursor: pointer; font-size: 16px; }
.rental-create { margin-bottom: 20px; }
.rental-history { margin-top: 18px; }
.admin-tabs { flex-wrap: wrap; }
.model-dialog { width: min(480px, calc(100vw - 24px)); max-height: min(650px, 80dvh); padding: 20px; border: 1px solid var(--line); border-radius: 20px; color: var(--text); background: var(--panel); box-shadow: 0 24px 90px #000a; }
.model-dialog::backdrop { background: #0009; }
.model-heading { display: flex; align-items: center; justify-content: space-between; }
.model-heading h2 { margin: 0; font-size: 21px; }
.model-hint { font-size: 14px; line-height: 1.5; color: var(--muted); }
.model-search { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); font-size: 16px; }
.model-search:focus-visible, .model-option:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.model-options h3 { font-size: 14px; margin: 24px 0 8px; color: var(--muted); }
.model-option { display: block; width: 100%; min-height: 44px; padding: 11px; margin: 3px 0; border: 1px solid transparent; border-radius: 9px; text-align: left; overflow-wrap: anywhere; font-size: 14px; background: transparent; cursor: pointer; }
.model-option:hover { background: var(--panel-2); }
.model-option[aria-pressed="true"] { color: var(--accent-2); border-color: var(--accent); background: #a9824d15; }
.model-feedback { position: fixed; z-index: 45; left: 50%; top: max(70px, env(safe-area-inset-top)); transform: translateX(-50%); width: max-content; max-width: calc(100vw - 28px); padding: 12px 16px; border: 1px solid var(--accent); border-radius: 12px; background: var(--panel); box-shadow: 0 8px 30px #0008; font-size: 14px; pointer-events: none; }
.sidebar-backdrop { display: none; }
.composer-note { position: absolute; bottom: 7px; left: 15px; color: #737b87; font-size: 9px; }

@media (max-width: 720px) {
  .app-shell { grid-template-columns: 1fr; }
  .workspace { background-position: center, 68% center; }
  .sidebar { position: fixed; z-index: 20; top: 0; bottom: 0; left: 0; width: min(86vw, 310px); transform: translateX(-105%); transition: transform .22s ease; box-shadow: 22px 0 60px #000b; }
  .sidebar.open { transform: translateX(0); }
  .sidebar:not(.open) { visibility: hidden; }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 19; border: 0; background: #0007; touch-action: manipulation; }
  #menu { display: grid; }
  .topbar { height: 58px; padding-right: 10px; padding-left: 10px; }
  .messages { padding: 22px 16px 190px; }
  .message { grid-template-columns: 27px minmax(0, 1fr); gap: 9px; margin-bottom: 22px; }
  .avatar { width: 27px; height: 27px; border-radius: 8px; }
  .bubble { font-size: 14px; }
  .composer { right: 10px; bottom: max(8px, env(safe-area-inset-bottom)); left: 10px; }
  .notice { margin-right: 10px; margin-left: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}

.admin-panel { position: fixed; inset: 0; z-index: 40; overflow-y: auto; padding: 28px max(20px, calc((100vw - 1100px) / 2)) 60px; background: var(--bg); }
.admin-panel:not([hidden]) { display: grid; grid-template-columns: 170px minmax(0, 1fr); align-content: start; column-gap: 26px; }
.admin-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 24px; }
.admin-header { grid-column: 1 / -1; }
.admin-header .section-label { padding: 0; color: var(--accent-2); }
.admin-header h1 { margin: 8px 0 0; font-size: clamp(22px,4vw,32px); letter-spacing: -.035em; }
.admin-button { padding: 11px 15px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); font: inherit; cursor: pointer; }
.admin-button:hover, .admin-button.selected { border-color: var(--accent); color: var(--accent-2); }
.admin-button.primary { background: var(--accent-2); color: var(--bg); font-weight: 650; }
.admin-button:disabled { opacity: .5; cursor: wait; }
.admin-stats { display: grid; grid-column: 2; grid-template-columns: repeat(3,1fr); gap: 12px; margin-bottom: 24px; }
.admin-stats > div { padding: 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.admin-stats strong, .admin-stats span { display: block; }
.admin-stats strong { font-size: 26px; color: var(--accent-2); }
.admin-stats span { margin-top: 6px; color: var(--muted); font-size: 12px; }
.admin-tabs { display: flex; grid-column: 1; grid-row: 2 / span 20; align-self: start; position: sticky; top: 18px; flex-direction: column; flex-wrap: nowrap; gap: 10px; margin: 0; padding-right: 12px; border-right: 1px solid var(--line); }
.admin-tabs .admin-button { width: 100%; text-align: left; }
.admin-panel > .admin-feedback, .admin-panel > section { grid-column: 2; min-width: 0; }
.admin-filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.admin-filters label { display: grid; gap: 7px; flex: 1; min-width: 180px; font-size: 12px; color: var(--muted); }
.admin-filters input, .admin-filters select { width: 100%; min-height: 43px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; font: inherit; font-size: 14px; color: var(--text); background: var(--panel); }
.admin-filters input:focus, .admin-filters select:focus { outline: 1px solid var(--accent); }
.admin-hint { color: var(--muted); font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.admin-list { display: grid; gap: 12px; margin: 18px 0; }
.admin-card { border: 1px solid var(--line); border-radius: 14px; padding: 18px; background: var(--panel); }
.admin-card-title { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.admin-badge { display: inline-block; padding: 5px 8px; border-radius: 7px; background: #343841; font-size: 11px; white-space: nowrap; }
.admin-badge.answered { color: #88dfb3; background: #183729; }
.admin-badge.active { color: var(--accent-2); background: #3c3021; }
.admin-request-detail summary { cursor: pointer; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; }
.admin-request-detail h3 { margin: 22px 0 10px; font-size: 13px; color: var(--accent-2); }
.admin-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; font-size: 14px; }
.admin-feedback { padding: 14px; margin-bottom: 16px; border: 1px solid var(--accent); border-radius: 10px; background: #30271c; line-height: 1.5; }
.admin-empty { padding: 30px 0; text-align: center; color: var(--muted); }
#admin-open { margin-bottom: 12px; color: var(--accent-2); }
#users-open { margin-bottom: 7px; color: var(--accent-2); }
.admin-user-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.admin-user-toolbar h2, .admin-add-heading { margin: 10px 0; font-size: 22px; }
.admin-user-model { display: grid; gap: 6px; margin: 16px 0 12px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); overflow-wrap: anywhere; }
.admin-user-model span, .admin-user-model small { color: var(--muted); font-size: 14px; }
.admin-user-model strong { font-size: 16px; color: var(--accent-2); }
.admin-user-state { font-size: 14px; color: var(--muted); }
.admin-user-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.admin-user-actions button { min-height: 44px; font-size: 14px; }
.admin-user-warning { font-size: 14px; color: #ffc38c; line-height: 1.5; }
.admin-model-person { color: var(--accent-2); font-size: 16px; overflow-wrap: anywhere; }
.vpn-capacity { display: flex; align-items: baseline; gap: 10px; margin: 16px 0; padding: 18px; border: 1px solid #a9824d66; border-radius: 14px; background: linear-gradient(135deg, #211c15, var(--panel)); }
.vpn-capacity strong { color: var(--accent-2); font-size: 34px; line-height: 1; }
.vpn-capacity span { color: var(--muted); font-size: 13px; }
.vpn-warning { margin: 12px 2px 20px; color: #ffc38c; }
#admin-vpn-view .admin-card > .admin-button { margin-top: 12px; }

.agent-panel { position: fixed; inset: 0; z-index: 42; overflow-y: auto; padding: 28px max(20px, calc((100vw - 980px) / 2)) 70px; background: radial-gradient(circle at 88% 0%, #5b432333, transparent 34%), var(--bg); }
.agent-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.agent-header .section-label { padding: 0; color: var(--accent-2); }
.agent-header h1 { margin: 8px 0 0; font-size: clamp(28px, 5vw, 42px); letter-spacing: -.045em; }
.agent-lead { max-width: 760px; margin: 18px 0 24px; color: var(--muted); line-height: 1.6; }
.agent-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.agent-stats > div { padding: 18px; border: 1px solid var(--line); border-radius: 15px; background: #15181de8; }
.agent-stats strong, .agent-stats span { display: block; }
.agent-stats strong { color: var(--accent-2); font-size: 28px; }
.agent-stats span { margin-top: 5px; color: var(--muted); font-size: 12px; }
.agent-create { display: grid; gap: 15px; padding: 20px; border: 1px solid #a9824d66; border-radius: 18px; background: #15181df2; box-shadow: 0 20px 70px #0005; }
.agent-create label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; }
.agent-create input, .agent-create select { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: var(--bg); font: inherit; font-size: 15px; }
.agent-create input:focus, .agent-create select:focus { outline: 1px solid var(--accent); }
.agent-title-row { display: grid; grid-template-columns: minmax(0, 1fr) 46px; gap: 10px; align-items: end; }
.agent-fields { display: grid; grid-template-columns: 1.35fr .85fr .7fr 1fr .8fr; gap: 12px; }
.agent-mic { width: 46px; height: 44px; border: 1px solid var(--line); border-radius: 12px; color: var(--danger); background: var(--bg); cursor: pointer; }
.agent-mic.listening { color: #fff; background: #a92f38; box-shadow: 0 0 0 5px #ff6b6b22; animation: pulse 650ms infinite alternate; }
.agent-mic:disabled { opacity: .35; cursor: default; }
.agent-check { display: flex !important; align-items: center; grid-template-columns: none; gap: 10px !important; color: var(--text) !important; line-height: 1.5; }
.agent-check input { width: 20px; min-height: 20px; flex: 0 0 20px; }
.agent-form-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.agent-form-actions span { color: var(--muted); font-size: 12px; }
.agent-section { margin-top: 30px; }
.agent-section h2 { margin: 0 0 12px; font-size: 18px; }
.agent-list { display: grid; gap: 10px; }
.agent-card { padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.agent-card.overdue { border-color: #8f4d4d; background: #25191c; }
.agent-card.approval { border-color: #a9824d88; background: #201b14; }
.agent-card-head { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.agent-card-head strong { line-height: 1.45; }
.agent-card-meta { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.agent-priority { flex: 0 0 auto; padding: 5px 8px; border-radius: 8px; color: #c7cbd1; background: #30353d; font-size: 10px; }
.agent-priority.p1 { color: #ffd1d1; background: #5a292e; }
.agent-priority.p3 { color: #b8c5d4; background: #27313e; }
.agent-priority.approval { color: #f1d2a2; background: #4a3922; }
.agent-card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.agent-card-actions .admin-button { min-height: 40px; padding: 8px 12px; font-size: 12px; }
.agent-empty { margin: 0; padding: 18px; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); text-align: center; font-size: 13px; }
@media (max-width: 600px) {
  .admin-panel { padding: 16px 10px 40px; }
  .admin-panel:not([hidden]) { grid-template-columns: 108px minmax(0, 1fr); column-gap: 10px; }
  .admin-header { align-items: start; }
  .admin-tabs { top: 12px; gap: 7px; padding-right: 8px; }
  .admin-tabs .admin-button { padding: 10px 8px; font-size: 11px; }
  .admin-stats { gap: 7px; }
  .admin-stats > div { padding: 12px 9px; }
  .admin-stats strong { font-size: 22px; }
  .admin-stats span { font-size: 10px; }
  .admin-card { padding: 14px; }
  .agent-fields { grid-template-columns: 1fr 1fr; }
  .agent-fields label:first-child { grid-column: 1 / -1; }
  .agent-panel { padding: 18px 12px 40px; }
  .agent-header { align-items: start; }
  .agent-header .admin-button { max-width: 112px; font-size: 12px; }
  .agent-stats { gap: 7px; }
  .agent-stats > div { padding: 13px 9px; }
  .agent-stats strong { font-size: 22px; }
  .agent-stats span { font-size: 10px; }
  .agent-create { padding: 15px; }
  .agent-fields { grid-template-columns: 1fr; }
  .agent-card-head { display: grid; }
}
