/* SPDX-License-Identifier: Apache-2.0 */
/* MonzBIM: app bar, ribbon, project browser, the view, the properties palette. Light work area, dark frame. */
:root {
  --frame: #161b22; --frame-2: #1f2630; --frame-ink: #e8edf2; --frame-dim: #9aa6b2;
  --paper: #ffffff; --ink: #1d232b; --ink-2: #5b6672; --line: #d7dce2; --soft: #f3f5f7;
  --accent: #ff7a2f; --accent-2: #2f7bff; --sel: #2f7bff; --ok: #1f9d55; --bad: #c0392b;
  font-family: "IBM Plex Sans Thai", "Noto Sans Thai", "Segoe UI", system-ui, sans-serif; font-size: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { display: grid; grid-template-rows: auto auto 1fr auto; background: var(--soft); color: var(--ink); overflow: hidden; }
button, input, select { font: inherit; }
[hidden] { display: none !important; }

.appbar { display: flex; align-items: center; gap: 14px; padding: 6px 12px; background: var(--frame); color: var(--frame-ink); }
.brand { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; letter-spacing: .02em; }
.filebar { display: flex; gap: 4px; }
.filebar button { background: transparent; border: 1px solid transparent; color: var(--frame-ink); border-radius: 6px; padding: 4px 10px; cursor: pointer; }
.filebar button:hover { border-color: #3a4552; }
.filebar button:disabled { opacity: .4; cursor: default; }
.projname { margin-left: auto; color: var(--frame-dim); font-size: 13px; }

.ribbon { background: var(--frame-2); color: var(--frame-ink); border-bottom: 1px solid #000; }
.rtabs { display: flex; gap: 2px; padding: 0 10px; }
.rtabs button { background: transparent; border: 0; color: var(--frame-dim); padding: 6px 14px; cursor: pointer; border-bottom: 2px solid transparent; }
.rtabs button[aria-pressed="true"] { color: var(--frame-ink); border-bottom-color: var(--accent); }
.rpanels { display: flex; gap: 0; padding: 6px 10px 4px; background: #252d38; min-height: 74px; }
.rpanel { display: flex; flex-direction: column; padding: 0 10px; border-right: 1px solid #3a4552; }
.rpanel:last-child { border-right: 0; }
.rpanel .rtools { display: flex; gap: 4px; flex: 1; align-items: flex-start; }
.rpanel .rname { font-size: 11px; color: var(--frame-dim); text-align: center; padding-top: 2px; }
.rtool { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 56px; padding: 4px 6px; background: transparent; border: 1px solid transparent; border-radius: 6px; color: var(--frame-ink); cursor: pointer; font-size: 12px; }
.rtool:hover { background: #2f3946; }
.rtool[aria-pressed="true"] { background: #3a2a20; border-color: var(--accent); }
.rtool svg { width: 26px; height: 26px; }
.rtool kbd { font: 10px/1 ui-monospace, monospace; color: var(--frame-dim); }

.work { display: grid; grid-template-columns: 240px 1fr 280px; min-height: 0; }
.side { background: var(--paper); overflow: auto; min-height: 0; }
.side.left { border-right: 1px solid var(--line); }
.side.right { border-left: 1px solid var(--line); }
.side h2 { font-size: 12px; text-transform: none; letter-spacing: .02em; color: var(--ink-2); margin: 0; padding: 10px 12px 4px; display: flex; align-items: center; justify-content: space-between; }
.side h2 button { background: none; border: 0; color: var(--accent-2); cursor: pointer; font-size: 12px; }
.tree { list-style: none; margin: 0; padding: 0 6px 6px; }
.tree li button { display: flex; width: 100%; align-items: center; gap: 6px; background: transparent; border: 0; border-radius: 5px; padding: 4px 8px; text-align: left; cursor: pointer; color: var(--ink); }
.tree li button:hover { background: var(--soft); }
.tree li button[aria-current="true"] { background: #e6efff; color: #0d3b8a; font-weight: 600; }
.tree .dim { color: var(--ink-2); font-size: 12px; margin-left: auto; }

.center { display: grid; grid-template-rows: auto 1fr; min-width: 0; min-height: 0; }
.viewbar { display: flex; align-items: center; gap: 10px; padding: 5px 10px; background: var(--paper); border-bottom: 1px solid var(--line); font-size: 13px; color: var(--ink-2); }
.viewbar b { color: var(--ink); }
.viewbar button { background: var(--soft); border: 1px solid var(--line); border-radius: 5px; padding: 2px 8px; cursor: pointer; }
.stage { position: relative; min-height: 0; background: #fff; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#plan { cursor: crosshair; }
.tableview { position: absolute; inset: 0; overflow: auto; padding: 14px; background: #fff; }

.props { padding: 4px 12px 14px; display: grid; grid-template-columns: 96px 1fr; gap: 6px 8px; align-items: center; font-size: 13px; }
.props .k { color: var(--ink-2); }
.props .span { grid-column: 1 / -1; }
.props input, .props select { width: 100%; padding: 4px 6px; border: 1px solid var(--line); border-radius: 5px; background: #fff; }
.props .ro { padding: 4px 0; }
.btn { background: var(--soft); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; cursor: pointer; }
.btn:hover { border-color: var(--accent-2); }
.btn.bad { color: var(--bad); }
.btn.primary { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.note { color: var(--ink-2); font-size: 12px; line-height: 1.5; }

.foot { display: flex; align-items: center; gap: 14px; padding: 4px 12px; background: var(--frame); color: var(--frame-ink); font-size: 13px; min-height: 30px; }
.hint { color: var(--frame-dim); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.typed input { width: 90px; background: #0f1318; color: var(--frame-ink); border: 1px solid #3a4552; border-radius: 4px; padding: 2px 6px; }
#msg { color: #ffd2b5; }

/* schedules */
.sched-head { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-bottom: 10px; font-size: 13px; }
.sched-head label { display: inline-flex; gap: 4px; align-items: center; }
.sched-fields { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 12px; margin-bottom: 10px; color: var(--ink-2); }
table.sched { border-collapse: collapse; font-size: 13px; min-width: 60%; }
table.sched th, table.sched td { border: 1px solid #b9c3cf; padding: 4px 8px; }
table.sched th { background: #eef2f6; text-align: left; }
table.sched td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.sched tr.group td { background: #f6f8fa; font-weight: 600; }
table.sched tr.sub td, table.sched tr.total td { font-weight: 700; }
table.sched tr.total td { border-top: 3px double #7a8794; }

/* MonzDraw's type editor, shown in a dialog */
dialog.types { width: min(980px, 94vw); max-height: 88vh; border: 1px solid var(--line); border-radius: 10px; padding: 0; }
dialog.types::backdrop { background: rgba(10, 14, 20, .45); }
dialog.types header { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
dialog.types .body { padding: 10px 14px; overflow: auto; max-height: calc(88vh - 56px); }
.mz-row { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin: 4px 0; }
.mz-type { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 8px 0; }
.mz-table { border-collapse: collapse; font-size: 13px; }
.mz-table th, .mz-table td { border-bottom: 1px solid var(--line); padding: 3px 6px; text-align: left; }
.mc-input, .mc-select { padding: 3px 6px; border: 1px solid var(--line); border-radius: 5px; }
.mz-len { width: 6.5em; }
.mz-fld { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; }
.mz-fld > span { color: var(--ink-2); }
.mz-paint { display: inline-flex; gap: 4px; align-items: center; }
.mz-swatch { width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--line); display: inline-block; }
.mz-tabs { display: inline-flex; gap: 2px; }
.mz-tab { background: var(--soft); border: 1px solid var(--line); padding: 3px 10px; border-radius: 5px; cursor: pointer; }
.mz-tab[aria-pressed="true"] { background: #e6efff; border-color: var(--accent-2); }
.btn-line, .btn-plot { background: var(--soft); border: 1px solid var(--line); border-radius: 5px; padding: 3px 8px; cursor: pointer; }
.btn-plot { background: var(--accent-2); color: #fff; border-color: var(--accent-2); }
.mc-note { color: var(--ink-2); font-size: 12px; }
.mz-type-boq { border-top: 1px dashed var(--line); padding-top: 4px; }
.mz-type-boq .mc-input { width: 9em; }

@media (max-width: 900px) { .work { grid-template-columns: 1fr; } .side { display: none; } }
