:root {
  --bg: #f4f7f8;
  --surface: #ffffff;
  --surface-soft: #eef8f7;
  --text: #17252a;
  --muted: #60747b;
  --primary: #0f766e;
  --primary-dark: #0b5c56;
  --border: #d8e3e5;
  --danger: #b42318;
  --warning: #9a6700;
  --success: #067647;
  --shadow: 0 10px 30px rgba(21, 55, 63, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
  padding: 2rem max(1.25rem, calc((100vw - 1380px) / 2));
  color: white;
  background: linear-gradient(125deg, #0b5c56, #0f766e 52%, #155e75);
}
.app-header h1 { margin: .15rem 0 .25rem; font-size: clamp(1.65rem, 3vw, 2.6rem); }
.eyebrow { margin: 0; letter-spacing: .18em; font-weight: 800; font-size: .78rem; opacity: .78; }
.subtitle { margin: 0; opacity: .86; }
.privacy-badge { padding: .6rem .9rem; border: 1px solid rgba(255,255,255,.35); border-radius: 999px; white-space: nowrap; background: rgba(255,255,255,.08); }

.container { max-width: 1380px; margin: 0 auto; padding: 1.5rem; }
.tabs { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tab-button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 10px;
  padding: .7rem 1rem;
  font-weight: 700;
}
.tab-button.active { background: var(--primary); color: white; border-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.span-2 { grid-column: 1 / -1; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.15rem;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 1rem; font-size: 1.1rem; }
.card h3 { margin: 1.25rem 0 .75rem; font-size: 1rem; }
.grid { display: grid; gap: .85rem; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .8rem; }
.field > span { color: #304a52; font-weight: 700; font-size: .9rem; }
.field small { color: var(--muted); }
input, select, textarea {
  width: 100%;
  border: 1px solid #c7d6d9;
  border-radius: 9px;
  padding: .68rem .75rem;
  background: white;
  color: var(--text);
}
textarea { resize: vertical; font-family: "Cascadia Code", Consolas, monospace; font-size: .87rem; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(15,118,110,.16); border-color: var(--primary); }
input[type="checkbox"] { width: auto; }
input[type="range"] { padding: 0; }
output { color: var(--muted); font-size: .85rem; }
.checkbox-field, .compact-options label { display: flex; align-items: center; gap: .5rem; min-height: 2rem; }
.compact-options { margin: .5rem 0 1rem; }

details summary { cursor: pointer; font-weight: 800; }
.details-content { margin-top: 1rem; }
.notice { padding: .8rem; border-left: 4px solid var(--warning); background: #fffaeb; border-radius: 8px; color: #6b4f00; }
.help-text p { margin: .45rem 0; }

.action-card { display: flex; gap: .75rem; justify-content: flex-end; }
.primary, .secondary, .download-link {
  border: none;
  border-radius: 10px;
  padding: .78rem 1.05rem;
  font-weight: 800;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
}
.primary { background: var(--primary); color: white; }
.primary:hover { background: var(--primary-dark); }
.secondary { background: #edf2f3; color: #31484f; }
.download-link { background: #e6f6f4; color: var(--primary-dark); border: 1px solid #b8dfda; }

.status { position: sticky; top: .75rem; z-index: 20; margin-bottom: 1rem; padding: .85rem 1rem; border-radius: 10px; box-shadow: var(--shadow); }
.status.info { background: #eff8ff; color: #175cd3; border: 1px solid #b2ddff; }
.status.success { background: #ecfdf3; color: var(--success); border: 1px solid #abefc6; }
.status.error { background: #fef3f2; color: var(--danger); border: 1px solid #fecdca; }
.status.warning { background: #fffaeb; color: var(--warning); border: 1px solid #fedf89; }
.hidden { display: none !important; }

.results { margin-top: 1.25rem; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 1.15rem; box-shadow: var(--shadow); }
.result-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.download-row { display: flex; gap: .6rem; flex-wrap: wrap; margin: .75rem 0; }
.gallery { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.chart-card { border: 1px solid var(--border); border-radius: 12px; padding: .75rem; background: white; }
.chart-card h3 { margin: .2rem 0 .7rem; }
.chart { width: 100%; min-height: 630px; }
.result-text { background: #f8fbfb; border: 1px solid var(--border); padding: 1rem; border-radius: 10px; }

.table-wrap { overflow: auto; max-height: 580px; border: 1px solid var(--border); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: .55rem .65rem; border-bottom: 1px solid #e7edef; white-space: nowrap; text-align: left; }
th { position: sticky; top: 0; background: #edf7f6; z-index: 1; }
.row-red td { background: #ff9999; }
.row-orange td { background: #ffcc80; }
.row-yellow td { background: #fff59d; }
.row-purple td { background: #d1c4e9; }
.cell-yellow { background: #ffff00; }

footer { max-width: 1380px; margin: 0 auto; padding: 1rem 1.5rem 2rem; color: var(--muted); font-size: .9rem; }
code { background: #e7edef; padding: .1rem .3rem; border-radius: 4px; }

@media (max-width: 900px) {
  .app-header { align-items: flex-start; flex-direction: column; }
  .panel-grid, .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .chart { min-height: 480px; }
}
