/* EngTool F&G Safety Studio — light theme, responsive */
:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #61708a;
  --line: #d9e0ea;
  --primary: #1b6ef3;
  --primary-d: #1559c4;
  --danger: #d64545;
  --green: #2e9e5b;
  --orange: #e08a1e;
  --shadow: 0 1px 3px rgba(20,40,80,.08), 0 4px 16px rgba(20,40,80,.06);
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    "PingFang SC", "Microsoft YaHei", "Noto Sans CJK", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

/* Header */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px; background: var(--panel);
  border-bottom: 1px solid var(--line); box-shadow: var(--shadow);
  flex-wrap: wrap; gap: 10px;
}
.brand { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.brand-title { font-size: 19px; font-weight: 700; color: var(--primary); letter-spacing: .2px; }
.brand-tag { font-size: 12px; color: var(--muted); }
.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lang-label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
select, input[type="number"] {
  font: inherit; padding: 6px 8px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; color: var(--ink); min-width: 70px;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); cursor: pointer; font: inherit; font-weight: 600;
  text-decoration: none; transition: .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-d); color: #fff; }
.btn-danger { color: var(--danger); border-color: #f0c4c4; }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-home { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-home:hover { background: var(--primary-d); color: #fff; }
.btn-email { background: #fff; color: var(--ink); }

/* Tabs */
.tabs { display: flex; gap: 4px; padding: 8px 14px 0; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tab {
  border: none; background: transparent; padding: 9px 16px; cursor: pointer;
  font: inherit; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent;
}
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Workspace */
.workspace { display: grid; grid-template-columns: 270px 1fr 280px; gap: 14px; padding: 14px; align-items: start; }
.controls, .results {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow);
}
.ctl-panel h3 { margin: 0 0 10px; font-size: 15px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-size: 12px; color: var(--muted); }
.field select, .field input { width: 100%; }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 10px; }
.btn-row { display: flex; gap: 8px; margin-bottom: 12px; }
.tool { flex: 1; }
.tool.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.hint { font-size: 11.5px; color: var(--muted); background: #f7f9fc; border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin: 8px 0; }

/* Stage */
.stage { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
.canvas-wrap { width: 100%; }
#mainCanvas { width: 100%; height: auto; display: block; border-radius: 8px; background: #eef2f7; cursor: crosshair; touch-action: none; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.legend .item { display: flex; align-items: center; gap: 6px; }
.legend .swatch { width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0,0,0,.15); }

/* Results */
.results h3 { margin: 0 0 10px; font-size: 15px; }
.results .stat { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.results .stat .k { color: var(--muted); }
.results .stat .v { font-weight: 700; }
.results .note { font-size: 12px; color: var(--muted); margin-top: 10px; }
.results .warn { font-size: 12px; color: #8a2b2b; background: #fbeaea; border: 1px solid #e6b3b3; border-radius: 8px; padding: 7px 9px; margin-top: 8px; }
.results table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 8px; }
.results th, .results td { border: 1px solid var(--line); padding: 4px 6px; text-align: left; }
.results table.mini { width: auto; min-width: 60%; font-size: 11.5px; }
.results table.mini th, .results table.mini td { padding: 3px 8px; }
.results h4 { margin: 14px 0 4px; font-size: 13px; color: var(--ink); }

.app-footer { padding: 12px 18px; font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--line); background: var(--panel); }

/* Charts (results panel) */
.chart { width: 100%; height: 172px; margin-top: 10px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }

.hidden { display: none !important; }

/* Responsive */
@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .controls, .results { order: 2; }
  .stage { order: 1; }
}
@media print {
  .app-header, .tabs, .controls, .app-footer, .legend { display: none !important; }
  .workspace { display: block; }
  .stage { box-shadow: none; border: none; }
}

/* Toast (transient status / error messages) */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: #1f2933; color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 13px; box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease; z-index: 50; max-width: 80%;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: #b3261e; }
.toast.ok { background: #1f7a45; }
.toast.warn { background: #9a6b13; }

/* Import status line */
.import-status { margin-top: 8px; font-size: 12px; padding: 6px 9px; border-radius: 8px; display: none; }
.import-status.ok { display: block; color: #1f7a45; background: #e7f5ec; border: 1px solid #bfe6cd; }
.import-status.warn { display: block; color: #8a5a10; background: #fbf2dd; border: 1px solid #ecd9a6; }
.import-status.error { display: block; color: #8a2b2b; background: #fbeaea; border: 1px solid #e6b3b3; }

/* Methodology / engineering-basis blocks (report panel) */
.method-block { background: #f7f9fc; border: 1px solid #e3e9f2; border-radius: 8px; padding: 8px 12px; margin: 8px 0; }
.method-block h5 { margin: 2px 0 4px; font-size: 13px; color: var(--primary); }
.method-block p { margin: 4px 0; font-size: 12px; color: var(--ink); }
.method-block ul { margin: 4px 0; padding-left: 18px; font-size: 12px; }
.method-label { font-weight: 700; color: #33405a; margin: 6px 0 2px; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; }
.method-warn { color: #8a2b2b; background: #fbeaea; border: 1px solid #e6b3b3; border-radius: 6px; padding: 6px 10px; }

/* Inline methodology summary inside results panel (non-report view) */
.meth-inline { margin: 10px 0 4px; border: 1px solid #e3e9f2; border-radius: 8px; background: #fbfcfe; padding: 2px 10px; }
.meth-inline > summary { cursor: pointer; font-weight: 700; color: var(--primary); font-size: 13px; padding: 6px 0; outline: none; }
.meth-inline > summary::marker { color: var(--primary); }
.meth-inline .method-block { border: none; background: transparent; padding: 0; margin: 4px 0 8px; }

/* Disabled buttons (undo/redo at history bounds) */
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---- Gap-feature UI: weather-mix frequency grid, multi-release list, mono textareas ---- */
.freq-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; margin: 6px 0; }
.freq-grid .field.sm { display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
.freq-grid .field.sm input { width: 100%; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; line-height: 1.4; }
.rel-list { margin: 6px 0 2px; display: flex; flex-direction: column; gap: 4px; }
.rel-item { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: #f4f7fb; border: 1px solid #e0e7f1; border-radius: 6px; padding: 3px 8px; font-size: 12px; }
.rel-del { border: none; background: #f3d6d6; color: #8a2b2b; border-radius: 4px; cursor: pointer;
  width: 20px; height: 20px; line-height: 1; font-size: 14px; }
.rel-del:hover { background: #efc2c2; }
.chart { width: 100%; max-width: 320px; margin: 6px 0; background: #fff; border: 1px solid #e3e9f2; border-radius: 8px; }
.view3d-canvas { width: 100%; margin: 8px 0; border: 1px solid #d4d9e2; border-radius: 8px; background: #eef2f7; overflow: hidden; }
.view3d-canvas canvas { width: 100%; display: block; touch-action: none; cursor: grab; }
