:root {
    --primary: #08a045;
    --primary-dark: #067a35;
    --accent: #7cc242;
    --ink: #111827;
    --muted: #667085;
    --line: #dfe5e8;
    --panel: #ffffff;
    --soft: #f3faf5;
    --soft-blue: #eef6fb;
    --danger: #b42318;
    --shadow: 0 24px 70px rgba(17, 24, 39, 0.10);
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    min-height: 100%;
    margin: 0;
}

body {
    color: var(--ink);
    background:
        linear-gradient(90deg, rgba(8, 160, 69, 0.05) 1px, transparent 1px),
        linear-gradient(180deg, rgba(8, 160, 69, 0.05) 1px, transparent 1px),
        linear-gradient(135deg, #ffffff 0%, #f6fbf8 56%, #eef6fb 100%);
    background-size: 28px 28px, 28px 28px, auto;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
    font: inherit;
}

button {
    border: 0;
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.68;
}

.page-shell {
    min-height: 100vh;
    min-height: 100dvh;
}

/* Ekran Geçiş Kontrolleri */
body.login-active .login-screen { display: grid; }
body.login-active .chat-screen { display: none; }
body.chat-active .login-screen { display: none; }
body.chat-active .chat-screen { display: block; }

.login-screen {
    min-height: 100vh;
    min-height: 100dvh;
    display: none;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: min(440px, 100%);
    padding: 38px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(223, 229, 232, 0.95);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.brand-block {
    display: grid;
    gap: 18px;
    justify-items: center;
    margin-bottom: 28px;
    text-align: center;
}

.brand-mark,
.app-mark {
    display: grid;
    place-items: center;
    color: #ffffff;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    box-shadow: 0 14px 28px rgba(8, 160, 69, 0.22);
    font-weight: 900;
}

.brand-mark {
    width: 92px;
    height: 92px;
    border-radius: 8px;
    font-size: 40px;
}

.app-mark {
    width: 54px;
    height: 54px;
    flex: 0 0 auto;
    border-radius: 8px;
    font-size: 23px;
}

.brand-kicker {
    margin: 0 0 8px;
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1, h2, p {
    margin-top: 0;
}

h1 {
    margin-bottom: 10px;
    font-size: 28px;
    line-height: 1.16;
}

.brand-copy {
    margin-bottom: 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
}

.login-form {
    display: grid;
    gap: 10px;
}

.login-form label {
    font-size: 13px;
    font-weight: 800;
}

.login-form input,
.chat-form textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--ink);
    outline: none;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.login-form input {
    min-height: 46px;
    padding: 0 14px;
    margin-bottom: 6px;
}

.chat-form textarea {
    min-height: 60px;
    max-height: 160px;
    padding: 14px;
    resize: vertical;
}

.login-form input:focus,
.chat-form textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(8, 160, 69, 0.14);
}

.form-error {
    min-height: 20px;
    margin: 2px 0 4px;
    color: var(--danger);
    font-size: 13px;
    line-height: 1.35;
}

#login-button,
#send-button {
    min-height: 46px;
    padding: 0 18px;
    border-radius: 8px;
    color: #ffffff;
    background: var(--primary);
    font-weight: 850;
    box-shadow: 0 12px 24px rgba(8, 160, 69, 0.22);
}

#login-button:hover,
#send-button:hover {
    background: var(--primary-dark);
}

.chat-screen {
    min-height: 100vh;
    min-height: 100dvh;
    display: none;
    width: min(1240px, 100%);
    margin: 0 auto;
    padding: 26px;
}

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

.header-brand {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 14px;
}

.header-brand h1 {
    margin-bottom: 4px;
    font-size: 25px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 0 14px;
    border: 1px solid rgba(8, 160, 69, 0.18);
    border-radius: 8px;
    color: var(--primary-dark);
    background: rgba(8, 160, 69, 0.09);
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
}

.status-pill span {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--primary);
}

.ghost-button,
.secondary-button {
    min-height: 38px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    background: #ffffff;
    font-weight: 800;
}

.ghost-button:hover,
.secondary-button:hover {
    border-color: rgba(8, 160, 69, 0.30);
    background: var(--soft);
}

.chat-layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 18px;
    align-items: stretch;
}

.quick-panel,
.chat-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 18px 50px rgba(17, 24, 39, 0.07);
}

.quick-panel {
    align-self: start;
    padding: 18px;
}

.quick-panel h2 {
    margin-bottom: 14px;
    font-size: 16px;
}

.quick-question {
    display: block;
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    margin-bottom: 10px;
    border: 1px solid rgba(8, 160, 69, 0.18);
    border-radius: 8px;
    color: var(--primary-dark);
    background: var(--soft);
    font-size: 13px;
    font-weight: 800;
    text-align: left;
}

