/* A quiet, full-width workspace: table first, conversation alongside it. */
:root {
    color-scheme: light;
    --ink: #101828;
    --muted: #71809f;
    --line: #e8edf5;
    --blue: #0066ff;
}
.setup-admin-link { display: block; text-align: center; color: #7c91b1; font-size: 12px; margin-top: 24px; }
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: #fff; font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button { color: inherit; cursor: pointer; background: none; border: 0; }
button:disabled { cursor: default; opacity: .4; }
a { color: inherit; text-decoration: none; }
h1, h2, p { margin: 0; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, select:focus-visible { outline: 2px solid #7cafff; outline-offset: 3px; }
input:focus-visible { outline: 0; }
::selection { background: #dce9ff; }
[x-cloak] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.icon { width: 20px; height: 20px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }

/* Header */
.app-shell { height: 100dvh; min-height: 420px; display: flex; flex-direction: column; }
.app-header { height: 72px; min-height: 72px; padding: 0 44px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 20px; font-size: 24px; font-weight: 700; letter-spacing: -.55px; line-height: 1; }
.brand-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: var(--blue); color: #fff; }
.brand-icon .icon { width: 27px; height: 27px; }
.brand-dot { color: var(--blue); }
.workspace-account { position: relative; }
.account-avatar { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: #eff5ff; color: var(--blue); font-size: 14px; font-weight: 550; }
.workspace-menu, .entry-menu { z-index: 30; width: 210px; padding: 6px; border: 1px solid #e1e7f0; border-radius: 9px; background: #fff; box-shadow: 0 5px 20px #152d5210; }
.workspace-menu { position: absolute; top: 54px; right: 0; }
.workspace-menu a, .workspace-menu button, .entry-menu button { display: flex; align-items: center; gap: 9px; width: 100%; padding: 9px 10px; border-radius: 5px; text-align: left; font-size: 13px; color: #465572; }
.workspace-menu a:hover, .workspace-menu button:hover, .entry-menu button:hover { background: #f5f7fa; }
.workspace-menu [aria-disabled="true"] { opacity: .4; }
.workspace-menu .icon, .entry-menu .icon { width: 15px; height: 15px; }
.workspace-menu form { margin: 0; }
.menu-heading { padding: 7px 10px 9px; color: #8995a9; font-size: 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }

/* Main table */
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1fr) clamp(340px, 28vw, 470px); flex: 1; min-height: 0; }
.sheet-panel { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 22px 32px 32px 42px; }
.sheet-toolbar { padding-bottom: 20px; flex-shrink: 0; }
.search-box { height: 50px; display: flex; align-items: center; gap: 16px; padding: 0 16px; border: 1px solid #d9e2ef; border-radius: 9px; color: #617394; }
.search-box:focus-within { border-color: #95baff; }
.search-box .icon { width: 21px; height: 21px; }
.search-box input { width: 100%; min-width: 0; padding: 0; border: 0; background: transparent; color: #34425c; font-size: 14px; box-shadow: none; }
.search-box input::placeholder { color: #7583a1; opacity: 1; }
.sheet-scroll { flex: 1; min-height: 0; overflow: auto; position: relative; scrollbar-width: thin; scrollbar-color: #dfe5ee transparent; overscroll-behavior: contain; overflow-anchor: none; }
.data-table { width: 100%; min-width: 620px; border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: 14px; }
.serial-column { width: 8%; }
.reference-column { width: 28%; }
.timestamp-column { width: 25%; }
.action-column { width: 5%; }
.data-table thead { position: sticky; top: 0; z-index: 2; }
.data-table th, .data-table td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); text-align: left; font-weight: 400; }
.data-table th:last-child, .data-table td:last-child { border-right: 0; }
.data-table thead th { height: 38px; padding: 0 16px; background: #f8f9fb; border-top: 1px solid var(--line); font-size: 14px; color: #1c263a; }
.data-table tbody th, .data-table tbody td { height: 35px; padding: 5px 16px; vertical-align: middle; }
.data-table tbody tr:hover { background: #fafbfd; }
.data-table .serial-cell { color: #7887a5; font-variant-numeric: tabular-nums; }
.number-line { display: flex; align-items: baseline; justify-content: space-between; gap: 15px; }
.number-main { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.number-text { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.copy-inline { flex-shrink: 0; display: inline-grid; place-items: center; height: 24px; width: 24px; border-radius: 4px; color: #99a6ba; padding: 0; }
.copy-inline:hover { background: #eef3fb; color: var(--blue); }
.copy-inline .icon { width: 13px; height: 13px; }
.reference-content { display: flex; align-items: center; gap: 6px; min-width: 0; }
.reference-link { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #60799f; font-size: 13px; }
.reference-link:hover { text-decoration: underline; }
.empty-reference { color: #b9c1ce; font-size: 12px; }
.check-url-btn { flex-shrink: 0; display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border-radius: 4px; font-size: 11px; font-weight: 550; line-height: 1.3; border: 1px solid #d3dce9; background: #f8fafc; color: #4b5d7a; cursor: pointer; transition: all .15s ease; user-select: none; }
.check-url-btn:hover:not(:disabled) { background: #eef4fe; border-color: #92b7fe; color: var(--blue); }
.check-url-btn .icon { width: 11px; height: 11px; }
.check-url-btn.is-checking { background: #f1f5f9 !important; color: #334155 !important; border-color: #94a3b8 !important; cursor: wait !important; box-shadow: 0 0 0 2px #e2e8f0; }
.check-url-btn .spinner-dot { display: inline-block; width: 9px; height: 9px; border: 2px solid #3b82f6; border-top-color: transparent; border-radius: 50%; animation: spin-check .5s linear infinite; }
@keyframes spin-check { to { transform: rotate(360deg); } }
.check-url-btn.has-status { border-width: 1px; }
.check-url-btn.status-live { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.check-url-btn.status-live:hover { background: #d1fae5; border-color: #6ee7b7; }
.check-url-btn.status-live .status-indicator { width: 6px; height: 6px; border-radius: 50%; background: #10b981; }
.check-url-btn.status-flagged { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.check-url-btn.status-flagged:hover { background: #fee2e2; border-color: #fca5a5; }
.check-url-btn.status-flagged .status-indicator { width: 6px; height: 6px; border-radius: 50%; background: #ef4444; }
.check-url-btn.status-deleted, .check-url-btn.status-expired { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.check-url-btn.status-deleted:hover, .check-url-btn.status-expired:hover { background: #fef3c7; border-color: #fcd34d; }
.check-url-btn.status-deleted .status-indicator, .check-url-btn.status-expired .status-indicator { width: 6px; height: 6px; border-radius: 50%; background: #f59e0b; }
.check-url-btn.status-error { background: #f3f4f6; border-color: #e5e7eb; color: #6b7280; }
.check-url-btn .status-indicator { display: inline-block; flex-shrink: 0; }
.check-url-btn .recheck-icon { display: none; margin-left: 2px; }
.check-url-btn.has-status:hover .recheck-icon { display: inline-flex; }
.check-url-btn .btn-check-content { display: inline-flex; align-items: center; gap: 4px; }
.entry-author { max-width: 100px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; color: #8b96ab; }
.timestamp-cell { color: #7585a4; white-space: nowrap; font-variant-numeric: tabular-nums; }
.data-table .action-cell { padding: 0; text-align: center; }
.row-action { display: inline-grid; place-items: center; width: 32px; height: 30px; color: #607293; border-radius: 5px; vertical-align: middle; }
.row-action:hover { background: #eef2f8; }
.row-action .icon { width: 17px; height: 17px; }
.row-new { background: #f0f7ff; }
.sheet-empty, .loading-state { color: #8995aa; font-size: 13px; text-align: center; padding: 45px 16px; }
.sheet-empty .text-button { margin-top: 8px; }
.text-button { padding: 4px 0; font-size: 12px; color: #637ba4; }
.text-button:hover { color: var(--blue); }
.older-entries { text-align: center; padding: 14px; }
.entry-menu { position: fixed; width: 230px; }
.entry-details { padding: 8px 10px 12px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.entry-details > span { display: block; font-size: 11px; color: #8a95a9; margin-bottom: 4px; }
.entry-details p { color: #3c4b65; font-size: 13px; overflow-wrap: anywhere; max-height: 65px; overflow-y: auto; }
.entry-details small { display: block; font-size: 11px; color: #8895aa; margin-top: 5px; }

/* Chat: plain bubbles, a small profile switcher and one input. */
.chat-panel { align-self: start; height: clamp(420px, calc(100dvh - 200px), 720px); min-height: 0; min-width: 0; position: relative; display: flex; flex-direction: column; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.mobile-chat-launcher, .mobile-chat-close, .mobile-chat-backdrop { display: none; }
.chat-header { padding: 23px 28px 19px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.chat-header h2 { font-size: 22px; font-weight: 650; letter-spacing: -.3px; line-height: 1.4; }
.chat-profile { display: flex; align-items: center; gap: 12px; margin-top: 5px; }
.connection-dot { height: 9px; width: 9px; background: #0ac35d; border-radius: 50%; flex-shrink: 0; }
.connection-dot.connection-warning { background: #d5a24b; }
.chat-profile select { max-width: 100%; padding: 0 4px 0 0; border: 0; color: #7585a2; background: transparent; font-size: 14px; cursor: pointer; }
.chat-history { flex: 1; min-height: 0; overflow: auto; padding: 27px 28px 8px; scrollbar-width: thin; scrollbar-color: #e0e5ed transparent; overscroll-behavior: contain; overflow-anchor: none; }
.message { display: flex; align-items: flex-start; gap: 22px; margin-bottom: 29px; }
.message-avatar { display: grid; place-items: center; width: 46px; height: 46px; flex-shrink: 0; border-radius: 50%; color: #73819b; background: #f4f5f7; font-size: 14px; margin-top: 0; }
.own-message .message-avatar { color: #507fc4; background: #f0f5ff; }
.message-content { flex: 1; min-width: 0; padding-top: 3px; }
.message-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.sender-name { min-width: 0; font-size: 12px; font-weight: 650; overflow-wrap: anywhere; }
.message-heading time { flex-shrink: 0; color: #7b8baa; font-size: 11px; white-space: nowrap; }
.bubble { display: inline-block; max-width: 100%; padding: 9px 13px; background: #f3f4f6; color: #1b253a; border-radius: 8px; font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.own-message .bubble { background: #eff5ff; color: #28558e; }
.bubble.bubble-failed { background: #fff5ed; color: #995f42; }
.message-state { display: block; margin-top: 4px; color: #9aa4b6; font-size: 10px; }
.message-failure { margin-top: 7px; font-size: 11px; line-height: 1.5; color: #a4694e; }
.message-failure button { padding: 0; font-weight: 600; text-decoration: underline; }
.chat-response { display: flex; align-items: flex-start; gap: 6px; margin: -16px 0 24px 68px; color: #7c8e85; font-size: 11px; line-height: 1.6; overflow-wrap: anywhere; }
.chat-response .icon { height: 13px; width: 13px; margin-top: 2px; }
.chat-response.response-error { color: #aa7954; }
.day-divider { text-align: center; color: #97a1b2; font-size: 11px; margin: 0 0 22px; }
.history-loader { text-align: center; padding-bottom: 22px; }
.chat-empty { padding: 50px 0; font-size: 14px; color: #72809a; text-align: center; }
.chat-empty span { display: block; font-size: 12px; margin-top: 7px; color: #98a2b4; }
.chat-composer { flex-shrink: 0; border-top: 1px solid var(--line); padding: 11px 28px 16px; }
.composer-form { display: flex; align-items: center; gap: 7px; min-height: 54px; border: 1px solid #d9e2ef; border-radius: 10px; padding: 7px 9px 7px 17px; }
.composer-form:focus-within { border-color: #91b6f8; }
.reference-step-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 1px 9px; }
.reference-step-heading label { font-size: 12px; font-weight: 550; color: #546581; }
.reference-step-heading label span { font-weight: 400; color: #98a3b5; }
.skip-reference { padding: 0 2px; font-size: 12px; color: #7184a1; }
.skip-reference:hover { color: var(--blue); text-decoration: underline; }
.composer-form input { flex: 1; min-width: 0; width: 100%; border: 0; background: transparent; color: #34425b; font-size: 14px; padding: 3px 0; box-shadow: none; }
.composer-form input::placeholder { color: #7c8ba8; opacity: 1; }
.send-button { display: grid; place-items: center; flex-shrink: 0; width: 32px; height: 34px; color: #5c6e8e; border-radius: 6px; }
.send-button:hover:not(:disabled) { color: var(--blue); background: #f2f6fd; }
.send-button .icon { height: 22px; width: 22px; }
.jump-latest { position: absolute; bottom: 106px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 6px; padding: 6px 11px; border: 1px solid #dde5f1; border-radius: 20px; background: #fff; color: #6681ab; font-size: 12px; white-space: nowrap; }
.jump-latest .icon { width: 13px; height: 13px; }

/* Small utility states; no decorative cards or banners in the main view. */
.form-error { font-size: 12px; color: #ac694f; margin-top: 9px; }
.notice { position: fixed; z-index: 40; top: 82px; left: 24px; right: 24px; max-width: 760px; margin: 0 auto; padding: 12px 16px; border: 1px solid #f0dfce; border-radius: 7px; background: #fffaf5; color: #9b7255; font-size: 13px; }
.notice button { padding: 0; text-decoration: underline; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: calc(100vw - 32px); border-radius: 7px; background: #27354b; color: #fff; padding: 10px 16px; font-size: 13px; }
.login-page { min-height: 100dvh; display: grid; place-items: center; padding: 32px 24px; }
.login-card { width: 100%; max-width: 370px; }
.login-card .brand { margin-bottom: 44px; }
.login-card h1 { font-size: 22px; font-weight: 600; letter-spacing: -.4px; margin-bottom: 8px; }
.login-card > p { font-size: 13px; color: #8793a7; }
.login-form { margin-top: 28px; }
.login-form label { display: block; color: #52627e; font-size: 12px; margin-bottom: 7px; }
.login-form input { width: 100%; height: 46px; border: 1px solid #dbe3ef; border-radius: 7px; padding: 0 12px; background: #fff; color: #34425b; }
.login-form input:focus { border-color: #8bb4fb; }
.login-form input + label { margin-top: 16px; }
.primary-button { width: 100%; margin-top: 14px; display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-radius: 7px; background: var(--blue); color: #fff; font-size: 13px; }
.primary-button .icon { width: 16px; height: 16px; }
.setup-card { max-width: 550px; margin: 16vh auto; padding: 30px; }
.setup-card h1 { font-size: 25px; margin: 14px 0; font-weight: 600; }
.setup-card p { font-size: 14px; color: #7b889e; line-height: 1.8; margin-bottom: 15px; }
.setup-card a { color: var(--blue); }
.eyebrow { color: #8290a7; font-size: 11px; letter-spacing: 1px; }

@media (min-width: 1600px) {
    .data-table { font-size: 16px; }
    .data-table thead th { font-size: 15px; }
    .search-box input { font-size: 15px; }
    .chat-header { padding-top: 24px; }
    .sender-name { font-size: 13px; }
    .message-heading time { font-size: 12px; }
    .bubble { font-size: 16px; }
    .message { gap: 28px; }
    .chat-response { margin-left: 74px; }
}
@media (max-width: 1100px) {
    .app-header { padding: 0 26px; }
    .sheet-panel { padding: 22px 22px 24px 26px; }
    .serial-column { width: 52px; }
    .timestamp-column { width: 150px; }
    .action-column { width: 36px; }
    .data-table thead th, .data-table tbody th, .data-table tbody td { padding-left: 10px; padding-right: 10px; }
    .entry-author { display: none; }
    .chat-header { padding-left: 22px; padding-right: 22px; }
    .chat-history { padding-left: 22px; padding-right: 22px; }
    .message { gap: 14px; }
    .message-avatar { width: 38px; height: 38px; font-size: 12px; }
    .chat-response { margin-left: 52px; }
    .chat-composer { padding-left: 20px; padding-right: 20px; }
}
@media (max-width: 760px) {
    .app-shell { height: 100dvh; min-height: 420px; }
    .app-header { height: 68px; min-height: 68px; padding: 0 22px; }
    .brand { font-size: 22px; gap: 13px; }
    .brand-icon { width: 38px; height: 38px; border-radius: 10px; }
    .brand-icon .icon { width: 24px; height: 24px; }
    .account-avatar { width: 38px; height: 38px; font-size: 12px; }
    .workspace-grid { display: flex; flex-direction: column; }
    .sheet-panel { flex: 1; height: auto; min-height: 0; max-height: none; padding: 20px 22px 84px; }
    .sheet-toolbar { padding-bottom: 18px; }
    .search-box { height: 46px; padding: 0 12px; gap: 10px; }
    .search-box input { font-size: 16px; }
    .search-box input::placeholder { font-size: 13px; }
    .data-table { min-width: 0; width: 100%; font-size: 13px; }
    .data-table .timestamp-column, .data-table .action-column,
    .data-table thead th:nth-child(4), .data-table thead th:nth-child(5),
    .data-table .timestamp-cell, .data-table .action-cell { display: none; }
    .data-table .reference-column { width: 42%; }
    .data-table thead th:nth-child(3), .data-table .reference-cell { border-right: 0; }
    .data-table thead th { font-size: 12px; }
    .serial-column { width: 52px; }
    .timestamp-column { width: 150px; }
    .entry-author { display: none; }
    .timestamp-cell { font-size: 12px; }
    .mobile-chat-launcher { position: fixed; right: max(18px, env(safe-area-inset-right)); bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 60; display: grid; place-items: center; width: 54px; height: 54px; border-radius: 50%; background: var(--blue); color: #fff; box-shadow: 0 5px 20px #0066ff40; }
    .mobile-chat-launcher .icon { width: 26px; height: 26px; }
    .mobile-chat-launcher:hover { background: #0057df; }
    .mobile-chat-backdrop { display: block; position: fixed; inset: 0; z-index: 60; background: #182c4c26; }
    .chat-panel { display: none; position: fixed; z-index: 70; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); width: auto; max-width: 420px; margin-left: auto; height: min(76dvh, 620px); min-height: 0; max-height: calc(100dvh - 24px - env(safe-area-inset-bottom) - env(safe-area-inset-top)); border: 1px solid #dfe7f2; border-radius: 16px; background: #fff; box-shadow: 0 14px 50px #14294d30; overflow: hidden; }
    .chat-panel.mobile-chat-open { display: flex; }
    .chat-panel:focus { outline: none; }
    .chat-header { position: relative; padding: 16px 20px 14px; }
    .chat-header h2 { font-size: 18px; padding-right: 38px; }
    .mobile-chat-close { display: grid; place-items: center; position: absolute; top: 13px; right: 13px; width: 34px; height: 34px; border-radius: 50%; color: #526582; background: #f0f4f9; border: none; cursor: pointer; transition: all .15s ease; }
    .mobile-chat-close:hover { background: #e2eaf4; color: #0f172a; }
    .mobile-chat-close .icon { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2; }
    .chat-profile { padding-right: 34px; }
    .chat-profile select { font-size: 13px; }
    .chat-history { padding: 20px 20px 4px; }
    .message { gap: 20px; margin-bottom: 26px; }
    .message-avatar { width: 42px; height: 42px; }
    .sender-name { font-size: 12px; }
    .message-heading time { font-size: 11px; }
    .chat-response { margin-left: 62px; }
    .chat-composer { padding: 12px 18px 14px; }
    .toast { z-index: 80; bottom: calc(80px + env(safe-area-inset-bottom)); }
}
@media (max-width: 480px) {
    .app-header { padding: 0 18px; }
    .sheet-panel { padding: 18px 16px 84px; }
    .serial-column { width: 44px; }
    .timestamp-column { width: 140px; }
    .action-column { width: 29px; }
    .data-table thead th, .data-table tbody th, .data-table tbody td { padding: 6px 8px; }
    .data-table .action-cell { padding: 0; }
    .row-action { width: 26px; }
    .entry-author { display: none; }
    .timestamp-cell { font-size: 10px; }
    .number-text { font-size: 12px; }
    .search-box input::placeholder { font-size: 12px; }
    .chat-header { padding-left: 20px; padding-right: 20px; }
    .chat-history { padding-left: 20px; padding-right: 20px; }
    .chat-composer { padding-left: 18px; padding-right: 18px; }
    .message { gap: 16px; }
    .message-avatar { width: 38px; height: 38px; }
    .chat-response { margin-left: 54px; }
    .bubble { font-size: 13px; }
    .composer-form input { font-size: 16px; }
    .composer-form input::placeholder { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
