:root {
  color-scheme: light;
  --ink: #1e2227;
  --muted: #667085;
  --line: #d8dee8;
  --panel: #ffffff;
  --soft: #f4f7fb;
  --brand: #f36b21;
  --brand-dark: #c64b13;
  --green: #237b4b;
  --shadow: 0 18px 55px rgba(26, 36, 52, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  background: var(--soft);
  color: var(--ink);
  direction: ltr;
  text-align: left;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef3f8;
}

.auth-card {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-logo {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(243, 107, 33, 0.22);
}

.auth-card label {
  display: grid;
  gap: 7px;
  font-weight: 700;
}

.auth-card input {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.auth-error {
  margin: 0;
  padding: 10px 12px;
  color: #991b1b;
  background: #fff1f2;
  border: 1px solid #fecdd3;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
}

.account-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 10px;
  border-right: 1px solid var(--line);
}

.account-box span {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

button,
textarea,
input {
  font: inherit;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 310px 1fr;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  justify-content: space-between;
  padding: 34px 26px;
  background: #222831;
  color: #fff;
}

.eyebrow {
  margin: 0 0 8px;
  color: #98a2b3;
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 31px;
  line-height: 1.2;
}

h2 {
  font-size: 25px;
}

.status-grid {
  display: grid;
  gap: 12px;
}

.status-grid div,
.question-card,
.reply-panel,
.settings-panel,
.toolbar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.status-grid div {
  padding: 14px;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
}

.status-grid span {
  display: block;
  color: #cbd5e1;
  font-size: 13px;
  margin-bottom: 4px;
}

.connection-state.connected strong {
  color: #7ee2a8;
}

.connection-state.reconnecting strong {
  color: #fbbf24;
}

.connection-state.disconnected strong {
  color: #f87171;
}

.workspace {
  padding: 28px;
}

.data-status {
  margin: 12px 0 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
}

.backend-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid #ef4444;
  border-radius: 6px;
  background: #fff1f2;
  color: #991b1b;
}

.backend-alert div {
  min-width: 0;
}

.backend-alert strong,
.backend-alert span {
  display: block;
}

.backend-alert span {
  margin-top: 3px;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.data-status.verified {
  color: var(--green);
  background: #edf9f2;
  border-color: #b8dfc9;
}

.data-status.error {
  color: #b42318;
  background: #fff1f0;
  border-color: #f3b7b2;
}

.nav-buttons {
  display: grid;
  gap: 10px;
}

.store-list {
  display: grid;
  gap: 10px;
  align-content: start;
  min-height: 160px;
}

.store-item {
  width: 100%;
  display: grid;
  gap: 4px;
  padding: 13px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.16s, background 0.16s, transform 0.16s;
}

.store-item.active {
  border-color: var(--brand);
  background: rgba(243, 107, 33, 0.2);
}

.store-item.attention {
  transform: translateY(-1px);
}

.store-item.status-red {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.16);
}

.store-item.status-orange {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.16);
}

.store-item span {
  color: #cbd5e1;
  font-size: 13px;
}

.store-item strong {
  display: flex;
  gap: 8px;
  align-items: center;
}

.store-item em {
  color: #fff;
  font-style: normal;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #d1d5db;
  flex: 0 0 auto;
}

.status-red .status-dot {
  background: #ef4444;
}

.status-orange .status-dot {
  background: #f59e0b;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

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

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.metric strong {
  font-size: 24px;
}

.top-questions-panel {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.mini-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.mini-list span {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  max-width: 340px;
  padding: 7px 10px;
  border-radius: 999px;
  background: #f4f7fb;
  color: var(--ink);
  font-size: 13px;
}

.test-panel {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.test-results {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 10px;
}

.test-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.test-card.ok {
  border-color: #86efac;
  background: #f0fdf4;
}

.test-card.fail {
  border-color: #fecaca;
  background: #fff1f2;
}

.test-card span {
  font-weight: 800;
  color: var(--muted);
  font-size: 13px;
}

.test-card pre,
.log-row pre {
  max-width: 100%;
  margin: 0;
  padding: 10px;
  overflow: auto;
  border-radius: 8px;
  background: #111827;
  color: #e5e7eb;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #fff3eb;
  color: var(--brand-dark);
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(280px, 420px) 1fr;
  gap: 18px;
  align-items: start;
}

.product-search-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 16px;
}

.product-search-row label {
  width: min(560px, 100%);
}

.settings-panel {
  margin-bottom: 18px;
  padding: 20px;
  box-shadow: var(--shadow);
}

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

.settings-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 14px;
}

.settings-form .wide {
  grid-column: 1 / -1;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.check-row input {
  flex: 0 0 auto;
}

.question-list {
  display: grid;
  gap: 12px;
}

.question-card {
  width: 100%;
  padding: 16px;
  text-align: right;
  cursor: pointer;
  color: var(--ink);
  transition: border-color 0.16s, transform 0.16s;
}

.question-card:hover,
.question-card.active {
  border-color: var(--brand);
  transform: translateY(-1px);
}

.question-card.manual {
  border-color: #f59e0b;
  background: #fffbeb;
}

.question-card strong {
  display: block;
  margin-bottom: 8px;
}

.question-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.question-card.sending {
  border-color: #f59e0b;
}

.question-card.send-failed {
  border-color: #dc2626;
  background: #fff7f7;
}

.question-tracking {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  width: 100%;
  margin: 12px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  text-align: left;
}

.question-tracking div {
  min-width: 0;
}

.question-tracking .wide {
  grid-column: 1 / -1;
}

.question-tracking dt {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.question-tracking dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.4;
}

.manual-badge {
  display: inline-flex;
  margin-top: 12px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #fff3c4;
  color: #92400e;
  font-size: 12px;
  font-weight: 800;
}

.category-badge {
  display: inline-flex;
  margin-top: 10px;
  margin-right: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e8f2ff;
  color: #165fa7;
  font-size: 12px;
  font-weight: 800;
}

.reply-panel {
  min-height: 540px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.empty-state {
  min-height: 480px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.reply-editor {
  display: grid;
  gap: 14px;
}

.selected-question {
  padding: 16px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.selected-question span {
  display: block;
  color: var(--brand-dark);
  font-weight: 700;
  margin-bottom: 8px;
}

.selected-question h3 {
  font-size: 20px;
  line-height: 1.45;
}

.manual-note {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fffbeb;
  color: #92400e;
  font-weight: 700;
}

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-weight: 700;
}

textarea,
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  background: #fff;
  line-height: 1.6;
}

select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  background: #fff;
  line-height: 1.6;
  font: inherit;
}

textarea {
  resize: vertical;
}

textarea:focus,
input:focus,
select:focus {
  outline: 3px solid rgba(243, 107, 33, 0.17);
  border-color: var(--brand);
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  background: var(--brand);
  color: #fff;
}

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

.secondary-button {
  background: #e8edf5;
  color: var(--ink);
}

.danger-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 800;
  cursor: pointer;
  background: #fee2e2;
  color: #991b1b;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 18px 0;
}

.tab {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
}

.tab.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.tab-panel {
  margin-bottom: 18px;
}

.search-input {
  margin-bottom: 12px;
}

.history-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.history-filters label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.history-filters input,
.history-filters select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 9px 11px;
}

.history-summary,
.history-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0;
  color: var(--muted);
}

