﻿:root {
    --bg: #f7f7f8;
    --surface: #ffffff;
    --surface-soft: #f0f0f1;
    --text: #202123;
    --text-muted: #6e6e80;
    --border: #e5e5e5;
    --accent: #10a37f;
    --accent-hover: #0e8f70;
    --sidebar-bg: #ffffff;
}

body.dark {
    --bg: #171717;
    --surface: #212121;
    --surface-soft: #2f2f2f;
    --text: #ececf1;
    --text-muted: #a0a0a8;
    --border: #3a3a3a;
    --accent: #10a37f;
    --accent-hover: #13b890;
    --sidebar-bg: #111111;
}

html, body {
    background: var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    margin: 0;
    padding: 0;
}

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

.portal-shell {
    min-height: 100vh;
    display: flex;
    background: var(--bg);
}

.portal-sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.portal-brand {
    font-size: 18px;
    font-weight: 700;
    padding: 10px 12px 24px;
}

.portal-nav,
.nav-section {
    display: flex;
    flex-direction: column;
}

.portal-nav {
    gap: 6px;
}

.nav-section {
    gap: 6px;
    margin-bottom: 28px;
}

.nav-section-title {
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0 12px;
    margin-bottom: 10px;
}

.portal-nav a {
    display: block;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--text-muted);
    font-size: 15px;
}

    .portal-nav a.active,
    .portal-nav a:hover {
        background: var(--surface-soft);
        color: var(--text);
    }

.portal-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.portal-topbar {
    height: 64px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 28px;
    flex-shrink: 0;
}

.portal-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 34px;
}

.portal-shell {
    height: 100vh;
}

.portal-main {
    height: 100vh;
}


.page-title {
    font-size: 30px;
    font-weight: 700;
    margin-bottom: 8px;
}

.page-subtitle {
    color: var(--text-muted);
    margin-bottom: 32px;
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px;
}

.tool-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 24px;
    transition: 0.15s ease;
}

    .tool-card:hover {
        transform: translateY(-2px);
        border-color: var(--accent);
    }

.tool-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--surface-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 20px;
}

.tool-card h3 {
    font-size: 19px;
    margin-bottom: 8px;
}

.tool-card p {
    color: var(--text-muted);
    margin-bottom: 22px;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
}

    .btn-primary:hover {
        background: var(--accent-hover);
        border-color: var(--accent-hover);
    }

.theme-toggle {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: 999px;
    padding: 8px 14px;
    cursor: pointer;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-left: 20px;
}

.user-name {
    color: var(--text-muted);
    font-size: 14px;
}

.logout-form {
    margin: 0;
}

.logout-btn {
    border: none;
    background: transparent;
    color: var(--text);
    padding: 0;
    cursor: pointer;
}

    .logout-btn:hover {
        color: var(--accent);
    }

.auth-page {
    min-height: calc(100vh - 64px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.auth-card {
    width: 100%;
    max-width: 430px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 34px;
    box-shadow: 0 18px 50px rgba(0,0,0,0.08);
}

.auth-brand {
    text-align: center;
    margin-bottom: 30px;
}

.auth-logo {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: var(--accent);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    margin-bottom: 16px;
}

.auth-brand h1 {
    font-size: 26px;
    margin-bottom: 8px;
}

.auth-brand p {
    color: var(--text-muted);
    margin: 0;
}

.form-group {
    margin-bottom: 18px;
}

    .form-group label {
        display: block;
        margin-bottom: 7px;
        font-size: 14px;
        color: var(--text-muted);
    }

.form-control {
    width: 100%;
    box-sizing: border-box;
    background: var(--surface-soft);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 11px 13px;
}

    .form-control:focus {
        background: var(--surface);
        color: var(--text);
        border-color: var(--accent);
        box-shadow: none;
    }

.auth-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 14px;
    margin-bottom: 20px;
}

.remember-me {
    display: flex;
    align-items: center;
    gap: 7px;
}

.auth-submit {
    width: 100%;
    border: none;
    border-radius: 12px;
    background: var(--accent);
    color: white;
    padding: 12px 16px;
    font-weight: 700;
    cursor: pointer;
}

    .auth-submit:hover {
        background: var(--accent-hover);
    }

.auth-footer {
    margin-top: 22px;
    text-align: center;
    color: var(--text-muted);
}

.profile-page {
    max-width: 760px;
}

.profile-header {
    margin-bottom: 28px;
}

.profile-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 30px;
}

