:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #152238;
  --muted: #5f6b7a;
  --primary: #2957d1;
  --primary-hover: #1f46ac;
  --border: #d9e1ef;
  --success: #177245;
  --error: #a63232;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0 1.5rem 1.5rem 1.5rem;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 0 1rem 0;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
}

h1 {
  margin-top: 0;
  margin-bottom: 0.4rem;
}

.intro {
  color: var(--muted);
  margin-top: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
}

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

label {
  display: flex;
  flex-direction: column;
  font-weight: 700;
  gap: 0.35rem;
  color: #21324d;
}

label small {
  font-weight: 400;
  color: var(--muted);
}

input,
select,
button,
textarea {
  font: inherit;
}

input,
select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem;
  font-weight: 400;
}

.full-width {
  grid-column: 1 / -1;
}

.actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.6rem;
}

button {
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1rem;
  cursor: pointer;
  font-weight: 700;
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon-btn:hover {
  background: #e7ebf5;
}

.small-btn {
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
}

#primaryAction {
  background: var(--primary);
  color: #fff;
}

#primaryAction:hover {
  background: var(--primary-hover);
}

.secondary {
  background: #e7ebf5;
  color: #273957;
}

.danger {
  background: #f9d9d9;
  color: #7c1e1e;
}

progress {
  width: 100%;
  height: 22px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.stats p {
  margin: 0;
}

#statusLog {
  margin-top: 0.8rem;
  min-height: 180px;
  max-height: 350px;
  overflow: auto;
  background: #0f1a2b;
  color: #d7e4ff;
  border-radius: 8px;
  padding: 0.7rem;
  white-space: pre-wrap;
}

.modal.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(3, 10, 22, 0.66);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
}

.modal-content {
  width: min(900px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 1.5rem;
}

.settings-group {
  margin-bottom: 1.5rem;
}

.cache-table-container {
  margin-top: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.cache-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.cache-table th,
.cache-table td {
  padding: 0.6rem;
  border-bottom: 1px solid var(--border);
}

.cache-table th {
  background: var(--bg);
  font-weight: 700;
  font-size: 0.9rem;
}

.tab-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.tab-buttons button {
  background: #e7ebf5;
  color: #263955;
}

.tab-buttons button.active {
  background: var(--primary);
  color: #fff;
}

.preview-pane {
  margin-top: 0.6rem;
  background: #0f1a2b;
  color: #d7e4ff;
  border-radius: 8px;
  padding: 0.7rem;
  min-height: 250px;
  max-height: 48vh;
  overflow: auto;
  white-space: pre-wrap;
}

.modal-actions {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