.history-summary > div {
  display: grid;
  gap: 3px;
}

.turkish-date-field {
  display: grid;
  grid-template-columns: 1fr 42px;
  width: 100%;
}

.history-filters .turkish-date-field input {
  border-radius: 8px 0 0 8px;
  border-right: 0;
}

.date-picker-button {
  min-width: 42px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 0 8px 8px 0;
  background: #fff;
  color: #344054;
  font-size: 20px;
  cursor: pointer;
}

.date-picker-button:hover,
.date-picker-button:focus-visible {
  border-color: var(--brand);
  color: var(--brand-dark);
  outline: none;
}

.turkish-calendar {
  position: fixed;
  z-index: 1200;
  width: min(330px, calc(100vw - 24px));
  padding: 12px;
  border: 1px solid #cfd6e1;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.22);
  direction: ltr;
}

.turkish-calendar-header {
  display: grid;
  grid-template-columns: 38px 1fr 38px;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.turkish-calendar-header strong {
  text-align: center;
  font-size: 15px;
}

.turkish-calendar-header button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}

.turkish-calendar-header button:hover,
.turkish-calendar-header button:focus-visible {
  border-color: var(--brand);
  color: var(--brand-dark);
  outline: none;
}

.turkish-calendar-weekdays,
.turkish-calendar-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.turkish-calendar-weekdays {
  margin-bottom: 5px;
  color: #667085;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.turkish-calendar-weekdays span {
  padding: 5px 0;
}