.profile-card-header {
    margin-bottom: 26px;
}

    .profile-card-header h2 {
        font-size: 22px;
        margin-bottom: 6px;
    }

    .profile-card-header p {
        color: var(--text-muted);
        margin: 0;
    }

.generated-text {
    white-space: pre-wrap;
    line-height: 1.7;
}

.result-card {
    position: relative;
}

.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

    .result-header h3 {
        margin: 0;
    }

.copy-btn {
    border: 1px solid var(--border);
    background: var(--surface-soft);
    color: var(--text);
    border-radius: 10px;
    padding: 7px 12px;
    font-size: 14px;
    cursor: pointer;
}

    .copy-btn:hover {
        border-color: var(--accent);
        color: var(--accent);
    }

.history-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.history-item {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    background: var(--surface-soft);
}

.history-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.history-prompt {
    font-weight: 600;
    margin-bottom: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-actions {
    display: flex;
    gap: 10px;
}

.chat-layout {
    height: calc(100vh - 130px);
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 24px;
}

.chat-history-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 14px;
    overflow-y: auto;
}

.new-chat-btn {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--surface-soft);
    color: var(--text);
    border-radius: 12px;
    padding: 12px 14px;
    font-weight: 700;
    cursor: pointer;
    margin-bottom: 14px;
}

    .new-chat-btn:hover {
        border-color: var(--accent);
        color: var(--accent);
    }

