:root {
  --bg: #f4f1eb;
  --panel: #ffffff;
  --ink: #1d2422;
  --muted: #69726f;
  --line: #dfd8cc;
  --brand: #0f6b5f;
  --brand-dark: #0b4e46;
  --brand-soft: #dceee9;
  --accent: #c58b2c;
  --danger: #b94b4b;
  --good: #1c7c54;
  --shadow: 0 20px 50px rgba(31, 37, 35, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

.hidden {
  display: none !important;
}

.setup-banner {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  color: #fff;
  background: #8a6425;
  font-size: 14px;
}

.setup-banner.live {
  background: var(--brand-dark);
}

.auth-view {
  min-height: calc(100vh - 41px);
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at top left, rgba(15, 107, 95, 0.16), transparent 36%),
    var(--bg);
}

.auth-card {
  width: min(520px, 100%);
  padding: 28px;
  background: var(--panel);
  border: 1px solid rgba(29, 36, 34, 0.08);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 18px;
}

.auth-card h1 {
  font-size: 32px;
}

.auth-card p,
.auth-hint {
  color: var(--muted);
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form label {
  color: var(--muted);
  font-weight: 800;
  display: grid;
  gap: 6px;
}

.auth-form input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.auth-hint {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fffdf8;
}

.brand.compact {
  color: var(--ink);
}

.brand.compact span {
  color: var(--muted);
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px;
  background: #112724;
  color: #f7f3ea;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  background: var(--accent);
  color: #14130f;
  display: grid;
  place-items: center;
  font-weight: 900;
  letter-spacing: 0;
}

.brand strong,
.brand span,
.account-card strong,
.account-card small,
.user-card strong,
.user-card small {
  display: block;
}

.brand span,
.account-card small,
.user-card small,
.sidebar-note p {
  color: rgba(247, 243, 234, 0.72);
}

.role-switch {
  display: grid;
  gap: 8px;
}

.role-btn,
.ghost-btn,
.primary-btn {
  border: 0;
  border-radius: 8px;
  min-height: 42px;
  padding: 10px 14px;
  font-weight: 700;
}

.role-btn {
  color: rgba(247, 243, 234, 0.72);
  background: rgba(255, 255, 255, 0.07);
  text-align: left;
}

.role-btn.active {
  color: #112724;
  background: #f7f3ea;
}

.account-card,
.user-card,
.sidebar-note {
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.06);
}

.select-label {
  margin-bottom: -14px;
  color: rgba(247, 243, 234, 0.78);
  font-weight: 700;
}

.sidebar select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 12px;
  color: #f7f3ea;
  background: #19332f;
}

.sidebar-logout {
  margin-top: auto;
}

.main {
  padding: 28px;
  min-width: 0;
}

.topbar,
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.topbar {
  margin-bottom: 22px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.05;
}

h2 {
  font-size: 20px;
}

.eyebrow {
  display: inline-block;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.period-select {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.period-select select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--ink);
  background: #fff;
  font-weight: 800;
}

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

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

