/* Options Live — shared styles */
:root {
  --bg: #f3f4f7;
  --panel: #ffffff;
  --panel-2: #f8f9fb;
  --ink: #1b2230;
  --muted: #667085;
  --line: #dfe3ea;
  --line-strong: #c7cdd8;
  --accent: #1f5fd1;
  --accent-ink: #ffffff;
  --accent-soft: #e8effc;
  --ok: #16794a;
  --warn: #a15c07;
  --err: #b42318;
  --err-soft: #fdecea;
  --header: #18202e;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --field: #ffffff;
  --warn-soft: #fff7e6;
  --warn-line: #f3d38b;
  --warn-ink: #6b4a00;
  --warn-text: #8a5a00;
  --ok-soft: #dcf3e6;
  --err-line: #f2b8b5;
  --info-soft: #e7eefc;
  --info-ink: #2f55b5;
  --param: #4a3fb0;
  --cad: var(--cad);
  --row-dirty: #fffaeb;
  --row-new: #f6f9ff;
  --limited-line: #b9c6ef;
  --limited-bg: #f6f8ff;
  --alt-ink: #8a6d1f;
  --suppress: #9b3b3b;
  --resume: #1f7a45;
  --text-2: #444444;
  --neutral-soft: #eeeeee;
  --neutral-ink: #888888;
  --toast-bg: #1b2230;
  --overlay: rgba(16, 24, 40, .35);
  color-scheme: light;
}

