:root {
  --waynes-blue: #1F3A5F;
  --waynes-deep: #14263F;
  --camel: #B07A45;
  --sand: #E9E1D3;
  --paper: #F7F4EE;
  --ink: #1B1F24;
  --muted: #6B7280;
  --line-soft: #E3DCCF;
  --c-manual: #1F3A5F;
  --c-cinnamon: #2E8B74;
  --c-line: #E08A2E;
  --radius: 12px;
  --panel-w: 440px;
  --top-h: 60px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--paper); color: var(--ink); font-family: Inter, system-ui, -apple-system, sans-serif; font-size: 14px; }
button, input { font: inherit; }

.topbar { height: var(--top-h); display: flex; align-items: center; gap: 24px; padding: 0 20px; background: var(--waynes-deep); color: #fff; }
.brand { display: flex; align-items: baseline; gap: 12px; white-space: nowrap; }
.wordmark { font-family: Fraunces, Georgia, serif; font-weight: 700; font-size: 22px; letter-spacing: 0.08em; }
.brand-sub { font-size: 12px; opacity: 0.75; }
.legend { display: flex; gap: 8px; margin-left: auto; }
.chip { display: inline-flex; align-items: center; gap: 7px; border: 1px solid rgba(255,255,255,0.25); background: transparent; color: #fff; border-radius: 999px; padding: 5px 11px; font-size: 12px; cursor: pointer; opacity: 0.5; }
.chip i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.chip.active { opacity: 1; background: rgba(255,255,255,0.08); }
.stats { display: flex; gap: 16px; font-size: 12px; opacity: 0.9; white-space: nowrap; }
.stats b { font-weight: 600; }

.layout { display: grid; grid-template-columns: 1fr var(--panel-w); height: calc(100% - var(--top-h)); }
.stage { position: relative; background: radial-gradient(ellipse at 50% 40%, #EFE9DE 0%, #DED5C5 100%); overflow: hidden; }
#scene { width: 100%; height: 100%; display: block; touch-action: none; }
.stage-hint { position: absolute; left: 16px; top: 14px; font-size: 12px; color: var(--muted); background: rgba(255,255,255,0.7); padding: 6px 10px; border-radius: 8px; pointer-events: none; }
.zone-tabs { position: absolute; left: 16px; bottom: 16px; display: flex; flex-wrap: wrap; gap: 6px; max-width: calc(100% - 32px); }
.zone-tab { border: 1px solid var(--line-soft); background: rgba(255,255,255,0.85); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: 12px; display: inline-flex; gap: 8px; align-items: center; }
.zone-tab b { font-weight: 700; color: var(--waynes-blue); }
.zone-tab .n { color: var(--muted); }
.zone-tab.active { background: var(--waynes-blue); color: #fff; border-color: var(--waynes-blue); }
.zone-tab.active b, .zone-tab.active .n { color: #fff; }

.panel { display: flex; flex-direction: column; background: #fff; border-left: 1px solid var(--line-soft); min-height: 0; }
.panel-head { padding: 18px 20px 12px; border-bottom: 1px solid var(--line-soft); }
.zone-title { display: flex; align-items: center; gap: 14px; }
.zone-letter { width: 48px; height: 48px; border-radius: 12px; background: var(--waynes-blue); color: #fff; display: grid; place-items: center; font-family: Fraunces, serif; font-size: 22px; font-weight: 700; flex: none; }
.zone-title h2 { margin: 0; font-size: 18px; font-weight: 600; }
.zone-meta { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.zone-desc { margin: 10px 0 0; color: #3F4752; font-size: 13px; line-height: 1.45; }
.toolbar { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.toolbar input { flex: 1; border: 1px solid var(--line-soft); border-radius: 8px; padding: 8px 10px; background: var(--paper); }
.count { color: var(--muted); font-size: 12px; white-space: nowrap; }

.list { overflow-y: auto; padding: 8px 14px 16px; flex: 1; min-height: 0; }
.section { margin: 14px 0 6px; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; display: flex; justify-content: space-between; }
.item { position: relative; border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 10px 12px 10px 16px; margin: 6px 0; background: #fff; cursor: pointer; transition: box-shadow .15s; }
.item:hover { box-shadow: 0 4px 16px rgba(20,38,63,0.08); }
.item::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 4px; border-radius: 4px; background: var(--src); }
.item-row { display: flex; align-items: flex-start; gap: 8px; }
.item-name { font-weight: 600; font-size: 13.5px; flex: 1; }
.item-qty { font-size: 12px; color: var(--muted); white-space: nowrap; }
.item-sub { color: var(--muted); font-size: 12px; margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.badge { display: inline-block; font-size: 10.5px; padding: 2px 7px; border-radius: 999px; background: var(--sand); color: #4B4034; font-weight: 500; }
.badge.elec { background: #FDECD3; color: #8A4B00; }
.badge.proposed { background: #FFF1DE; color: #9A5A12; }
.badge.approved { background: #E3F3EC; color: #1F6B4E; }
.item-spec { display: none; margin-top: 8px; font-size: 12.5px; line-height: 1.45; color: #3F4752; border-top: 1px dashed var(--line-soft); padding-top: 8px; }
.item.open .item-spec { display: block; }
.item-spec .kv { display: grid; grid-template-columns: 90px 1fr; gap: 2px 8px; margin-top: 6px; }
.item-spec .kv span:nth-child(odd) { color: var(--muted); }
.empty { color: var(--muted); padding: 30px 10px; text-align: center; }
.panel-foot { padding: 10px 20px; border-top: 1px solid var(--line-soft); font-size: 11.5px; color: var(--muted); line-height: 1.4; }

@media (max-width: 900px) {
  :root { --panel-w: 100%; }
  .topbar { height: auto; flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .legend { margin-left: 0; flex-wrap: wrap; }
  .stats, .brand-sub, .stage-hint { display: none; }
  .layout { grid-template-columns: 1fr; grid-template-rows: 48vh 1fr; height: auto; min-height: calc(100% - 90px); }
  .zone-tabs { display: none; }
}

/* ---- phase 2: auth, forms, history, users ---- */
:root { --c-team: #2271B3; }
.user { display: flex; align-items: center; gap: 8px; margin-left: 8px; position: relative; }
.user-name { font-size: 12px; opacity: 0.9; white-space: nowrap; }
.user-name small { opacity: 0.6; margin-left: 4px; }
.user .btn { padding: 5px 10px; font-size: 12px; }
.btn { border: 1px solid var(--line-soft); background: #fff; color: var(--ink); border-radius: 8px; padding: 7px 12px; cursor: pointer; font-size: 13px; font-weight: 500; }
.btn:hover { background: var(--paper); }
.btn.primary { background: var(--waynes-blue); border-color: var(--waynes-blue); color: #fff; }
.btn.primary:hover { background: #2A4C7A; }
.btn.danger { color: #9B2C2C; border-color: #E8C9C9; }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn.wide { width: 100%; }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,0.3); color: #fff; }
.btn.ghost:hover { background: rgba(255,255,255,0.1); }
.btn[disabled] { opacity: 0.5; cursor: default; }
.menu { position: absolute; right: 0; top: 40px; background: #fff; color: var(--ink); border: 1px solid var(--line-soft); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,0.15); min-width: 200px; padding: 6px; z-index: 20; }
.menu button, .menu a { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--ink); text-decoration: none; }
.menu button:hover, .menu a:hover { background: var(--paper); }
.menu hr { border: 0; border-top: 1px solid var(--line-soft); margin: 4px 0; }

.zone-title-text { flex: 1; min-width: 0; }
.view-tabs { display: flex; gap: 4px; margin-top: 12px; border-bottom: 1px solid var(--line-soft); margin-bottom: -12px; }
.view-tab { border: 0; background: none; padding: 8px 10px; cursor: pointer; font-size: 13px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.view-tab.active { color: var(--waynes-blue); border-bottom-color: var(--waynes-blue); font-weight: 600; }
.check { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); white-space: nowrap; cursor: pointer; }

.item.removed { opacity: 0.6; }
.item.removed .item-name { text-decoration: line-through; }
.item-actions { display: flex; gap: 6px; margin-top: 10px; }
.badge.removed { background: #F3E5E5; color: #8E3B3B; }

.overlay { position: fixed; inset: 0; background: rgba(20,38,63,0.55); display: grid; place-items: center; z-index: 50; padding: 16px; overflow-y: auto; }
.overlay[hidden] { display: none; }
.card { background: #fff; border-radius: 16px; padding: 24px; width: 100%; max-width: 440px; box-shadow: 0 20px 60px rgba(0,0,0,0.25); }
.card h1 { font-size: 20px; margin: 6px 0 2px; }
.card h2 { font-size: 17px; margin: 0 0 4px; }
.card .muted { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.card label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 0; font-weight: 500; }
.card input, .card select, .card textarea { display: block; width: 100%; margin-top: 4px; border: 1px solid var(--line-soft); border-radius: 8px; padding: 8px 10px; background: #fff; color: var(--ink); font-size: 14px; }
.card textarea { resize: vertical; }
.card input:focus, .card select:focus, .card textarea:focus { outline: 2px solid rgba(31,58,95,0.3); border-color: var(--waynes-blue); }
.auth-card { text-align: center; max-width: 380px; }
.auth-card label { text-align: left; }
.auth-card .btn { margin-top: 16px; }
.wordmark.dark { color: var(--waynes-blue); }
.form-error { color: #9B2C2C; font-size: 12.5px; min-height: 16px; margin: 8px 0 0; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.item-form { max-width: 620px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 12px; }
@media (max-width: 600px) { .grid3 { grid-template-columns: 1fr; } }

.change { border-left: 3px solid var(--line-soft); padding: 8px 12px; margin: 8px 0; font-size: 12.5px; }
.change.create { border-color: var(--c-cinnamon); } .change.update { border-color: var(--c-team); } .change.remove { border-color: #B23A3A; } .change.restore { border-color: var(--c-line); }
.change-head { display: flex; justify-content: space-between; gap: 8px; }
.change-head b { font-weight: 600; }
.change-head time { color: var(--muted); white-space: nowrap; }
.change-who { color: var(--muted); }
.diff { margin-top: 4px; color: #3F4752; }
.diff .k { color: var(--muted); }
.diff del { color: #9B2C2C; text-decoration: line-through; opacity: 0.8; }
.diff ins { color: #1F6B4E; text-decoration: none; }

.user-row { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line-soft); border-radius: 10px; padding: 10px 12px; margin: 6px 0; font-size: 13px; }
.user-row .u-main { flex: 1; min-width: 0; }
.user-row .u-main small { display: block; color: var(--muted); }
.user-row.inactive { opacity: 0.55; }
.temp-pw { background: #FFF6E5; border: 1px dashed #E0B060; border-radius: 10px; padding: 10px 12px; margin: 8px 0; font-size: 13px; }
.temp-pw code { font-size: 15px; font-weight: 700; letter-spacing: 0.04em; user-select: all; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; z-index: 60; box-shadow: 0 8px 24px rgba(0,0,0,0.25); }
.toast.error { background: #8E2B2B; }

@media (max-width: 900px) {
  .user { margin-left: auto; }
  .legend { order: 3; width: 100%; }
}
@media (max-width: 1280px) { .stats { display: none; } }
@media (max-width: 1100px) { .brand-sub { display: none; } .chip { padding: 5px 9px; font-size: 11px; } }

/* ---- pricing ---- */
.cost-line { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 12.5px; color: #3F4752; }
.cost-line b { font-weight: 600; color: var(--ink); }
.cost-line .muted { color: var(--muted); }
.price { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; white-space: nowrap; }
.price b { font-weight: 600; }
.price .unpriced { color: var(--muted); font-style: italic; }
.price-edit { display: flex; align-items: center; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.price-edit input { width: 110px; border: 1px solid var(--line-soft); border-radius: 6px; padding: 5px 8px; font-size: 13px; }
.price-edit select { border: 1px solid var(--line-soft); border-radius: 6px; padding: 5px 6px; font-size: 13px; background: #fff; }
.price-edit .total { color: var(--muted); font-size: 12px; margin-left: auto; }
.item-row .price { margin-left: 8px; }

/* ---- phase 3: sizes, container plan, suppliers ---- */
.size-switch { display: inline-flex; border: 1px solid rgba(255,255,255,0.3); border-radius: 999px; overflow: hidden; }
.size-switch button { border: 0; background: transparent; color: #fff; padding: 5px 12px; font-size: 12px; font-weight: 600; cursor: pointer; opacity: 0.6; }
.size-switch button.active { background: #fff; color: var(--waynes-deep); opacity: 1; }
.badge.src-turkey { background: #FDECD3; color: #8A4B00; } .badge.src-local { background: #E8EEF5; color: #2F4A6B; } .badge.src-brand { background: #ECE6F7; color: #4E3A82; }
.badge.rep { background: #EEF3EE; color: #2F5A3C; }
.item-qty .size { color: #9AA1AB; font-size: 10.5px; margin-left: 2px; }
.item-qty.missing { color: #B05C00; font-style: italic; }
.plan { padding: 4px 2px 12px; font-size: 13px; }
.plan h3 { font-size: 13px; margin: 18px 0 8px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.plan .kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.kpi { border: 1px solid var(--line-soft); border-radius: 10px; padding: 10px 12px; }
.kpi b { display: block; font-size: 18px; font-weight: 700; color: var(--waynes-blue); }
.kpi span { color: var(--muted); font-size: 11.5px; }
.ctn { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.ctn .box { border: 2px solid var(--waynes-blue); border-radius: 6px; width: 120px; height: 44px; position: relative; overflow: hidden; background: #fff; }
.ctn .box.small { width: 64px; }
.ctn .box i { position: absolute; left: 0; bottom: 0; top: 0; background: var(--camel); opacity: 0.85; }
.ctn .box span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; font-weight: 600; color: var(--ink); }
.bar-row { display: grid; grid-template-columns: 120px 1fr 110px; gap: 8px; align-items: center; margin: 5px 0; font-size: 12.5px; }
.bar-row .bar { height: 10px; background: var(--paper); border-radius: 5px; overflow: hidden; }
.bar-row .bar i { display: block; height: 100%; background: var(--waynes-blue); border-radius: 5px; }
.bar-row .v { text-align: right; color: var(--muted); white-space: nowrap; }
.plan .note { color: var(--muted); font-size: 12px; margin-top: 6px; }
.plan ol { padding-left: 18px; margin: 4px 0; } .plan li { margin: 3px 0; }
.sup { border: 1px solid var(--line-soft); border-radius: 12px; padding: 12px 14px; margin: 8px 0; font-size: 13px; }
.sup h4 { margin: 0 0 6px; font-size: 13.5px; display: flex; justify-content: space-between; gap: 8px; }
.sup ul { margin: 4px 0; padding-left: 18px; } .sup li { margin: 2px 0; }
.sup .req { color: #3F4752; font-size: 12.5px; margin-top: 6px; }
.sup .zones { color: var(--muted); font-size: 11.5px; }
@media (max-width: 900px) { .size-switch { order: 2; } }