.ghost-btn {
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.hero-panel {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.score-card,
.panel,
.metric {
  background: var(--panel);
  border: 1px solid rgba(29, 36, 34, 0.08);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.score-card {
  padding: 22px;
  display: grid;
  gap: 14px;
}

.score-ring {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, #fff 58%, transparent 59%),
    conic-gradient(var(--brand) 0deg, var(--brand) 295deg, #e7e0d3 295deg);
}

.score-ring span {
  font-size: 42px;
  font-weight: 900;
}

.chart {
  min-height: 280px;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  overflow: hidden;
}

.chart svg {
  display: block;
  width: 100%;
  height: auto;
}

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

.chart-label {
  fill: #6c716d;
  font-size: 11px;
  font-weight: 700;
}

.chart-area {
  fill: rgba(15, 107, 95, 0.08);
}

.chart-line-clicks {
  fill: none;
  stroke: var(--brand);
  stroke-width: 4;
}

.chart-line-impressions {
  fill: none;
  stroke: var(--accent);
  stroke-width: 4;
}

.score-card p,
.metric small,
.task-list small,
.request-list small,
.admin-request-list small,
.client-site-list small,
.package-grid p {
  color: var(--muted);
}

.summary-grid,
.agency-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.summary-grid {
  align-self: stretch;
}

.metric {
  padding: 18px;
  display: grid;
  gap: 8px;
}

.metric span {
  color: var(--muted);
  font-weight: 700;
}

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

.metric.strong {
  border-top: 4px solid var(--brand);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 18px;
  margin-bottom: 18px;
}

.lower-grid {
  align-items: start;
}

.panel {
  padding: 20px;
}

.panel.wide {
  min-width: 0;
}

.status-pill {
  white-space: nowrap;
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 900;
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.status-pill.good {
  background: #dff2e6;
  color: var(--good);
}

.keyword-list,
.task-list,
.request-list,
.admin-request-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.keyword-item,
.task-item,
.request-item,
.admin-request-item,
.client-site-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fffdf8;
}

.keyword-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.keyword-item strong,
.task-item strong,
.request-item strong {
  display: block;
}

.rank {
  text-align: right;
  font-weight: 900;
  color: var(--brand-dark);
}

.rank small {
  display: block;
  color: var(--muted);
  font-weight: 700;
}

.progress {
  height: 8px;
  border-radius: 999px;
  background: #e8e0d4;
  overflow: hidden;
  margin-top: 10px;
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
}

.request-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.request-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
}

.request-form input,
.request-form select,
.request-form textarea,
.panel-head select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
}

.request-form textarea {
  resize: vertical;
}

.two-column-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

.form-help {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
}

.request-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.tag {
  border-radius: 999px;
  padding: 5px 8px;
  background: #eee6da;
  color: #5b564d;
  font-size: 12px;
  font-weight: 800;
}

.tag.hot {
  color: #7f2e2e;
  background: #f3dddd;
}

.tag.done {
  color: var(--good);
  background: #dff2e6;
}

.admin-request-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px;
  gap: 14px;
  align-items: start;
}

.admin-request-item select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.message-box {
  display: grid;
  gap: 14px;
  margin-top: 18px;
  padding: 16px;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.report-preview {
  margin-top: 18px;
  display: grid;
  gap: 12px;
}

.report-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.report-row strong {
  text-align: right;
}

.client-site-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.client-site-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.gsc-breakdown-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(190px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.breakdown-note {
  grid-column: 1 / -1;
  color: var(--muted);
  font-weight: 700;
}

.breakdown-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fffdf8;
  display: grid;
  align-content: start;
  gap: 10px;
}

.breakdown-card h3 {
  margin: 0;
  font-size: 16px;
}

.breakdown-row {
  border-top: 1px solid rgba(223, 216, 204, 0.8);
  padding-top: 10px;
  display: grid;
  gap: 3px;
}

.breakdown-row strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.breakdown-row span,
.breakdown-row small,
.breakdown-empty {
  color: var(--muted);
  font-size: 13px;
}

.package-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.package-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fffdf8;
  display: grid;
  gap: 8px;
}

.package-grid span {
  color: var(--brand-dark);
  font-weight: 900;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: 360px;
  padding: 14px 16px;
  border-radius: 8px;
  color: #fff;
  background: #112724;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: 0.2s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .hero-panel,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .summary-grid,
  .agency-grid,
  .package-grid,
  .gsc-breakdown-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .main,
  .sidebar {
    padding: 18px;
  }

  .setup-banner,
  .topbar,
  .panel-head,
  .admin-request-item,
  .client-site-item {
    display: grid;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .period-select {
    width: 100%;
  }

  .period-select select {
    width: 100%;
  }

  .topbar-actions button,
  .summary-grid,
  .agency-grid,
  .package-grid,
  .gsc-breakdown-grid {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .keyword-item {
    grid-template-columns: 1fr;
  }

  .two-column-form {
    grid-template-columns: 1fr;
  }

  .rank {
    text-align: left;
  }
}

@media print {
  .sidebar,
  .topbar-actions,
  .request-form,
  .ghost-btn,
  .primary-btn,
  .toast {
    display: none !important;
  }

  .app-shell,
  .hero-panel,
  .content-grid,
  .summary-grid {
    display: block;
  }

  .main {
    padding: 0;
  }

  .panel,
  .metric,
  .score-card {
    box-shadow: none;
    break-inside: avoid;
    margin-bottom: 14px;
  }
}

/* Search Console workspace */
.gsc-controls{margin-bottom:22px}.gsc-filter-row{display:flex;flex-wrap:wrap;align-items:end;gap:12px}.gsc-filter-row label{display:grid;gap:7px;flex:1;min-width:150px;font-size:13px;font-weight:700;color:var(--muted)}.gsc-filter-row input,.gsc-filter-row select{max-width:100%;min-width:0}.gsc-filter-row>input{flex:1;min-width:180px}.gsc-tabs{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:18px}.gsc-tabs .selected{background:var(--brand);color:#fff}.gsc-table-wrap{overflow-x:auto;max-width:100%;margin-top:15px}.gsc-table{width:100%;border-collapse:collapse;font-size:14px}.gsc-table th{background:#f5f2ea;color:#49675e;text-align:left;font-size:12px;white-space:nowrap}.gsc-table td,.gsc-table th{padding:15px 12px;border-bottom:1px solid #e5e9e4}.gsc-table td:first-child{max-width:460px;overflow-wrap:anywhere;min-width:150px}.gsc-table tbody tr:hover{background:#f5f8f6}.gsc-table td:not(:first-child){white-space:nowrap;font-variant-numeric:tabular-nums}.gsc-pagination{display:flex;justify-content:space-between;align-items:center;gap:10px;margin-top:18px}.gsc-pagination button:disabled,button:disabled{opacity:.5;cursor:wait}.muted,#gscSyncStatus{color:var(--muted);font-size:13px;line-height:1.7;overflow-wrap:anywhere}.inspection-result{margin-top:20px}.inspection-result strong{overflow-wrap:anywhere;max-width:70%}.summary-grid{grid-template-columns:repeat(3,minmax(0,1fr))}.gsc-breakdown-grid .breakdown-card p{line-height:1.6}.gsc-breakdown-grid a,.gsc-table a{color:var(--brand)}.chart{min-width:0}.content-grid,.panel{min-width:0}
@media(max-width:1100px){.summary-grid{grid-template-columns:repeat(3,minmax(0,1fr))}}
@media(max-width:680px){.summary-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.gsc-filter-row>button{width:100%}.gsc-filter-row label{min-width:120px}.gsc-tabs .ghost-btn{padding:10px;font-size:12px}.gsc-table td,.gsc-table th{padding:12px 9px}.inspection-result .report-row{display:grid;gap:7px}.inspection-result strong{max-width:100%;text-align:left}}
@media print{.gsc-controls,.gsc-tabs,.gsc-filter-row,.gsc-pagination,#gscCsv,#gscInspectForm{display:none}.gsc-table-wrap{overflow:visible}.gsc-table{font-size:10px}.gsc-table td,.gsc-table th{padding:7px}.panel{break-inside:avoid}}
.gsc-chart-metrics{display:flex;flex-wrap:wrap;gap:15px;margin-bottom:15px;font-size:13px}.gsc-chart-metrics label{display:flex;align-items:center;gap:6px}.gsc-chart-metrics input{width:16px;height:16px;accent-color:var(--brand)}