.turkish-calendar-days button,
.turkish-calendar-days span {
  width: 100%;
  aspect-ratio: 1;
}

.turkish-calendar-days button {
  border: 1px solid transparent;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
}

.turkish-calendar-days button:hover,
.turkish-calendar-days button:focus-visible {
  border-color: var(--brand);
  background: #fff7ed;
  outline: none;
}

.turkish-calendar-days button.today {
  border-color: #94a3b8;
  font-weight: 800;
}

.turkish-calendar-days button.selected {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}

.turkish-calendar-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.turkish-calendar-actions button {
  min-height: 36px;
  padding: 7px 12px;
}

.history-record {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.history-record-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.history-record-header > div:first-child {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.history-record-header span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.history-badges {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  flex-wrap: wrap;
}

.history-badges .category-badge {
  margin: 0;
}

.status-badge {
  padding: 4px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

.conversation-message {
  padding: 14px 16px;
  border-left: 4px solid transparent;
}

.conversation-message + .conversation-message {
  border-top: 1px solid rgba(148, 163, 184, 0.24);
}

.conversation-message > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
}

.conversation-message time {
  color: #475569;
  font-size: 12px;
  white-space: nowrap;
}

.conversation-message p {
  margin: 0;
  color: var(--ink);
  line-height: 1.55;
  white-space: pre-wrap;
}

.customer-message {
  border-left-color: #2563eb;
  background: #eff6ff;
}

.customer-message strong {
  color: #1d4ed8;
}

.assistant-message {
  border-left-color: #16a34a;
  background: #f0fdf4;
}

.assistant-message strong {
  color: #15803d;
}

.history-details {
  padding: 11px 16px 14px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.history-details summary {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.history-pagination {
  justify-content: center;
}

.history-pagination button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.table-list,
.log-list {
  display: grid;
  gap: 10px;
}

.row-card,
.log-row {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.attention-row {
  border-color: #ef4444;
  background: #fff7f7;
}

.danger-row {
  border-color: #ef4444;
  background: #fef2f2;
}

.row-card p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.log-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 12px;
  align-items: start;
}

.log-row span {
  color: var(--muted);
  min-width: 90px;
}

.log-row div {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.toast {
  position: fixed;
  inset-inline: 22px auto;
  bottom: 22px;
  max-width: 420px;
  padding: 13px 16px;
  border-radius: 8px;
  background: #1f2937;
  color: #fff;
  box-shadow: var(--shadow);
}

.notification-popup {
  position: fixed;
  inset-inline: auto 22px;
  top: 22px;
  width: min(420px, calc(100vw - 44px));
  padding: 16px;
  border: 1px solid #fecaca;
  border-left: 5px solid #ef4444;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow);
  z-index: 20;
}

.notification-popup strong {
  display: block;
  margin-bottom: 6px;
}

.notification-popup p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.hidden {
  display: none;
}

@media (max-width: 900px) {
  .app-shell,
  .content-grid,
  .settings-form,
  .metrics-grid,
  .test-results {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .history-filters {
    grid-template-columns: 1fr;
  }

  .history-record-header,
  .conversation-message > div,
  .history-summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .conversation-message time {
    white-space: normal;
  }
}