.quick-question:hover {
    border-color: var(--primary);
    background: rgba(8, 160, 69, 0.11);
}

.chat-panel {
    min-height: 680px;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    overflow: hidden;
}

.messages {
    min-height: 0;
    padding: 18px;
    overflow-y: auto;
    background: linear-gradient(180deg, #ffffff 0%, #fbfdfc 100%);
}

.message {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
}

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

.message-avatar {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 8px;
    color: #ffffff;
    background: #2563eb;
    font-size: 13px;
    font-weight: 900;
}

.assistant-message .message-avatar {
    background: var(--primary);
}

.message-bubble {
    max-width: min(760px, calc(100% - 44px));
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--ink);
    font-size: 14px;
    line-height: 1.55;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.message-text {
    white-space: pre-wrap;
}

.analysis-panel {
    display: grid;
    gap: 10px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    white-space: normal;
}

.analysis-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.analysis-chip {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border: 1px solid rgba(8, 160, 69, 0.18);
    border-radius: 8px;
    color: var(--primary-dark);
    background: var(--soft);
    font-size: 12px;
    font-weight: 800;
}

.analysis-kpi {
    display: grid;
    gap: 4px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfdfc;
}

.analysis-kpi-label,
.analysis-kpi-note {
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
}

.analysis-kpi-value {
    color: var(--ink);
    font-size: 26px;
    line-height: 1.18;
    font-weight: 900;
}

.analysis-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.analysis-summary-item {
    display: grid;
    gap: 4px;
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfdfc;
}

.analysis-summary-item span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
}

.analysis-summary-item strong {
    color: var(--ink);
    font-size: 15px;
    overflow-wrap: anywhere;
}

.analysis-table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.analysis-table {
    width: 100%;
    min-width: 620px;
    border-collapse: collapse;
    font-size: 13px;
}

.analysis-table th,
.analysis-table td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.analysis-table th {
    color: #344054;
    background: #f8faf9;
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}

.analysis-table tbody tr:last-child td {
    border-bottom: 0;
}

.analysis-table td {
    color: var(--ink);
}

.numeric-cell {
    text-align: right !important;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.analysis-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
}

.analysis-actions {
    display: flex;
    justify-content: flex-end;
}

.analysis-more-button {
    min-height: 30px;
    padding: 0 10px;
    border: 1px solid rgba(8, 160, 69, 0.22);
    border-radius: 8px;
    color: var(--primary-dark);
    background: var(--soft);
    font-size: 12px;
    font-weight: 850;
}

.analysis-more-button:hover {
    border-color: var(--primary);
    background: rgba(8, 160, 69, 0.11);
}

.analysis-download-button {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid rgba(8, 160, 69, 0.26);
    border-radius: 8px;
    color: #ffffff;
    background: var(--primary);
    font-size: 12px;
    font-weight: 850;
    text-decoration: none;
}

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

.user-message .message-bubble {
    border-color: rgba(37, 99, 235, 0.18);
    color: #0f172a;
    background: var(--soft-blue);
}

.typing-message .message-bubble {
    color: var(--muted);
}

.chat-form {
    display: grid;
    gap: 10px;
    padding: 14px;
    border-top: 1px solid var(--line);
    background: #ffffff;
}

.chat-controls {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.sr-only {
    width: 1px;
    height: 1px;
    position: absolute;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* RESPONSIVE TASARIM AYARLARI */
@media (max-width: 900px) {
    .chat-screen { padding: 18px; }
    .app-header { align-items: flex-start; flex-direction: column; }
    .header-actions { width: 100%; justify-content: space-between; }
    .chat-layout { grid-template-columns: 1fr; }
    .quick-panel { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
    .quick-panel h2 { grid-column: 1 / -1; margin-bottom: 0; }
    .quick-question { margin-bottom: 0; }
    .chat-panel { min-height: 580px; }
}

@media (max-width: 560px) {
    .login-screen { padding: 16px; }
    .login-card { padding: 28px 22px; }
    h1 { font-size: 24px; }
    .brand-mark { width: 78px; height: 78px; font-size: 34px; }
    .chat-screen { padding: 14px; }
    .header-brand { align-items: flex-start; }
    .header-actions, .chat-controls { align-items: stretch; flex-direction: column; }
    .quick-panel { grid-template-columns: 1fr; }
    .message-bubble { max-width: calc(100% - 44px); }
    .analysis-summary-grid { grid-template-columns: 1fr; }
    .analysis-kpi-value { font-size: 22px; }
}
