:root { --access-orange: #f5790a; }

.auth-screen { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; background: #0d0f11; color: #f4f4f4; }
.authenticated .auth-screen { display: none; }
.auth-panel { width: 390px; max-width: calc(100vw - 32px); padding: 34px 36px; border: 1px solid #34373b; border-radius: 8px; background: #181a1d; box-shadow: 0 30px 90px #0009; }
.auth-mark { display: grid; place-items: center; width: 42px; height: 42px; margin-bottom: 22px; border-radius: 7px; background: var(--access-orange); color: #fff; font-weight: 800; }
.auth-panel h1 { margin: 8px 0; font-size: 24px; letter-spacing: 0; }
.auth-panel > p { margin: 0 0 24px; color: #9298a1; line-height: 1.6; }
.auth-form { display: grid; gap: 15px; }
.auth-form label { display: grid; gap: 7px; color: #c7cbd1; font-size: 12px; }
.auth-form input { height: 42px; padding: 0 12px; border: 1px solid #3a3e43; border-radius: 6px; outline: 0; background: #111315; color: #fff; font: inherit; }
.auth-form input:focus { border-color: var(--access-orange); }
.auth-submit { height: 42px; border: 0; border-radius: 6px; background: var(--access-orange); color: #fff; font-weight: 700; cursor: pointer; }
.auth-submit:disabled { opacity: .6; }
.auth-message { min-height: 18px; color: #ff8c78; font-size: 12px; }
.account-button { max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.workspace-view:has(.ai-workbench) .workspace-view-header { display: none; }
.workspace-view:has(.ai-workbench) .workspace-body { height: 100%; padding: 0; }
.ai-workbench { display: grid; grid-template-columns: 240px minmax(0, 1fr); height: 100%; min-height: 0; background: #0d0f11; color: #f3f3f3; }
.chat-history-panel { display: flex; flex-direction: column; gap: 12px; padding: 22px 14px; border-right: 1px solid #2a2d31; background: #15171a; }
.new-chat-button { height: 36px; padding: 0 12px; border: 1px solid #34383d; border-radius: 6px; background: #272a2f; color: #fff; text-align: left; font-weight: 700; cursor: pointer; }
.chat-search { padding: 8px 11px; color: #8f96a0; }
.chat-history-panel > strong { margin-top: 18px; padding: 0 11px; color: #b7bbc2; font-size: 12px; }
.recent-chats { display: grid; gap: 6px; color: #737a84; font-size: 12px; }
.chat-shell { position: relative; display: flex; flex-direction: column; align-items: center; min-width: 0; height: 100%; padding: 70px 40px 34px; background: #0d0f11; }
.chat-model-state { position: absolute; top: 20px; right: 24px; padding: 6px 10px; border: 1px solid #294b3b; border-radius: 14px; background: #11261d; color: #65c99b; font-size: 11px; }
.chat-model-state.warning { border-color: #664c2d; background: #2a2116; color: #e7a457; }
.chat-messages { width: min(820px, 100%); flex: 1; min-height: 0; overflow: auto; padding: 22px 0 180px; }
.chat-message { display: grid; grid-template-columns: 30px minmax(0, 1fr); column-gap: 10px; margin: 0 0 20px; }
.chat-message > span { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--access-orange); color: #fff; font-size: 10px; font-weight: 800; }
.chat-message.user > span { background: #343940; }
.chat-message p { margin: 3px 0 0; padding: 0 4px; color: #dfe2e7; font-size: 13px; line-height: 1.75; overflow-wrap: anywhere; }
.chat-message.user p { color: #adb3bc; }
.chat-message button { grid-column: 2; justify-self: start; margin-top: 9px; padding: 6px 10px; border: 1px solid #3b3f45; border-radius: 5px; background: #202329; color: #d8dce2; cursor: pointer; }
.chat-empty { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); width: min(520px, calc(100% - 40px)); text-align: center; }
.chat-empty.hidden { display: none; }
.chat-empty h2 { margin: 0 0 8px; font-size: 26px; letter-spacing: 0; }
.chat-empty p { margin: 0; color: #777f89; }
.chat-form { position: absolute; left: 50%; bottom: 88px; transform: translateX(-50%); display: grid; grid-template-columns: 34px minmax(0, 1fr) 38px; align-items: center; width: min(820px, calc(100% - 64px)); min-height: 74px; padding: 10px 12px; border: 1px solid #3a3e44; border-radius: 8px; background: #1b1e22; box-shadow: 0 18px 50px #0008; }
.chat-form textarea { width: 100%; max-height: 110px; resize: none; border: 0; outline: 0; background: transparent; color: #fff; font: inherit; line-height: 1.5; }
.chat-form textarea::placeholder { color: #777e87; }
.chat-form button { width: 34px; height: 34px; border: 0; border-radius: 50%; background: #a85b21; color: #fff; cursor: pointer; }
.chat-form button:disabled { opacity: .55; }
.chat-form .chat-add { background: transparent; color: #aeb4bd; font-size: 20px; }
.chat-presets { position: absolute; bottom: 34px; display: flex; gap: 8px; max-width: calc(100% - 40px); overflow: auto; }
.chat-presets button { height: 34px; padding: 0 14px; border: 1px solid #34383d; border-radius: 17px; background: #15171a; color: #c8ccd2; white-space: nowrap; cursor: pointer; }
.chat-presets button:hover { border-color: #5a5f67; color: #fff; }

.account-settings { margin-top: 18px; padding: 20px 22px; border-top: 1px solid #e3e6ea; background: #fff; color: #222831; }
.account-settings > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.account-settings h2 { margin: 5px 0 2px; font-size: 18px; }
.account-settings header p { margin: 0; color: #7d8693; font-size: 12px; }
.permission-matrix { display: flex; flex-wrap: wrap; gap: 8px; margin: 17px 0; }
.permission-matrix span { padding: 6px 9px; border: 1px solid #e1e4e9; border-radius: 5px; background: #f8f9fb; color: #626b77; font-size: 11px; }
.create-user-form { display: grid; grid-template-columns: 1fr 1fr 1.2fr 120px 110px; gap: 8px; margin: 16px 0; }
.create-user-form input, .create-user-form select { min-width: 0; height: 38px; padding: 0 10px; border: 1px solid #d9dde3; border-radius: 5px; background: #fff; color: #303641; }
.create-user-form button { border: 0; border-radius: 5px; background: #20242a; color: #fff; cursor: pointer; }
.user-table { border: 1px solid #e1e4e8; border-radius: 6px; overflow: hidden; }
.user-table-head, .user-row { display: grid; grid-template-columns: minmax(180px, 1.5fr) 140px 90px 170px; align-items: center; gap: 12px; min-height: 54px; padding: 0 14px; border-bottom: 1px solid #e7e9ed; }
.user-table-head { min-height: 38px; background: #f6f7f9; color: #747d89; font-size: 11px; }
.user-row:last-child { border-bottom: 0; }
.user-row > span:first-child { display: grid; gap: 3px; }
.user-row small { color: #8b939e; }
.user-row select { height: 32px; border: 1px solid #d9dde3; border-radius: 5px; background: #fff; color: #38404b; }
.account-switch { position: relative; width: 34px; height: 20px; }
.account-switch input { position: absolute; opacity: 0; }
.account-switch span { position: absolute; inset: 0; border-radius: 10px; background: #c7ccd3; cursor: pointer; }
.account-switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: .15s; }
.account-switch input:checked + span { background: #25a26f; }
.account-switch input:checked + span::after { transform: translateX(14px); }
.user-actions { display: flex; gap: 7px; }
.user-actions button { padding: 5px 7px; border: 1px solid #d7dbe1; border-radius: 4px; background: #fff; color: #5f6875; font-size: 11px; cursor: pointer; }
.user-actions button:last-child { color: #bf4d45; }
.user-actions button:disabled { opacity: .35; }
.access-note, .users-loading { padding: 16px; border: 1px dashed #d9dde3; border-radius: 6px; color: #747d88; }
.access-note.error { color: #c84e45; }

@media (max-width: 900px) {
  .ai-workbench { grid-template-columns: 180px minmax(0, 1fr); }
  .chat-shell { padding-left: 20px; padding-right: 20px; }
  .create-user-form { grid-template-columns: 1fr 1fr; }
  .user-table { overflow-x: auto; }
  .user-table-head, .user-row { min-width: 720px; }
}

@media (max-width: 650px) {
  .ai-workbench { grid-template-columns: 1fr; }
  .chat-history-panel { display: none; }
  .chat-form { width: calc(100% - 24px); }
  .chat-presets { bottom: 26px; }
  .chat-shell { padding-top: 58px; }
  .account-button { display: none; }
}

/* Login verification surface */
html, body { min-width: 0; }
.auth-screen { display: block; overflow: auto; background: #0b0d0f; }
.auth-site-header { position: fixed; inset: 0 0 auto; z-index: 2; display: flex; align-items: center; justify-content: space-between; height: 76px; padding: 0 60px; }
.auth-brand { display: inline-flex; align-items: center; gap: 9px; color: #ff7a00; text-decoration: none; }
.auth-brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid #ff7a00; border-radius: 7px; font-size: 11px; font-weight: 800; }
.auth-brand strong { display: block; color: #ff7a00; font-size: 17px; letter-spacing: .2px; }
.auth-brand small { display: block; margin-top: 1px; color: #69717c; font-size: 10px; }
.auth-site-nav { display: flex; align-items: center; gap: 34px; margin-left: auto; margin-right: 230px; }
.auth-site-nav a { color: #e5e7eb; font-size: 13px; font-weight: 650; text-decoration: none; }
.auth-site-nav a:hover { color: #ff8b25; }
.auth-site-actions { position: absolute; right: 60px; display: flex; gap: 8px; }
.auth-site-actions button { height: 38px; padding: 0 14px; border: 1px solid #2b3036; border-radius: 9px; background: #14171a; color: #e9ebee; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.auth-site-actions button:hover, .auth-site-actions button.current { border-color: #3e454d; background: #1c2024; }
.auth-panel { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -45%); width: min(460px, calc(100% - 32px)); max-width: calc(100% - 32px); padding: 34px 28px 48px; border: 1px solid #34383d; border-radius: 7px; background: #181a1d; box-shadow: 0 24px 70px #0008; }
.auth-heading { margin-bottom: 27px; text-align: center; }
.auth-heading h1 { margin: 0 0 8px; color: #f4f5f6; font-size: 28px; font-weight: 800; }
.auth-heading p { margin: 0; color: #8a929c; font-size: 13px; }
.auth-form { gap: 17px; }
.auth-field { gap: 8px; }
.auth-field-label { display: flex; align-items: center; justify-content: space-between; color: #e0e3e7; font-size: 12px; font-weight: 700; }
.auth-input-wrap { position: relative; display: flex; align-items: center; height: 48px; border: 1px solid #353a41; border-radius: 7px; background: #101214; }
.auth-input-wrap:focus-within { border-color: #727a86; box-shadow: 0 0 0 3px #ffffff08; }
.auth-input-icon { display: grid; place-items: center; width: 40px; color: #858d97; font-size: 17px; }
.auth-input-wrap input { flex: 1; width: 100%; height: 46px; padding: 0 10px 0 0; border: 0; outline: 0; background: transparent; color: #eff1f3; font: inherit; font-size: 13px; }
.auth-input-wrap input::placeholder { color: #68717d; }
.auth-forgot { padding: 0; border: 0; background: transparent; color: #b9c0c9; font: inherit; font-size: 12px; cursor: pointer; }
.auth-forgot:hover, .auth-contact button:hover, .auth-consent a:hover { color: #ff902b; }
.password-toggle { width: 38px; height: 38px; margin-right: 4px; border: 0; border-radius: 50%; background: transparent; color: #7f8893; cursor: pointer; }
.password-toggle:hover { background: #ffffff08; color: #e8eaed; }
.auth-consent { display: flex; align-items: center; gap: 8px; color: #9ba2ab; font-size: 11px; line-height: 1.4; }
.auth-consent input { flex: 0 0 auto; width: 17px; height: 17px; margin: 0; accent-color: #e7e9ec; }
.auth-consent a { color: #b6bdc6; text-decoration: underline; }
.auth-submit { width: 100%; height: 48px; margin-top: 2px; border-radius: 7px; background: #f1f2f3; color: #16191d; font-size: 14px; }
.auth-submit:hover { background: #fff; }
.auth-message { min-height: 16px; margin-top: -7px; text-align: center; }
.auth-contact { margin-top: 26px; color: #858e99; text-align: center; font-size: 12px; }
.auth-contact button { padding: 0; border: 0; background: transparent; color: #c4cad1; font: inherit; text-decoration: underline; cursor: pointer; }

@media (max-width: 900px) {
  .auth-site-header { padding: 0 24px; }
  .auth-site-nav { gap: 18px; margin-right: 180px; }
  .auth-site-actions { right: 24px; }
  .auth-site-actions button:first-child { display: none; }
}

@media (max-width: 650px) {
  .auth-site-header { height: 62px; padding: 0 16px; }
  .auth-site-nav { display: none; }
  .auth-site-actions { right: 16px; }
  .auth-site-actions button { height: 32px; padding: 0 10px; }
  .auth-panel { top: 50%; width: calc(100vw - 28px); padding: 28px 20px 34px; }
}

.auth-mode-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; margin: -8px 0 22px; padding: 3px; border: 1px solid #30343a; border-radius: 8px; background: #101214; }
.auth-mode-tabs button { height: 32px; border: 0; border-radius: 6px; background: transparent; color: #858d98; font: inherit; font-size: 12px; cursor: pointer; }
.auth-mode-tabs button.active { background: #292d32; color: #fff; box-shadow: 0 2px 7px #0005; }
.auth-mode-panel { display: none; }
.auth-mode-panel.active { display: grid; }
.send-code-button { flex: 0 0 auto; min-width: 94px; height: 34px; margin-right: 6px; padding: 0 10px; border: 0; border-left: 1px solid #30353b; background: transparent; color: #d0d5db; font: inherit; font-size: 11px; cursor: pointer; }
.send-code-button:hover { color: #ff902b; }
.send-code-button:disabled { color: #68717d; cursor: wait; }
.register-two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.register-two-columns .auth-input-wrap input { padding-left: 12px; }
.auth-panel:has([data-auth-panel="register"].active) { top: 52%; padding-top: 26px; padding-bottom: 30px; }
.auth-panel:has([data-auth-panel="register"].active) .auth-heading { margin-bottom: 18px; }
.auth-panel:has([data-auth-panel="register"].active) .auth-mode-tabs { margin-bottom: 16px; }
.auth-panel:has([data-auth-panel="register"].active) .auth-form { gap: 12px; }
.auth-panel:has([data-auth-panel="register"].active) .auth-contact { display: none; }

.user-entry { border-bottom: 1px solid #e7e9ed; }
.user-entry:last-child { border-bottom: 0; }
.user-entry .user-row { border-bottom: 0; }
.user-actions { flex-wrap: wrap; }
.user-permission-editor { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 14px 14px; }
.user-permission-editor[hidden] { display: none; }
.user-permission-editor label { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 10px; border: 1px solid #dfe3e8; border-radius: 5px; background: #f8f9fb; color: #5f6874; font-size: 11px; cursor: pointer; }
.user-permission-editor input { margin: 0; accent-color: #20242a; }

/* Team access manager */
.account-settings { padding: 24px; }
.permission-matrix span { display: inline-flex; align-items: center; gap: 5px; }
.permission-matrix b { color: #303742; font-weight: 750; }
.access-summary { display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)); gap: 10px; margin: 18px 0; }
.access-summary article { display: grid; gap: 6px; padding: 13px 15px; border: 1px solid #e0e4e9; border-radius: 6px; background: #f8f9fb; }
.access-summary span { color: #737d89; font-size: 10px; }
.access-summary strong { color: #20262e; font-size: 20px; }
.create-account-panel, .member-management { border: 1px solid #dfe3e8; border-radius: 6px; background: #fff; }
.member-management { margin-top: 16px; }
.create-account-panel > header, .member-management > header { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 58px; padding: 0 16px; border-bottom: 1px solid #e4e7eb; background: #fafbfc; }
.create-account-panel > header > div, .member-management > header > div { display: grid; gap: 3px; }
.create-account-panel > header strong, .member-management > header strong { color: #252b34; font-size: 13px; }
.create-account-panel > header span, .member-management > header span { color: #818a96; font-size: 10px; }
.create-user-form { display: block; margin: 0; padding: 16px; }
.create-user-grid { display: grid; grid-template-columns: 1fr 1.2fr 1.2fr 150px; gap: 11px; }
.create-user-grid > label { display: grid; gap: 6px; min-width: 0; color: #5f6874; font-size: 10px; }
.create-user-form input, .create-user-form select { width: 100%; box-sizing: border-box; }
.create-password-field { display: grid; grid-template-columns: minmax(0, 1fr) 52px; }
.create-password-field input { border-radius: 5px 0 0 5px; }
.create-password-field button { border-radius: 0 5px 5px 0; background: #eef1f4; color: #505a66; font-size: 10px; }
.create-permission-block { display: grid; grid-template-columns: 180px minmax(0, 1fr); align-items: center; gap: 14px; margin-top: 14px; padding: 12px; border: 1px solid #e4e7eb; border-radius: 6px; background: #fafbfc; }
.create-permission-block > div:first-child { display: grid; gap: 4px; }
.create-permission-block strong { font-size: 11px; }
.create-permission-block span { color: #818a96; font-size: 9px; }
.permission-check-grid { display: flex; flex-wrap: wrap; gap: 7px; }
.permission-check-grid label { display: inline-flex; align-items: center; gap: 6px; min-height: 31px; padding: 0 10px; border: 1px solid #dfe3e8; border-radius: 5px; background: #fff; color: #59636f; font-size: 10px; cursor: pointer; }
.permission-check-grid label:has(input:checked) { border-color: #9ea8b4; background: #f0f3f6; color: #252d36; }
.permission-check-grid input { width: 14px; height: 14px; margin: 0; accent-color: #242a31; }
.permission-check-grid input:disabled + span { opacity: .55; }
.create-user-form > footer { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 14px; }
.create-user-form > footer span { min-height: 16px; color: #c35448; font-size: 10px; }
.create-user-form > footer button { min-width: 142px; height: 38px; padding: 0 14px; }
.create-user-form > footer button:disabled { opacity: .55; cursor: wait; }
.member-tools { display: flex; align-items: center; gap: 8px; }
.member-tools input, .member-tools select { height: 34px; border: 1px solid #d9dde3; border-radius: 5px; outline: none; background: #fff; color: #3b434d; font: inherit; font-size: 10px; }
.member-tools input { width: 190px; padding: 0 10px; }
.member-tools select { min-width: 112px; padding: 0 8px; }
.member-tools input:focus, .member-tools select:focus { border-color: #9ca6b2; }
.member-management .user-table { border: 0; border-radius: 0; }
.user-table-head, .user-row { grid-template-columns: minmax(310px, 2fr) 140px 120px 150px; min-height: 64px; padding: 0 16px; }
.user-table-head { min-height: 38px; }
.user-entry[hidden] { display: none; }
.member-identity { display: grid; gap: 3px; min-width: 0; padding: 10px 0; }
.member-identity > strong { display: flex; align-items: center; gap: 7px; }
.member-identity > strong i { padding: 2px 5px; border-radius: 3px; background: #edf0f3; color: #68727e; font-size: 8px; font-style: normal; font-weight: 600; }
.member-identity > small { overflow: hidden; color: #8a939f; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.member-permission-summary { display: flex !important; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.member-permission-summary em { padding: 2px 5px; border-radius: 3px; background: #f0f2f5; color: #68727e; font-size: 8px; font-style: normal; }
.member-status { display: flex; align-items: center; gap: 8px; color: #68727e; font-size: 10px; }
.member-status .account-switch { display: inline-block; flex: none; }
.member-status .account-switch i { position: absolute; inset: 0; border-radius: 10px; background: #c7ccd3; cursor: pointer; }
.member-status .account-switch i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: .15s; }
.member-status .account-switch input:checked + i { background: #25a26f; }
.member-status .account-switch input:checked + i::after { transform: translateX(14px); }
.member-status .account-switch input:disabled + i { cursor: not-allowed; opacity: .55; }
.user-actions { justify-content: flex-end; }
.user-actions button { min-height: 30px; padding: 0 9px; }
.user-actions button[data-confirming="true"] { border-color: #d9665c; background: #fff4f3; color: #b74239; }
.user-permission-editor { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(280px, .7fr); gap: 14px; padding: 14px 16px 16px; border-top: 1px solid #edf0f3; background: #fafbfc; }
.user-permission-editor[hidden] { display: none; }
.user-permission-editor > section { display: grid; gap: 10px; align-content: start; min-width: 0; }
.user-permission-editor section > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.user-permission-editor section > header > div { display: grid; gap: 3px; }
.user-permission-editor section > header strong { font-size: 10px; }
.user-permission-editor section > header span { color: #838d98; font-size: 9px; }
.user-permission-editor section > header button, .password-reset-block button { height: 31px; padding: 0 10px; border: 1px solid #d5dae0; border-radius: 5px; background: #fff; color: #4f5965; font: inherit; font-size: 9px; cursor: pointer; }
.user-permission-editor button:disabled { opacity: .4; cursor: not-allowed; }
.password-reset-block { padding-left: 14px; border-left: 1px solid #e1e5e9; }
.password-reset-block > div { display: grid; grid-template-columns: minmax(0, 1fr) 92px; }
.password-reset-block input { min-width: 0; height: 34px; padding: 0 10px; border: 1px solid #d9dde3; border-radius: 5px 0 0 5px; outline: 0; background: #fff; color: #303741; font: inherit; font-size: 10px; }
.password-reset-block button { border-radius: 0 5px 5px 0; }
.users-empty { padding: 26px; border-top: 1px solid #e5e8ec; color: #7d8792; text-align: center; font-size: 11px; }

@media (max-width: 650px) {
  .auth-mode-tabs { margin-top: -4px; }
  .register-two-columns { grid-template-columns: 1fr; }
  .auth-panel:has([data-auth-panel="register"].active) { top: 54%; max-height: calc(100vh - 90px); overflow: auto; }
}

@media (max-width: 1050px) {
  .create-user-grid { grid-template-columns: 1fr 1fr; }
  .user-table { overflow-x: auto; }
  .user-table-head, .user-row { min-width: 790px; }
  .user-permission-editor { min-width: 790px; }
}

@media (max-width: 700px) {
  .account-settings { padding: 16px; }
  .access-summary { grid-template-columns: 1fr; }
  .create-user-grid { grid-template-columns: 1fr; }
  .create-permission-block { grid-template-columns: 1fr; }
  .member-management > header { align-items: flex-start; flex-direction: column; padding: 12px; }
  .member-tools { width: 100%; }
  .member-tools input { flex: 1; width: auto; }
}
