:root {
  --bg: #f4f2ee;
  --panel: #ffffff;
  --ink: #23211e;
  --muted: #77726a;
  --line: #e2ddd4;
  --accent: #b5652b;
  --accent-ink: #fff;
  --accent-soft: #f6e8dc;
  --danger: #b33a3a;
  --radius: 8px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 14px; }
button, input, select { font: inherit; color: inherit; }
button {
  border: 1px solid var(--line); background: var(--panel); border-radius: 6px;
  padding: 6px 10px; cursor: pointer; white-space: nowrap;
}
button:hover { border-color: #c9c2b6; background: #faf8f5; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { filter: brightness(1.06); }
button.danger { color: var(--danger); }
button.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
button:disabled { opacity: .45; cursor: default; }
input, select {
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; background: #fff; min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
label { color: var(--muted); font-size: 12px; }
.error { color: var(--danger); min-height: 1.2em; font-size: 13px; }
.muted { color: var(--muted); }

/* ------ strona logowania ------ */
.auth-wrap { min-height: 100%; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero {
  background: #2b2723; color: #f4efe8; padding: 56px; display: flex; flex-direction: column; justify-content: space-between;
  background-image: linear-gradient(135deg, rgba(181,101,43,.25), transparent 60%);
}
.auth-hero h1 { font-size: 40px; margin: 0 0 12px; letter-spacing: -0.02em; }
.auth-hero p { color: #cfc6ba; max-width: 420px; line-height: 1.55; }
.auth-hero ul { color: #cfc6ba; line-height: 1.9; padding-left: 18px; }
.auth-card { display: flex; align-items: center; justify-content: center; padding: 40px; }
.auth-box { width: 100%; max-width: 360px; }
.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.tabs button { border: none; background: none; border-bottom: 2px solid transparent; border-radius: 0; padding: 10px 12px; color: var(--muted); }
.tabs button.on { border-bottom-color: var(--accent); color: var(--ink); font-weight: 600; }
.form { display: flex; flex-direction: column; gap: 12px; }
.form .field { display: flex; flex-direction: column; gap: 4px; }
.form input { padding: 9px 10px; }
.form button { padding: 10px; }
@media (max-width: 800px) { .auth-wrap { grid-template-columns: 1fr; } .auth-hero { display: none; } }

/* ------ edytor ------ */
.app { display: grid; grid-template-rows: 48px 1fr; height: 100%; }
.topbar {
  display: flex; align-items: center; gap: 8px; padding: 0 12px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.topbar .brand { font-weight: 700; margin-right: 8px; letter-spacing: -0.01em; }
.topbar .brand span { color: var(--accent); }
.topbar .proj-name { border-color: transparent; font-weight: 600; width: 220px; }
.topbar .proj-name:hover { border-color: var(--line); }
.topbar .spacer { flex: 1; }
.topbar .status { color: var(--muted); font-size: 12px; min-width: 120px; text-align: right; }
.sep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; }

.main { display: grid; grid-template-columns: 260px 1fr 300px; min-height: 0; }
.side { background: var(--panel); border-right: 1px solid var(--line); overflow: auto; min-height: 0; }
.side.right { border-right: none; border-left: 1px solid var(--line); }
.section { padding: 12px; border-bottom: 1px solid var(--line); }
.section h3 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.f { display: flex; flex-direction: column; gap: 3px; }
.f input, .f select { width: 100%; }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.row.stretch > * { flex: 1; }
.check { display: flex; align-items: center; gap: 6px; color: var(--ink); font-size: 13px; }
.orient { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.orient button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px; font-size: 11px; }
.orient svg { width: 34px; height: 28px; }

.viewport { position: relative; min-width: 0; min-height: 0; background: #e9e6e0; }
.viewport canvas { display: block; width: 100%; height: 100%; }
.viewbar { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.viewbar button { background: rgba(255,255,255,.92); }
.hint { position: absolute; bottom: 10px; left: 10px; max-width: calc(100% - 440px); font-size: 12px; color: var(--muted); background: rgba(255,255,255,.85); padding: 6px 10px; border-radius: 6px; }
.coords { position: absolute; bottom: 10px; right: 10px; font-size: 12px; background: rgba(35,33,30,.85); color: #fff; padding: 6px 10px; border-radius: 6px; font-variant-numeric: tabular-nums; display: none; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.list li:hover { background: #f6f3ef; }
.list li.sel { background: var(--accent-soft); }
.list .sw { width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(0,0,0,.15); flex: none; }
.list .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .dm { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); font-size: 13px; padding: 8px; }

table.cut { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
table.cut th, table.cut td { text-align: left; padding: 6px; border-bottom: 1px solid var(--line); }
table.cut th { color: var(--muted); font-weight: 500; }
table.cut td.n { text-align: right; }

/* ------ okna dialogowe ------ */
.modal-bg { position: fixed; inset: 0; background: rgba(30,27,24,.45); display: none; align-items: center; justify-content: center; z-index: 50; }
.modal-bg.open { display: flex; }
.modal { background: var(--panel); border-radius: 12px; padding: 20px; width: min(640px, 92vw); max-height: 86vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal h2 { margin: 0 0 14px; font-size: 18px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.pcard { border: 1px solid var(--line); border-radius: 10px; padding: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.pcard:hover { border-color: var(--accent); }
.pcard .t { font-weight: 600; }
.pcard .m { color: var(--muted); font-size: 12px; }
.pcard .a { display: flex; gap: 6px; margin-top: 4px; }
.pcard .a button { padding: 3px 8px; font-size: 12px; }
.pcard.new { align-items: center; justify-content: center; border-style: dashed; color: var(--accent); font-weight: 600; min-height: 96px; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #2b2723; color: #fff; padding: 9px 16px; border-radius: 8px; font-size: 13px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 60; }
.toast.show { opacity: 1; }
kbd { background: #f1eee9; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; font-size: 11px; font-family: inherit; }
