:root {
  --brand-green: #d3da71;
  --brand-green-dark: #93a12a;
  --brand-accent: #556b2f;
  --bg: #f6f7f2;
  --card-bg: #ffffff;
  --border: #dfe3d2;
  --text: #1f2937;
  --muted: #5b6472;
  --pos: #2e7d32;
  --neg: #c62828;
  --avemoy-bar: #7f9a2c;
  --actual-bar: #2b6cb0;
  --diff-pos-bar: #388e3c;
  --diff-neg-bar: #d94a38;
  --radius: 10px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
}

.hidden {
  display: none !important;
}

/* Auth Screen */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(31, 41, 55, 0.08);
}

.auth-banner {
  background: var(--brand-green);
  color: #ffffff;
  text-align: center;
  padding: 20px 18px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
}

.auth-brand {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.auth-sub {
  font-size: 0.95rem;
  font-weight: 600;
  margin-top: 4px;
}

.auth-form {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-form h2 {
  margin: 0;
  font-size: 1.25rem;
}

/* Header Bar (#D3DA71) with proportional scaling */
.top-bar {
  background: var(--brand-green);
  color: #ffffff;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: clamp(8px, 2vw, 24px);
  padding: clamp(10px, 1.5vw, 18px) clamp(14px, 3vw, 34px);
  min-height: clamp(64px, 8vw, 96px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
}

.top-bar-left {
  font-size: clamp(1.05rem, 2.2vw, 1.85rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  justify-self: start;
  white-space: nowrap;
}

.top-bar-center {
  text-align: center;
  justify-self: center;
}

.title-main {
  font-size: clamp(1.05rem, 2.3vw, 1.85rem);
  font-weight: 800;
  line-height: 1.15;
}

.title-sub {
  font-size: clamp(0.85rem, 1.6vw, 1.3rem);
  font-weight: 700;
  line-height: 1.2;
}

.top-bar-right {
  justify-self: end;
  display: flex;
  align-items: center;
}

.header-logo {
  height: clamp(36px, 5.2vw, 64px);
  width: auto;
  max-width: clamp(90px, 18vw, 220px);
  object-fit: contain;
  display: block;
}

/* Containers */
.main-container {
  max-width: 1320px;
  margin: 0 auto;
  padding: clamp(10px, 2vw, 22px) clamp(12px, 3vw, 34px) 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sub-container {
  max-width: 720px;
  margin: 26px auto;
  padding: 0 16px;
}

.sub-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.05);
}

.sub-card h2 {
  margin: 0 0 6px;
}

.under-logo-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Panels & Buttons */
.panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 9px 16px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.05s ease, background-color 0.15s ease;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

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

.btn-small {
  padding: 5px 12px;
  font-size: 0.82rem;
  border-radius: 6px;
}

.btn-full {
  width: 100%;
}

.btn-primary {
  background: var(--brand-accent);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-secondary {
  background: #edf1de;
  color: #3a4618;
  border-color: #cbd4aa;
}

.btn-secondary:hover:not(:disabled) {
  background: #e2e9c9;
}

.btn-ghost {
  background: #ffffff;
  color: var(--text);
  border-color: #cfd5c3;
}

.btn-ghost:hover:not(:disabled) {
  background: #f3f5ec;
}

.btn-danger {
  background: #fdecec;
  color: #b42318;
  border-color: #f6c7c3;
  padding: 5px 10px;
  font-size: 0.8rem;
}

.btn-danger:hover:not(:disabled) {
  background: #fbd5d5;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* Forms */
.stack-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.86rem;
  font-weight: 600;
  color: #374151;
}

.field input,
.field textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #cbd2be;
  border-radius: 7px;
  font: inherit;
  font-weight: 500;
  color: var(--text);
  background: #ffffff;
}

.field input:focus,
.field textarea:focus {
  outline: 2px solid rgba(147, 161, 42, 0.35);
  border-color: var(--brand-green-dark);
}

.error-msg {
  margin: 0;
  padding: 9px 12px;
  border-radius: 7px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  font-size: 0.88rem;
  font-weight: 500;
}

.notice {
  margin: 0;
  padding: 9px 12px;
  border-radius: 7px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  font-size: 0.88rem;
}

.muted {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0;
}

.status-pill {
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  background: #e8f5e9;
  color: #1b5e20;
  border: 1px solid #c8e6c9;
}

/* Tables */
.table-scroll {
  max-height: clamp(200px, 31vh, 320px);
  overflow-y: auto;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.table-scroll-editor {
  max-height: clamp(240px, 44vh, 460px);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: clamp(0.82rem, 1.15vw, 0.94rem);
  min-width: 520px;
}

.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #eef2dc;
  color: #2f3a11;
  text-align: left;
  font-weight: 700;
  padding: 10px 12px;
  border-bottom: 2px solid #d4dcb4;
  white-space: nowrap;
}

.data-table tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid #eef0e6;
  white-space: nowrap;
}

.data-table tbody tr:hover {
  background: #fafbf6;
}

.diff-pos {
  color: var(--pos);
  font-weight: 700;
}

.diff-neg {
  color: var(--neg);
  font-weight: 700;
}

.empty-state {
  text-align: center;
  padding: 20px 12px;
  color: var(--muted);
  font-size: 0.92rem;
}

/* Chart */
.chart-panel {
  position: relative;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: clamp(0.76rem, 1.05vw, 0.86rem);
  font-weight: 600;
  color: #374151;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.swatch-avemoy { background: var(--avemoy-bar); }
.swatch-actual { background: var(--actual-bar); }
.swatch-diff-pos { background: var(--diff-pos-bar); }
.swatch-diff-neg { background: var(--diff-neg-bar); }

.chart-root {
  width: 100%;
  min-height: 280px;
}

.chart-frame {
  display: flex;
  align-items: stretch;
  width: 100%;
}

.chart-axis-left,
.chart-axis-right {
  flex: 0 0 auto;
}

.chart-scroll-wrap {
  flex: 1 1 auto;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-gutter: stable;
}

.chart-tooltip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  background: rgba(17, 24, 39, 0.94);
  color: #ffffff;
  padding: 8px 11px;
  border-radius: 7px;
  font-size: 0.8rem;
  line-height: 1.45;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
  white-space: nowrap;
}

/* Update Mode */
.editor-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.editor-toolbar h2 {
  margin: 0;
  font-size: 1.3rem;
}

.add-box-panel {
  background: #fbfcf7;
}

.add-box-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 10px;
  color: #354014;
}

.add-box-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr)) auto;
  gap: 10px;
  align-items: end;
}