/* ---------- dark mode (default, like the Amada site); js/theme.js sets data-theme ---------- */
:root[data-theme="dark"] {
  --bg: #12161c;
  --panel: #1a2029;
  --panel-2: #202834;
  --ink: #e4e9ef;
  --muted: #9aa5b3;
  --line: #2e3744;
  --line-strong: #3d4858;
  --accent: #7fa2f0;
  --accent-ink: #0f1724;
  --accent-soft: #1d2a47;
  --ok: #5cc58e;
  --warn: #e8a64a;
  --err: #f08a82;
  --err-soft: #3d1a18;
  --header: #0d1116;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --field: #12161c;
  --warn-soft: #3a2a12;
  --warn-line: #6b5420;
  --warn-ink: #f0c98a;
  --warn-text: #e8a64a;
  --ok-soft: #153024;
  --err-line: #6e2f2c;
  --info-soft: #1d2a47;
  --info-ink: #7fa2f0;
  --param: #b19cf2;
  --cad: #4fd1b5;
  --row-dirty: #2e2812;
  --row-new: #16233a;
  --limited-line: #3d5a9a;
  --limited-bg: #172238;
  --alt-ink: #e0b85a;
  --suppress: #f08a82;
  --resume: #5cc58e;
  --text-2: #c0c8d4;
  --neutral-soft: #2a3240;
  --neutral-ink: #9aa5b3;
  --toast-bg: #2c3646;
  --overlay: rgba(0, 0, 0, .55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.45 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- header ---------- */
.app-header { display: flex; align-items: center; gap: 14px; padding: 0 18px; height: 52px; background: var(--header); color: #fff; }
.app-header .brand { font-weight: 600; font-size: 16px; letter-spacing: .01em; }
.app-header .brand span { color: #9fb7e8; font-weight: 400; }
.app-header .spacer { flex: 1; }
.app-header .who { font-size: 13px; color: #c8d1e0; text-align: right; line-height: 1.2; }
.app-header .who b { color: #fff; font-weight: 600; }
.app-header .role { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 9px; background: #2f3b52; color: #dfe6f3; margin-left: 4px; }
.app-header button { background: transparent; border: 1px solid #3a465d; color: #dfe6f3; border-radius: var(--radius); padding: 4px 10px; cursor: pointer; }
.app-header button:hover { background: #253045; }
.dev-banner { background: var(--warn-soft); color: var(--warn-ink); border-bottom: 1px solid var(--warn-line); padding: 6px 18px; font-size: 12.5px; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); background: var(--panel); border-radius: var(--radius); padding: 5px 11px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--err); }
.btn.small { padding: 2px 8px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { border: none; background: transparent; cursor: pointer; padding: 2px 5px; border-radius: 4px; color: var(--muted); font-size: 13px; line-height: 1; }
.icon-btn:hover { background: var(--line); color: var(--ink); }
.icon-btn:disabled { opacity: .3; cursor: default; background: transparent; }
.icon-btn.danger:hover { background: var(--err-soft); color: var(--err); }

label.field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
label.field > span { font-weight: 600; }
input[type=text], input[type=email], input[type=number], input[type=search], input[type=password], input:not([type]), select, textarea {
  border: 1px solid var(--line-strong); border-radius: 5px; padding: 6px 8px; background: var(--field); color: var(--ink); min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
label.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); }

/* ---------- toast ---------- */
#toast { position: fixed; right: 18px; bottom: 18px; max-width: 420px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
#toast .t { background: var(--toast-bg); color: #fff; padding: 9px 13px; border-radius: var(--radius); box-shadow: 0 4px 14px rgba(0,0,0,.18); font-size: 13px; }
#toast .t.err { background: var(--err); }
#toast .t.ok { background: var(--ok); }

/* ---------- login ---------- */
.login-wrap { max-width: 760px; margin: 36px auto; padding: 0 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.card-head { padding: 16px 20px 0; }
.card-head h1 { margin: 0 0 4px; font-size: 20px; }
.card-head p { margin: 0; color: var(--muted); }
.tabs { display: flex; gap: 4px; padding: 14px 20px 0; border-bottom: 1px solid var(--line); }
.tabs button { border: 1px solid transparent; border-bottom: none; background: transparent; padding: 8px 14px; border-radius: 6px 6px 0 0; cursor: pointer; color: var(--muted); }
.tabs button.on { background: var(--panel); border-color: var(--line); color: var(--ink); font-weight: 600; margin-bottom: -1px; }
.card-body { padding: 18px 20px 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.hint { color: var(--muted); font-size: 12.5px; }

/* ---------- builder layout ---------- */
.builder { display: grid; grid-template-columns: 240px minmax(0, 1fr); height: calc(100vh - 52px - 41px); }
.builder.has-banner { height: calc(100vh - 52px - 41px - 30px); }
.sidebar { border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 8px; }
.sidebar-head h2, .pane-head h3 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.product-list { list-style: none; margin: 0; padding: 0 6px 10px; overflow: auto; }
.product-list li { padding: 8px 10px; border-radius: var(--radius); cursor: pointer; }
.product-list li:hover { background: var(--panel-2); }
.product-list li.on { background: var(--accent-soft); }
.product-list .pn { font-weight: 600; }
.product-list .pm { font-size: 12px; color: var(--muted); }
.status { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 8px; background: var(--line); color: var(--muted); }
.status.Published { background: var(--ok-soft); color: var(--ok); }
.status.Archived { background: var(--neutral-soft); color: var(--neutral-ink); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
.empty { margin: auto; text-align: center; color: var(--muted); padding: 40px; }
.empty h2 { color: var(--ink); font-size: 18px; margin: 0 0 6px; }

.product-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; padding: 12px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.product-bar .grow { flex: 1 1 220px; }
.product-bar .key { flex: 0 1 180px; }

.panes { flex: 1; display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 12px; padding: 12px 16px 16px; min-height: 0; }
.stack { display: grid; grid-template-rows: minmax(0, 1fr) minmax(0, 1.4fr); gap: 12px; min-height: 0; }
.pane { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.pane-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.pane-body { overflow: auto; flex: 1; min-height: 0; }

.rows { list-style: none; margin: 0; padding: 6px; }
.rows li { display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 8px; border-radius: var(--radius); cursor: pointer; }
.rows li:hover { background: var(--panel-2); }
.rows li.on { background: var(--accent-soft); }
.rows li.off { opacity: .55; }
.rows li.off .rn { text-decoration: line-through; }
.rows .rn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rows .rm { font-size: 11.5px; color: var(--muted); }
.rows .acts { display: none; gap: 1px; }
.rows li:hover .acts, .rows li.on .acts { display: inline-flex; }

.edit-box { padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--panel-2); display: grid; gap: 8px; }
.edit-box .two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.edit-box .acts { display: flex; justify-content: flex-end; gap: 6px; }

/* items grid */
.input-props { display: grid; grid-template-columns: 2fr 1fr 1fr 1.3fr; gap: 10px 12px; padding: 12px; border-bottom: 1px solid var(--line); background: var(--panel-2); align-items: end; }
.input-props .help { grid-column: span 2; }
.input-props .acts { display: flex; justify-content: flex-end; gap: 6px; }
@media (max-width: 1000px) { .input-props { grid-template-columns: 1fr 1fr; } .input-props .help { grid-column: 1 / -1; } }
table.grid { border-collapse: separate; border-spacing: 0; width: 100%; }
table.grid th { position: sticky; top: 0; background: var(--panel); z-index: 1; text-align: left; font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 7px 6px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
table.grid th.attr { color: var(--param); }
table.grid td { padding: 2px 3px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid tr.off td { opacity: .5; }
table.grid tr.dirty td { background: var(--row-dirty); }
table.grid tr.new td { background: var(--row-new); }
table.grid td input[type=text] { width: 100%; border-color: transparent; background: transparent; padding: 5px 6px; }
table.grid td input[type=text]:hover { border-color: var(--line); background: var(--field); }
table.grid td input[type=text]:focus { background: var(--field); }
table.grid td.c-val { min-width: 110px; }
table.grid td.c-disp { min-width: 150px; }
table.grid td.c-pn { min-width: 100px; }
table.grid td.c-desc { min-width: 170px; }
table.grid td.c-attr { min-width: 90px; }
table.grid td.c-def { text-align: center; }
table.grid td.c-acts { white-space: nowrap; }
table.grid th.cad { color: var(--cad); }
table.grid td.c-cad { font-size: 11.5px; color: var(--cad); max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cad-line { font-size: 12px; color: var(--cad); }
.sidebar-head > span { display: inline-flex; gap: 6px; }
.grid-foot { padding: 8px 12px; display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 12.5px; }

/* drawer (report parameters) */
.drawer-bg { position: fixed; inset: 0; background: var(--overlay); z-index: 20; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--panel); z-index: 21; display: flex; flex-direction: column; box-shadow: -8px 0 24px rgba(0,0,0,.15); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 16px; }
.drawer-body { overflow: auto; padding: 12px 16px; flex: 1; }
.attr-row { display: grid; grid-template-columns: 1fr 110px 80px auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.attr-row.off { opacity: .55; }
.attr-flags { grid-column: 1 / -1; display: flex; gap: 16px; }
.muted { color: var(--muted); }

/* rules drawer */
.drawer .rule { border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; margin-bottom: 8px; display: grid; gap: 3px; font-size: 13px; }
.drawer .rule.off { opacity: .6; }
.drawer .muted, .muted { color: var(--muted); font-size: 12.5px; }

/* ---------- theme toggle ---------- */
.theme-btn { min-width: 34px; font-size: 14px; line-height: 1; }
.theme-float { position: fixed; top: 10px; right: 12px; z-index: 30; border: 1px solid var(--line-strong); background: var(--panel); color: var(--ink); border-radius: var(--radius); padding: 5px 9px; cursor: pointer; }

/* ---------- page tabs (under the header, on every page) ---------- */
.app-tabs { display: flex; align-items: flex-end; gap: 2px; height: 41px; padding: 0 14px; background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; }
.app-tabs a { display: inline-flex; align-items: center; height: 40px; padding: 0 14px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 13.5px; border-bottom: 3px solid transparent; white-space: nowrap; }
.app-tabs a:hover { color: var(--ink); background: var(--panel-2); }
.app-tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }
.app-tabs .spacer { flex: 1; }
.app-tabs a.tab-action { font-weight: 500; font-size: 12.5px; border: 1px solid var(--line-strong); border-radius: var(--radius); height: 28px; margin-bottom: 6px; padding: 0 10px; color: var(--ink); }
.bad-text { color: var(--err); }
