:root {
    --bg: #f4efe6;
    --surface: rgba(255, 255, 255, 0.78);
    --surface-strong: #fffdf8;
    --text: #1d2939;
    --muted: #526071;
    --border: rgba(29, 41, 57, 0.1);
    --primary: #0f766e;
    --primary-dark: #115e59;
    --accent: #f59e0b;
    --shadow: 0 18px 40px rgba(29, 41, 57, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(245, 158, 11, 0.16), transparent 24%),
        linear-gradient(180deg, #f8f4ec 0%, #eef6f3 100%);
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

img,
svg,
video {
    max-width: 100%;
    height: auto;
}

code {
    font-family: "Fira Code", monospace;
    background: rgba(15, 118, 110, 0.08);
    border-radius: 6px;
    padding: 0.1rem 0.35rem;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.site-header,
.page-shell {
    width: min(1120px, calc(100vw - 2rem));
    margin: 0 auto;
}

.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 2rem 0 1rem;
}

.site-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    color: var(--muted);
    align-items: center;
}

.header-tools,
.session-box {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.page-shell {
    display: grid;
    gap: 1.5rem;
    padding: 1rem 0 3rem;
}

.hero,
.status-card,
.card,
.table-card,
.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
}

.hero {
    padding: 1.75rem;
}

.hero {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 1rem;
}

.hero-actions,
.table-actions,
.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.form-actions-inline {
    margin-top: 0.2rem;
}

.inline-form-actions {
    margin: 0.6rem 0 1rem;
}

.eyebrow,
.status,
small {
    color: var(--muted);
}

.eyebrow,
.status {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.78rem;
    font-weight: 700;
}

.button {
    border: 0;
    border-radius: 999px;
    background: var(--primary);
    color: white;
    padding: 0.9rem 1.25rem;
    font: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.button:hover {
    background: var(--primary-dark);
}

.button-secondary {
    background: white;
    color: var(--text);
    border: 1px solid var(--border);
}

.button-secondary:hover {
    background: #f3f4f6;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.card,
.status-card,
.table-card,
.auth-card {
    padding: 1.4rem;
}

.auth-card {
    max-width: 560px;
    width: 100%;
}

.project-form-card {
    max-width: 900px;
}

.project-main-grid {
    grid-template-columns: minmax(220px, 0.9fr) minmax(420px, 2.1fr);
}

.project-name-input {
    min-width: 0;
}

.auth-card.chat-shell {
    max-width: 100%;
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 880px;
}

th,
td {
    text-align: left;
    padding: 0.9rem 0.8rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

th {
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}

.pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.28rem 0.65rem;
    font-size: 0.82rem;
    font-weight: 700;
}

.pill-ok {
    color: #166534;
    background: #dcfce7;
}

.pill-off {
    color: #991b1b;
    background: #fee2e2;
}

.login-form {
    display: grid;
    gap: 1rem;
    margin-top: 1.2rem;
}

.login-form label {
    display: grid;
    gap: 0.45rem;
}

.login-form input {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.85rem 1rem;
    background: var(--surface-strong);
    font: inherit;
    width: 100%;
}

.user-form {
    display: grid;
    gap: 1rem;
}

.user-form label {
    display: grid;
    gap: 0.45rem;
}

.user-form input,
.user-form select,
.chat-form textarea {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.85rem 1rem;
    background: var(--surface-strong);
    font: inherit;
    width: 100%;
}

.user-form textarea {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.85rem 1rem;
    background: var(--surface-strong);
    font: inherit;
    width: 100%;
    resize: vertical;
    min-height: 120px;
}

.form-hint {
    margin: -0.25rem 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.generated-secret {
    display: grid;
    gap: 0.45rem;
    padding: 0.95rem 1rem;
    border: 1px dashed rgba(15, 118, 110, 0.28);
    border-radius: 16px;
    background: rgba(15, 118, 110, 0.06);
}

.generated-secret[hidden] {
    display: none;
}

.generated-secret input {
    font-family: "Fira Code", monospace;
    letter-spacing: 0.02em;
}

.checkbox-field {
    display: flex !important;
    align-items: center;
    gap: 0.6rem;
}

.checkbox-field input {
    width: 1rem;
    height: 1rem;
    padding: 0;
}

.button-small {
    padding: 0.65rem 1rem;
    font-size: 0.92rem;
}

.field-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.actions-cell {
    min-width: 210px;
}

.project-warning-card {
    border: 1px dashed rgba(245, 158, 11, 0.4);
    border-radius: 16px;
    padding: 1rem;
    background: rgba(245, 158, 11, 0.08);
}

.project-row-draggable {
    cursor: move;
}

.project-row-draggable.dragging {
    opacity: 0.55;
}

.drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.8rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-strong);
    font-weight: 700;
}

.project-priority-1 {
    background: rgba(245, 158, 11, 0.18);
}

.project-priority-2 {
    background: rgba(245, 158, 11, 0.12);
}

.project-priority-3 {
    background: rgba(245, 158, 11, 0.07);
}

.projects-board {
    padding: 1.6rem;
}

.projects-table {
    min-width: 1180px;
}

.project-name-cell strong {
    display: inline-block;
    max-width: 420px;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.project-name-cell small {
    display: inline-block;
    margin-top: 0.2rem;
    max-width: 560px;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.inline-price-form {
    display: grid;
    gap: 0.4rem;
}

.inline-price-form input {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.5rem 0.6rem;
    background: var(--surface-strong);
    font: inherit;
}

.participants-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem 1rem;
    margin-top: 0.4rem;
}

.participant-checkbox {
    align-items: flex-start;
}

.message-read-row td {
    background: rgba(15, 118, 110, 0.07);
}

.message-unread-row td {
    background: rgba(245, 158, 11, 0.10);
}

.table-total-row td {
    background: rgba(15, 118, 110, 0.08);
    border-top: 2px solid rgba(15, 118, 110, 0.24);
}

.alert {
    border-radius: 16px;
    padding: 0.95rem 1rem;
    margin-top: 1rem;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.chat-shell {
    display: grid;
    gap: 1rem;
    max-width: 100%;
}

.chat-history {
    display: grid;
    gap: 0.9rem;
}

.chat-message {
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 1rem 1.1rem;
    background: var(--surface-strong);
}

.chat-message-user {
    background: rgba(15, 118, 110, 0.08);
    border-color: rgba(15, 118, 110, 0.14);
}

.chat-message-assistant {
    background: rgba(245, 158, 11, 0.08);
    border-color: rgba(245, 158, 11, 0.18);
}

.chat-message-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.chat-message-body {
    white-space: pre-wrap;
    line-height: 1.55;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.chat-empty {
    color: var(--muted);
}

.guidance-list {
    margin: 0.5rem 0 0.9rem 1rem;
    padding: 0;
    display: grid;
    gap: 0.35rem;
}

.chat-form {
    display: grid;
    gap: 1rem;
}

.chat-config-form {
    display: grid;
    gap: 0.7rem;
    margin-top: 0.8rem;
}

.chat-config-form label {
    display: grid;
    gap: 0.4rem;
}

.chat-config-form input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem 0.9rem;
    background: var(--surface-strong);
    font: inherit;
    color: inherit;
}

.chat-form textarea {
    width: 100%;
    min-height: 160px;
    resize: vertical;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1rem;
    background: var(--surface-strong);
    font: inherit;
    color: inherit;
}

.doc-pre {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
    line-height: 1.55;
    margin: 0;
    font-family: "Fira Code", monospace;
    font-size: 0.93rem;
}

.regulatory-ai-textarea {
    min-height: 420px;
    max-height: 70vh;
    overflow-y: auto;
    resize: vertical;
}

@media print {
    .site-header,
    .hero-actions {
        display: none !important;
    }

    .page-shell {
        width: 100%;
        padding: 0;
    }

    .hero,
    .status-card,
    .card,
    .table-card,
    .auth-card {
        box-shadow: none;
        border: 0;
        border-radius: 0;
        background: #fff;
    }

    .printable-report {
        padding: 0;
    }
}

@media (max-width: 800px) {
    .site-header,
    .hero,
    .header-tools,
    .session-box {
        flex-direction: column;
        align-items: start;
    }

    .site-header,
    .page-shell {
        width: min(100vw - 1rem, 1120px);
    }

    .site-header {
        padding: 1.25rem 0 0.75rem;
    }

    .header-tools,
    .session-box,
    .hero-actions,
    .form-actions,
    .table-actions {
        width: 100%;
    }

    .site-nav {
        gap: 0.75rem;
    }

    .site-nav a {
        width: 100%;
    }

    .session-box > div,
    .hero > div:first-child {
        width: 100%;
    }

    .hero,
    .status-card,
    .card,
    .table-card,
    .auth-card {
        border-radius: 20px;
        padding: 1rem;
    }

    .button,
    .button-small {
        width: 100%;
    }

    .form-actions > *,
    .hero-actions > *,
    .table-actions > * {
        width: 100%;
    }

    .table-actions form,
    .session-box form {
        width: 100%;
    }

    .field-grid {
        grid-template-columns: 1fr;
    }

    .project-main-grid {
        grid-template-columns: 1fr;
    }

    .project-form-card {
        max-width: 100%;
    }

    .chat-message-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
}

@media (max-width: 640px) {
    body {
        font-size: 15px;
    }

    .page-shell {
        gap: 1rem;
        padding: 0.75rem 0 2rem;
    }

    .cards {
        grid-template-columns: 1fr;
    }

    table {
        min-width: 0;
    }

    .table-wrap {
        overflow: visible;
    }

    .table-wrap table,
    .table-wrap thead,
    .table-wrap tbody,
    .table-wrap tr,
    .table-wrap th,
    .table-wrap td {
        display: block;
        width: 100%;
    }

    .table-wrap thead {
        display: none;
    }

    .table-wrap tbody {
        display: grid;
        gap: 0.9rem;
    }

    .table-wrap tr {
        border: 1px solid var(--border);
        border-radius: 18px;
        background: var(--surface-strong);
        padding: 0.35rem 0;
        box-shadow: 0 12px 30px rgba(29, 41, 57, 0.06);
    }

    .table-wrap td {
        border: 0;
        padding: 0.55rem 0.85rem;
    }

    .table-wrap td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 0.2rem;
        color: var(--muted);
        font-size: 0.74rem;
        font-weight: 700;
        letter-spacing: 0.05em;
        text-transform: uppercase;
    }

    .table-wrap td.actions-cell {
        padding-top: 0.75rem;
    }

    .table-wrap td.actions-cell::before {
        margin-bottom: 0.45rem;
    }
}