.diff-preview {
  height: 39px;
  display: flex;
  align-items: center;
  padding: 0 11px;
  border: 1px dashed #cbd2be;
  border-radius: 7px;
  background: #f5f7ee;
  font-weight: 700;
}

.table-actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.editable-table input {
  width: 100%;
  min-width: 90px;
  padding: 6px 8px;
  border: 1px solid #cbd2be;
  border-radius: 6px;
  font: inherit;
  background: #ffffff;
}

.editable-table input:focus {
  outline: 2px solid rgba(147, 161, 42, 0.35);
  border-color: var(--brand-green-dark);
}

.col-action {
  width: 90px;
  text-align: center;
}

.editable-table td.cell-action {
  text-align: center;
}

/* Feedback View */
.feedback-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.feedback-top h2 {
  margin: 0;
}

.feedback-list-box {
  border: 1px solid var(--border);
  background: #fafbf6;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 14px;
}

.feedback-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.feedback-list-content {
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.feedback-item {
  background: #ffffff;
  border: 1px solid #e4e7d8;
  border-radius: 7px;
  padding: 9px 11px;
}

.feedback-item-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.feedback-item-name {
  font-weight: 700;
  color: var(--text);
}

.feedback-item-msg {
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 780px) {
  .add-box-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
  .add-box-btn-wrap {
    grid-column: 1 / -1;
  }
  .add-box-btn-wrap .btn {
    width: 100%;
  }
}

/* Unified #D3DA71 buttons */
.btn,
.btn-primary,
.btn-secondary,
.btn-ghost,
.btn-danger {
  background: #d3da71;
  color: #ffffff;
  border-color: #bcc458;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
}

.btn:hover:not(:disabled),
.btn-primary:hover:not(:disabled),
.btn-secondary:hover:not(:disabled),
.btn-ghost:hover:not(:disabled),
.btn-danger:hover:not(:disabled) {
  background: #c5cd5f;
  color: #ffffff;
  filter: none;
}