.chat-session-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-session-item {
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text);
    text-align: left;
    border-radius: 12px;
    padding: 11px 12px;
    cursor: pointer;
}

    .chat-session-item:hover,
    .chat-session-item.active {
        background: var(--surface-soft);
    }

    .chat-session-item span {
        display: block;
        font-size: 14px;
        font-weight: 600;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .chat-session-item small {
        display: block;
        margin-top: 4px;
        color: var(--text-muted);
    }

.chat-page {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    margin-bottom: 18px;
    flex-shrink: 0;
}

    .chat-header h1 {
        font-size: 28px;
        font-weight: 700;
        margin-bottom: 6px;
    }

    .chat-header p {
        color: var(--text-muted);
        margin: 0;
    }

.chat-window {
    flex: 1;
    overflow-y: auto;
    padding: 24px 6px 24px;
}

.chat-empty {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-align: center;
}

    .chat-empty h2 {
        color: var(--text);
        font-size: 30px;
        margin-bottom: 10px;
    }

.chat-message {
    display: flex;
    margin-bottom: 22px;
}

    .chat-message.user {
        justify-content: flex-end;
    }

    .chat-message.assistant {
        justify-content: flex-start;
    }

.chat-bubble {
    max-width: 780px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 18px 20px;
    position: relative;
}

.chat-message.user .chat-bubble {
    background: var(--surface-soft);
}

.chat-role {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.chat-text {
    white-space: pre-wrap;
    line-height: 1.7;
}

.chat-copy {
    margin-top: 14px;
}

.chat-input-area {
    flex-shrink: 0;
    padding-top: 16px;
    display: flex;
    gap: 12px;
}

.chat-input {
    flex: 1;
    min-height: 52px;
    max-height: 180px;
    resize: vertical;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 15px 18px;
    outline: none;
    font-family: inherit;
}

    .chat-input:focus {
        border-color: var(--accent);
    }

.chat-send {
    min-width: 96px;
    height: 52px;
    border: none;
    border-radius: 18px;
    background: var(--accent);
    color: white;
    font-weight: 700;
    cursor: pointer;
}

    .chat-send:hover {
        background: var(--accent-hover);
    }

    .chat-send:disabled {
        opacity: .6;
        cursor: not-allowed;
    }

.chat-session-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 34px;
    align-items: stretch;
    gap: 6px;
    border-radius: 12px;
    width: 100%;
}

    .chat-session-row.active {
        background: var(--surface-soft);
    }

    .chat-session-row .chat-session-item {
        min-width: 0;
        width: 100%;
    }

.chat-session-item span,
.chat-session-item small {
    max-width: 100%;
}

.chat-delete-btn {
    width: 34px;
    min-width: 34px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 10px;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
}

    .chat-delete-btn:hover {
        background: var(--surface-soft);
        color: var(--accent);
    }

.chat-history-panel {
    overflow-x: hidden;
}

.import-message {
    margin-top: 16px;
    color: var(--text-muted);
}

.data-table-wrap {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

    .data-table th,
    .data-table td {
        padding: 12px 10px;
        border-bottom: 1px solid var(--border);
        text-align: left;
        vertical-align: top;
        font-size: 14px;
    }

    .data-table th {
        color: var(--text-muted);
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: .06em;
    }

.table-muted {
    display: block;
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 3px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 12px;
    font-weight: 700;
}

    .status-pill.neutral {
        background: var(--surface-soft);
        color: var(--text-muted);
    }

    .status-pill.success {
        background: rgba(16, 163, 127, .14);
        color: var(--accent);
    }

.table-toolbar {
    display: grid;
    grid-template-columns: 1fr 220px;
    gap: 12px;
    margin-bottom: 14px;
}

.status-filter {
    min-width: 220px;
}

.import-meta {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 14px;
}

@media (max-width: 900px) {
    .table-toolbar {
        grid-template-columns: 1fr;
    }

    .status-filter {
        min-width: 0;
    }
}
.status-pill.warning {
    background: rgba(245, 158, 11, .15);
    color: #d97706;
}
.testmail-box {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    margin-top: 18px;
}

@media (max-width: 700px) {
    .testmail-box {
        grid-template-columns: 1fr;
    }
}
.table-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.history-row td {
    background: var(--surface-soft);
}

.history-panel {
    padding: 10px 4px;
}

.mail-log-item {
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 12px;
}

.mail-log-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.mail-log-status {
    margin-bottom: 10px;
}

.mail-log-error {
    color: #dc2626;
    font-size: 13px;
    line-height: 1.5;
}
.template-vars {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

    .template-vars code {
        background: var(--surface-soft);
        border: 1px solid var(--border);
        padding: 6px 10px;
        border-radius: 8px;
        font-size: 13px;
    }
.tool-tabs {
    display: inline-flex;
    gap: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 5px;
    margin-bottom: 24px;
}

.tool-tab {
    border: none;
    background: transparent;
    color: var(--text-muted);
    padding: 9px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
}

    .tool-tab:hover {
        color: var(--text);
        background: var(--surface-soft);
    }

    .tool-tab.active {
        color: var(--text);
        background: var(--surface-soft);
    }

.tool-tabs {
    display: inline-flex;
    gap: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 5px;
    margin-bottom: 24px;
}

.tool-tab {
    border: none;
    background: transparent;
    color: var(--text-muted);
    padding: 9px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
}

    .tool-tab:hover {
        color: var(--text);
        background: var(--surface-soft);
    }

    .tool-tab.active {
        color: var(--text);
        background: var(--surface-soft);
    }
.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

@media (max-width: 800px) {
    .settings-grid {
        grid-template-columns: 1fr;
    }
}
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 22px;
}

    .kpi-card span {
        display: block;
        color: var(--text-muted);
        font-size: 13px;
        margin-bottom: 10px;
    }

    .kpi-card strong {
        display: block;
        font-size: 32px;
        line-height: 1.1;
        margin-bottom: 8px;
    }

    .kpi-card small {
        color: var(--text-muted);
    }
.sidebar-toggle {
    width: 100%;
    border: none;
    background: transparent;
    color: inherit;
    font-size: 1.4rem;
    padding: 0.75rem;
    cursor: pointer;
    text-align: left;
}

.portal-shell.sidebar-collapsed .portal-sidebar {
    width: 72px;
}

.portal-shell.sidebar-collapsed .portal-brand,
.portal-shell.sidebar-collapsed .nav-section-title,
.portal-shell.sidebar-collapsed .portal-nav a {
    white-space: nowrap;
    overflow: hidden;
}

.portal-shell.sidebar-collapsed .portal-brand,
.portal-shell.sidebar-collapsed .nav-section-title {
    display: none;
}

.portal-shell.sidebar-collapsed .portal-nav a {
    font-size: 0;
    justify-content: center;
    color: transparent;
}

.portal-shell.sidebar-collapsed .portal-nav {
    display: none;
}

.portal-shell.sidebar-collapsed .portal-main {
    margin-left: 72px;
}
.modal-backdrop-custom {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.modal-card {
    background: var(--card-bg, #fff);
    color: var(--text-color, #111);
    width: min(900px, 100%);
    max-height: 85vh;
    overflow-y: auto;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

    .modal-card pre {
        background: rgba(0, 0, 0, 0.06);
        padding: 1rem;
        border-radius: 10px;
        overflow-x: auto;
    }

    .modal-card code {
        white-space: pre-wrap;
    }
.icon-actions {
    display: flex;
    flex-direction: row;
    gap: 0.4rem;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: nowrap;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1rem;
    border-radius: 6px;
    padding: 0;
}

    .icon-btn:hover {
        background: rgba(0, 0, 0, 0.08);
    }

    .icon-btn:disabled {
        opacity: 0.4;
        cursor: not-allowed;
    }