/* Intermod Tool – PhosMega house style
 * Colors from the PhosMega logo package: orange #f39f18, petrol #1d2f33.
 */

:root {
  --orange: #f39f18;
  --orange-dark: #d9880a;
  --petrol: #1d2f33;
  --petrol-light: #2c454b;
  --background: #f6f1ee;
  --surface: #ffffff;
  --border: #e3dbd5;
  --text: #1d2f33;
  --muted: #6b7a7d;
  --danger: #c0392b;
  --success: #2e8b57;
  --warning: #d68910;
  --radius: 8px;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--background);
  color: var(--text);
  font-family: "Poppins", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--petrol); text-decoration-color: var(--orange); text-underline-offset: 3px; }
a:hover { color: var(--orange-dark); }

h1, h2 { font-weight: 600; margin: 0 0 12px; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; }

.muted { color: var(--muted); }
.small { font-size: 0.85em; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* --- Header ---------------------------------------------------------------- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 24px;
  background: var(--petrol);
  color: #fff;
}

.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand:hover { color: #fff; }
.brand-sun { height: 34px; width: 34px; }
.brand-name { font-size: 1.15rem; font-weight: 600; letter-spacing: 0.02em; }

.site-nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.site-nav a, .site-nav .link-button { color: #fff; text-decoration: none; font-weight: 500; }
.site-nav a:hover, .site-nav .link-button:hover { color: var(--orange); }

.link-button {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  cursor: pointer;
}

.inline-form { display: inline; margin: 0; }

/* --- Main ------------------------------------------------------------------ */

main.page { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 24px 16px 40px; }
main.page.wide { max-width: 1500px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.card.narrow { max-width: 520px; margin-left: auto; margin-right: auto; }
.card-header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }

.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; border-left: 4px solid var(--petrol); background: #fff; }
.flash-error { border-color: var(--danger); background: #fdf0ee; }
.flash-success { border-color: var(--success); background: #eef8f2; }
.flash-info { border-color: var(--orange); background: #fff7ea; }

/* --- Forms and buttons ----------------------------------------------------- */

.stacked-form { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.stacked-form label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; }
.stacked-form label.checkbox { flex-direction: row; align-items: center; gap: 8px; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
  font: inherit;
  color: inherit;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--orange); outline-offset: -1px; border-color: var(--orange); }
input.invalid { border-color: var(--danger); background: #fdf0ee; }

.button {
  display: inline-block;
  font: inherit;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--petrol);
  background: #fff;
  color: var(--petrol);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.button:hover { background: #f1ece8; color: var(--petrol); }
.button.primary { background: var(--orange); border-color: var(--orange); color: var(--petrol); }
.button.primary:hover { background: var(--orange-dark); border-color: var(--orange-dark); }
.button.danger { border-color: var(--danger); color: var(--danger); }
.button.danger:hover { background: #fdf0ee; }
.button.small { padding: 3px 9px; font-size: 0.85em; }

/* --- Calculator: toolbar and settings -------------------------------------- */

.toolbar, .settings { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.toolbar p { margin: 0; flex: 1; }
.toolbar-field { display: flex; flex-direction: column; gap: 4px; font-weight: 500; font-size: 0.9em; }
.toolbar-field.grow { flex: 1; min-width: 220px; }
.toolbar-message { flex-basis: 100%; min-height: 1.2em; font-size: 0.9em; color: var(--success); }
.toolbar-message:empty { display: none; }
.toolbar-message.error { color: var(--danger); }

.model-panel { flex: 1; min-width: 260px; }
.model-panel summary { cursor: pointer; font-weight: 500; padding: 7px 0; }
.model-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px 16px; margin: 8px 0 12px; }
.model-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85em; }

/* --- Calculator: input groups ---------------------------------------------- */

.group-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.group-grid .group-wide { grid-column: 1 / -1; }
@media (max-width: 900px) { .group-grid { grid-template-columns: 1fr; } }

.table-wrap { overflow-x: auto; }

.input-table { border-collapse: collapse; width: 100%; }
.input-table th {
  text-align: left;
  font-weight: 500;
  font-size: 0.85em;
  padding: 4px 6px 8px;
  border-bottom: 2px solid var(--orange);
  vertical-align: bottom;
}
.input-table td { padding: 4px 6px; border-bottom: 1px solid #f0ebe7; vertical-align: middle; }
.input-table .unit { color: var(--muted); font-weight: 400; }
.input-table .num-input { width: 100%; min-width: 80px; text-align: right; }
.input-table .row-label { font-weight: 600; color: var(--muted); width: 1%; white-space: nowrap; }
.input-table .new-row .num-input { background: #fbf8f6; border-style: dashed; }
.input-table .new-row .row-label { color: var(--orange-dark); }
.input-table .result-cell { white-space: nowrap; }

.remove-row {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
}
.remove-row:hover { color: var(--danger); background: #fdf0ee; }

/* --- Badges ---------------------------------------------------------------- */

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.8em; font-weight: 500; white-space: nowrap; }
.result-clear { background: #e6f4ec; color: var(--success); }
.result-below { background: #fdf2e1; color: #a5680a; }
.result-above { background: #fbe5e2; color: var(--danger); }

.status-pending { background: #fdf2e1; color: #a5680a; }
.status-active { background: #e6f4ec; color: var(--success); }
.status-disabled, .status-rejected { background: #eceff0; color: var(--muted); }

/* --- Results --------------------------------------------------------------- */

.chart { width: 100%; min-height: 520px; }
#calc-status.error, .error-text { color: var(--danger); font-weight: 500; }

.data-table { border-collapse: collapse; width: 100%; }
.data-table th, .data-table td { padding: 6px 8px; border-bottom: 1px solid #f0ebe7; text-align: left; }
.data-table th.num, .data-table td.num { text-align: right; }
.data-table thead th { font-weight: 500; font-size: 0.85em; border-bottom: 2px solid var(--orange); }
.data-table .group-row th { background: #f7f3f0; font-weight: 600; padding-top: 10px; }
.data-table .group-badge { margin-left: 8px; }
.data-table .level-above { color: var(--danger); font-weight: 600; }
.order-dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 8px; vertical-align: middle; }

/* --- Admin ----------------------------------------------------------------- */

.row-pending td { background: #fffaf1; }
.actions { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.note { max-width: 280px; white-space: pre-wrap; }
.inline-details { display: inline-block; }
.inline-details summary { list-style: none; }
.inline-details summary::-webkit-details-marker { display: none; }
.inline-details[open] form { display: flex; gap: 4px; margin-top: 4px; }
.details { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 20px; }
.details dt { color: var(--muted); }
.details dd { margin: 0; }

/* --- Footer: logo bottom-left, rising sun bottom-right, orange line ------- */

.site-footer { background: var(--petrol); margin-top: auto; }
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 14px 24px 8px;
}
.footer-logo img { height: 34px; display: block; }
.footer-sun { height: 26px; display: block; }
.footer-line { height: 4px; background: var(--orange); }
