/* ─── MAIN.CSS ─────────────────────────────────────────────────────
   Base: smeta warm beige palette (index_81_.html)
   Planner UI panels adapted to use same variables
   Planner font: Onest (replaces Inter)
──────────────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Onest:wght@300;400;500;600&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Merriweather:wght@300;400;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ── Palette ── */
  --bg:       #F0F0EE;
  --card:     #F5F5F3;
  --white:    #FFFFFF;
  --ink:      #1A1A1A;
  --muted:    #888884;
  --muted2:   #AAAAAA;
  --line:     rgba(0,0,0,0.07);
  --line2:    rgba(0,0,0,0.11);
  --radius:   14px;
  --radius-sm:10px;
  --sidebar:  380px;
  /* ── Planner ── */
  --panel-border: rgba(0,0,0,0.09);
  --tool-active:  var(--ink);
  --accent-hover: #2d2d2d;
  --input-border: rgba(0,0,0,0.13);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.10), 0 2px 4px rgba(0,0,0,0.05);
  --shadow-float: 0 2px 12px rgba(0,0,0,0.10), 0 1px 4px rgba(0,0,0,0.06);
}

html, body {
  height: 100%;
  font-family: 'Onest', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-size: 13px;
  line-height: 1.4;
  user-select: none;
}

/* ═══════════════════════════════════════════════════════════════
   APP SHELL & TABS
═══════════════════════════════════════════════════════════════ */

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Global top bar ── */
.global-topbar {
  height: 48px;
  background: var(--white);
  border-bottom: 1px solid var(--line2);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 8px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  z-index: 20;
}

.app-logo {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.3px;
  margin-right: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.app-logo-icon {
  width: 22px; height: 22px;
  background: var(--ink);
  border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  color: var(--white); font-size: 11px; font-weight: 700;
}

.tab-sep { width: 1px; height: 20px; background: var(--line2); margin: 0 2px; flex-shrink: 0; }

.tab-btn {
  height: 32px;
  padding: 0 14px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  font-family: 'Onest', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}
.tab-btn:hover { background: var(--card); color: var(--ink); }
.tab-btn.active { background: var(--ink); color: var(--white); border-color: var(--ink); }

.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.tb-action-btn {
  height: 30px; padding: 0 12px;
  background: var(--card); border: 1px solid var(--line2); border-radius: 7px;
  font-family: 'Onest', sans-serif; font-size: 11px; font-weight: 500; color: var(--muted);
  cursor: pointer; transition: all 0.12s; display: flex; align-items: center; gap: 5px;
  white-space: nowrap;
}
.tb-action-btn:hover { background: var(--white); color: var(--ink); }
.tb-action-btn.primary { background: var(--ink); color: var(--white); border-color: transparent; }
.tb-action-btn.primary:hover { opacity: 0.85; }

/* ── View containers ── */
.app-views { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
#plannerView { display: none; height: 100%; flex-direction: column; overflow: hidden; }
#smetaView   { display: block; height: 100%; overflow: hidden; }

/* ═══════════════════════════════════════════════════════════════
   PLANNER LAYOUT
═══════════════════════════════════════════════════════════════ */

.planner-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - 92px);
  position: relative;
}

/* ── Planner topbar ── */
.planner-topbar {
  height: 44px;
  background: var(--white);
  border-bottom: 1px solid var(--line2);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 6px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  z-index: 10;
}

.snap-badge {
  margin-left: auto;
  font-size: 11px; color: var(--muted);
  background: var(--card); border: 1px solid var(--line2);
  border-radius: 20px; padding: 3px 10px; font-weight: 500; flex-shrink: 0;
}

.tb-btn {
  height: 30px; padding: 0 10px;
  background: var(--card); border: 1px solid var(--line2); border-radius: 6px;
  font-family: 'Onest', sans-serif; font-size: 12px; font-weight: 500; color: var(--ink);
  cursor: pointer; display: flex; align-items: center; gap: 5px;
  transition: background 0.12s; white-space: nowrap; flex-shrink: 0;
}
.tb-btn:hover { background: #dedad4; }
.tb-btn:disabled { opacity: 0.45; cursor: default; }
.tb-btn.icon-btn { width: 30px; justify-content: center; padding: 0; }

/* ── Canvas ── */
.canvas-wrap {
  flex: 1; position: relative; overflow: hidden;
  background: #ffffff; width: 100%;
}
#planCanvas { display: block; cursor: crosshair; background: #fff; }

#lengthOverlay { display: none; position: absolute; left: 0; top: 0; pointer-events: none; z-index: 20; }
#lengthLabel {
  position: absolute; background: var(--ink); color: var(--white);
  font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 6px;
  white-space: nowrap; box-shadow: 0 2px 8px rgba(0,0,0,0.28);
  transform: translate(-50%, -130%); pointer-events: none;
}

.statusbar {
  position: absolute; bottom: 0; left: 0; right: 0; height: 26px;
  background: rgba(247,244,239,0.92); backdrop-filter: blur(4px);
  border-top: 1px solid var(--line); display: flex; align-items: center;
  padding: 0 14px; gap: 20px; font-size: 11px; color: var(--muted); z-index: 5;
}
.statusbar span b { color: var(--ink); font-weight: 600; }

/* ── Right panel — floating cards ── */
.right-panel {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 360px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  z-index: 30;
  pointer-events: none;
}
.right-panel > * { pointer-events: all; }

/* Floating card base */
.fp-card {
  background: #FFFFFF;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.09);
  padding: 10px;
  box-shadow: var(--shadow-float);
}

.rp-scroll { display: contents; }
.rp-section { display: none; }
.rp-section-title {
  font-size: 9px; font-weight: 600; color: #999999; text-transform: uppercase;
  letter-spacing: 0.07em; margin-bottom: 8px;
}

/* Tool grid */
.tool-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 3px; }
.tool-btn {
  background: #F5F5F3; border: 1px solid rgba(0,0,0,0.09); border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  padding: 7px 4px; cursor: pointer; transition: all 0.12s;
  color: #444444; font-size: 11px; font-weight: 500; font-family: inherit;
  line-height: 1;
}
.tool-btn svg { display: none; }
.tool-btn:hover { background: #ECECEA; color: #111111; }
.tool-btn.active { background: #EEF3FF; border-color: #4A6FE3; color: #2952CC; font-weight: 600; }

/* Params */
.param-group { margin-bottom: 7px; }
.param-label { font-size: 10px; color: #666666; font-weight: 400; margin-bottom: 3px; display: flex; justify-content: space-between; align-items: center; }
.param-unit { color: #AAAAAA; font-size: 10px; }
.param-input-wrap {
  display: flex; align-items: center; border: 1px solid rgba(0,0,0,0.12);
  border-radius: 5px; background: #F8F8F6; overflow: hidden; transition: border-color 0.12s;
}
.param-input-wrap:focus-within { border-color: #555555; background: #FFFFFF; }
.param-input { flex: 1; border: none; background: transparent; font-family: inherit; font-size: 12px; color: #111111; padding: 5px 7px; outline: none; font-weight: 400; user-select: text; min-width: 0; }
.param-input-unit { font-size: 10px; color: #AAAAAA; padding: 0 7px 0 0; white-space: nowrap; }

.hint-box {
  background: #F5F5F3; border-radius: 5px;
  padding: 6px 8px; font-size: 10px; color: #888888; line-height: 1.5; margin-top: 5px;
}
.hint-box b { color: #333333; font-weight: 600; }

.tool-panel { display: none; }
.tool-panel.active { display: block; }

.section-note { font-size: 10.5px; color: var(--muted2); margin: -4px 0 10px; line-height: 1.45; }

/* Explication */
.expl-panel {
  background: #FFFFFF;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.09);
  padding: 10px;
  box-shadow: var(--shadow-float);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.expl-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px; }
.expl-title { font-size: 9px; font-weight: 600; color: #999999; text-transform: uppercase; letter-spacing: 0.07em; }
.expl-count { font-size: 10px; background: #EBEBEB; color: #555555; border-radius: 10px; padding: 1px 7px; font-weight: 600; }
.expl-scroll { flex: 1; overflow-y: auto; overflow-x: auto; max-height: 220px; }
.expl-scroll::-webkit-scrollbar { width: 3px; height: 3px; }
.expl-scroll::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 4px; }
.expl-table { width: 100%; border-collapse: collapse; font-size: 10px; min-width: 400px; }
.expl-table thead th {
  font-weight: 500; font-size: 9px; text-transform: uppercase; letter-spacing: 0.3px;
  padding: 4px 5px; border-bottom: 2px solid rgba(0,0,0,0.10);
  position: sticky; top: 0; z-index: 1; text-align: right; white-space: nowrap; cursor: default;
}
.expl-th-name { text-align: left !important; min-width: 75px; background: #F5F5F3; color: #999; }
.expl-th-main { background: #EEECEA; color: #444; border-left: 1px solid rgba(0,0,0,0.07); }
.expl-th-ref  { background: #F5F5F3; color: #AAAAAA; border-left: 1px solid rgba(0,0,0,0.05); font-style: italic; }
.expl-table tbody td {
  padding: 4px 5px; border-bottom: 1px solid rgba(0,0,0,0.05);
  color: #111; text-align: right; white-space: nowrap;
}
.expl-table tbody td:first-child { text-align: left; }
.expl-table tbody tr:hover td { background: #F8F8F6; }
.expl-table tbody tr:hover td { background: #F8F8F6; }
.expl-table .empty-row td { color: #AAAAAA; font-style: italic; text-align: center; padding: 10px; font-size: 10px; }
.room-dot { display: inline-block; width: 7px; height: 7px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }
.room-name-cell { display: flex; align-items: center; gap: 4px; min-width: 0; }
.room-name-input { width: 100%; min-width: 0; border: none; background: transparent; font: inherit; color: inherit; padding: 1px 3px; border-radius: 3px; outline: none; user-select: text; }
.room-name-input:focus { background: #FFFFFF; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12); }

/* Edit panel */
#editPanel { display: none; }
.edit-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.edit-row label { flex: 1; font-size: 11px; color: var(--muted); font-weight: 500; }
.edit-note { margin-top: 8px; font-size: 10.5px; color: var(--muted2); line-height: 1.45; }

.delete-btn {
  width: 100%; padding: 8px; background: #fff5f5; border: 1.5px solid #fecaca;
  border-radius: 7px; color: #dc2626; font-size: 12px; font-weight: 600; cursor: pointer; transition: all 0.12s; margin-top: 4px; font-family: inherit;
}
.delete-btn:hover { background: #fee2e2; border-color: #f87171; }

/* Offset buttons */
.offset-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 5px 3px 4px; background: #F5F5F3; border: 1px solid rgba(0,0,0,0.10);
  border-radius: 6px; cursor: pointer; font-size: 9px; font-weight: 500; color: #666666;
  transition: all 0.12s; font-family: inherit;
}
.offset-btn svg { width: 22px; height: 18px; }
.offset-btn:hover { background: #ECECEA; color: #111111; }
.offset-btn.active { background: #F0F0EE; border-color: #888888; color: #111111; font-weight: 600; }

/* Choice buttons */
.choice-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; margin-top: 3px; }
.choice-btn {
  padding: 5px 6px; border: 1px solid rgba(0,0,0,0.10); background: #F5F5F3;
  border-radius: 6px; font-size: 10px; font-weight: 500; color: #666666;
  cursor: pointer; transition: all 0.12s; font-family: inherit;
}
.choice-btn:hover { background: #ECECEA; color: #111111; }
.choice-btn.active { background: #F0F0EE; border-color: #888888; color: #111111; font-weight: 600; }
.choice-btn.compact { padding: 5px 4px; font-size: 10px; }

/* Zoom */
.zoom-controls { position: absolute; bottom: 36px; right: 14px; display: flex; flex-direction: column; gap: 4px; z-index: 10; }
.zoom-btn {
  width: 30px; height: 30px; background: var(--white); border: 1.5px solid var(--line2); border-radius: 7px;
  font-size: 16px; display: flex; align-items: center; justify-content: center; cursor: pointer;
  color: var(--muted); box-shadow: var(--shadow-sm); transition: all 0.12s; font-family: inherit;
}
.zoom-btn:hover { background: var(--card); color: var(--ink); }

/* Import rooms button */
.import-rooms-btn {
  width: 100%; padding: 7px 10px; margin-top: 0;
  background: #1A1A1A; border: none; border-radius: 7px;
  font-family: 'Onest', sans-serif; font-size: 11px; font-weight: 500; color: #FFFFFF;
  cursor: pointer; transition: background 0.12s; text-align: center;
}
.import-rooms-btn:hover { background: #333333; }

/* ═══════════════════════════════════════════════════════════════
   SMETA VIEW
═══════════════════════════════════════════════════════════════ */

.smeta-shell { height: 100%; display: flex; flex-direction: row; overflow: hidden; }

.sidebar {
  width: clamp(300px, 33.333vw, 520px);
  min-width: 300px;
  flex-shrink: 0;
  background: var(--white);
  border-right: 1px solid var(--line2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
}
.sidebar-head {
  padding: 20px 28px 14px; border-bottom: 1px solid var(--line);
  flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
}
.sidebar-head-left h1 { font-size: 19px; font-weight: 400; letter-spacing: -0.3px; line-height: 1.2; margin-bottom: 3px; }
.sidebar-head-left p { font-size: 12px; color: var(--muted); font-weight: 300; }
.sidebar-head-actions { display: flex; gap: 10px; align-items: center; }
.sidebar-scroll { flex: 1; overflow-y: auto; padding: 18px 28px 40px; }
.sidebar-scroll::-webkit-scrollbar { width: 4px; }
.sidebar-scroll::-webkit-scrollbar-track { background: transparent; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 2px; }

/* Form elements */
.sec-label {
  font-size: 10px; font-weight: 500; letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--muted); margin: 18px 0 8px; padding: 0 2px;
}
.sec-label:first-child { margin-top: 0; }
.card { background: var(--white); border-radius: var(--radius); padding: 16px; margin-bottom: 8px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
.field label { font-size: 11px; color: var(--muted); font-weight: 400; }
.field input, .field textarea {
  background: transparent; border: none; border-bottom: 1px solid var(--line2);
  padding: 7px 0; font-family: 'Onest', sans-serif; font-size: 14px; color: var(--ink);
  outline: none; width: 100%; transition: border-color 0.2s;
}
.field input:focus, .field textarea:focus { border-bottom-color: var(--ink); }
.field input::placeholder, .field textarea::placeholder { color: var(--muted2); }
.field textarea { resize: none; min-height: 40px; }
.field-row  { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

/* Logo upload */
.logo-upload {
  background: var(--card); border-radius: var(--radius-sm); padding: 16px;
  text-align: center; cursor: pointer; position: relative; transition: background 0.2s;
  min-height: 64px; display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 6px; margin-bottom: 12px;
}
.logo-upload:hover { background: #dedad4; }
.logo-upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.logo-upload .up-icon { font-size: 18px; color: var(--muted); }
.logo-upload .up-text { font-size: 12px; color: var(--muted); font-weight: 300; }
.logo-upload .up-text strong { color: var(--ink); font-weight: 500; }
#logoPreview { max-height: 44px; max-width: 140px; display: none; border-radius: 6px; }

/* Plan upload */
.plan-upload {
  background: var(--card); border-radius: var(--radius-sm); min-height: 100px; cursor: pointer;
  position: relative; display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 6px; overflow: hidden; margin-bottom: 8px;
  transition: background 0.2s; padding: 16px;
}
.plan-upload:hover { background: #dedad4; }
.plan-upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.plan-upload .up-icon { font-size: 26px; color: var(--muted2); }
.plan-upload .up-text { font-size: 12px; color: var(--muted); text-align: center; }
#planPreview { max-width: 100%; max-height: 160px; display: none; border-radius: 8px; }

/* Rooms */
.room-item { background: var(--card); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 6px; }
.room-item-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.room-name-inp { background: transparent; border: none; font-family: 'Onest', sans-serif; font-size: 15px; font-weight: 500; color: var(--ink); outline: none; width: 100%; user-select: text; }
.room-name-inp::placeholder { color: var(--muted2); }
.btn-del-room { background: none; border: none; color: var(--muted2); font-size: 18px; cursor: pointer; padding: 0 0 0 8px; line-height: 1; transition: color 0.15s; flex-shrink: 0; }
.btn-del-room:hover { color: #c0392b; }
.room-fields { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.room-field { display: flex; flex-direction: column; gap: 3px; }
.room-field label { font-size: 10px; color: var(--muted); letter-spacing: .5px; text-transform: uppercase; }
.room-field input { background: transparent; border: none; border-bottom: 1px solid var(--line2); padding: 4px 0; font-family: 'Onest', sans-serif; font-size: 13px; color: var(--ink); outline: none; width: 100%; user-select: text; }
.room-field input:focus { border-bottom-color: var(--ink); }

.totals-strip { display: grid; grid-template-columns: 1fr 1fr 1fr; background: var(--white); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 8px; }
.totals-item .tv { font-size: 20px; font-weight: 500; letter-spacing: -.5px; }
.totals-item .tl { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-top: 2px; }

.btn-add-room {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: none; border-radius: var(--radius-sm);
  padding: 11px 14px; width: 100%;
  font-family: 'Onest', sans-serif; font-size: 13px; color: var(--muted);
  cursor: pointer; transition: background 0.2s; margin-bottom: 8px;
}
.btn-add-room:hover { background: #dedad4; color: var(--ink); }

/* Smeta upload */
.smeta-upload {
  background: var(--card); border-radius: var(--radius-sm); padding: 16px;
  text-align: center; cursor: pointer; position: relative; transition: background 0.2s; margin-bottom: 8px;
}
.smeta-upload:hover { background: #dedad4; }
.smeta-upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.smeta-upload.has-data { background: #e6efe6; }
.smeta-upload .up-icon { font-size: 20px; color: var(--muted); margin-bottom: 4px; }
.smeta-upload .up-text { font-size: 12px; color: var(--muted); }
.smeta-upload .up-text strong { color: var(--ink); font-weight: 500; }
.smeta-ok { font-size: 11px; color: #27ae60; font-weight: 500; margin-top: 4px; }

/* Work rows */
.work-table-wrap { margin-top: 8px; }
.work-header-row {
  display: grid; grid-template-columns: 22px 1fr 44px 50px 70px 20px;
  gap: 0; padding: 6px 10px; background: var(--card); border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.work-header-row span { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 500; }
.work-rows-body { background: var(--white); border-radius: 0 0 var(--radius-sm) var(--radius-sm); overflow: hidden; }
.work-row-item {
  display: grid; grid-template-columns: 22px 1fr 44px 50px 70px 20px;
  gap: 0; padding: 2px 10px; align-items: center; border-bottom: 1px solid var(--line); min-height: 36px;
}
.work-row-item:last-child { border-bottom: none; }
.work-row-item .wn { font-size: 11px; color: var(--muted2); text-align: center; }
.work-row-item input { background: transparent; border: none; font-family: 'Onest', sans-serif; font-size: 12px; color: var(--ink); outline: none; width: 100%; padding: 3px 4px; user-select: text; }
.work-row-item input:focus { background: rgba(0,0,0,0.03); border-radius: 4px; }
.work-footer-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; background: var(--card);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm); margin-top: 1px;
}
.work-footer-row .wfl { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.work-footer-row .wfv { font-size: 16px; font-weight: 500; }
.btn-add-row { background: none; border: none; font-family: 'Onest', sans-serif; font-size: 12px; color: var(--muted); cursor: pointer; padding: 8px 0; transition: color 0.2s; }
.btn-add-row:hover { color: var(--ink); }
.btn-del-row { background: none; border: none; color: var(--muted2); font-size: 15px; cursor: pointer; padding: 0; line-height: 1; }
.btn-del-row:hover { color: #c0392b; }
.btn-manual { background: none; border: none; font-family: 'Onest', sans-serif; font-size: 12px; color: var(--muted); cursor: pointer; padding: 8px 0 2px; transition: color 0.2s; display: block; }
.btn-manual:hover { color: var(--ink); }

/* Summary card */
.summary-card { background: var(--ink); border-radius: var(--radius); padding: 18px 16px; margin-top: 16px; color: #fff; }
.summary-card .sc-lbl { font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: rgba(255,255,255,.4); margin-bottom: 4px; }
.summary-card .sc-total { font-size: 32px; font-weight: 300; letter-spacing: -1px; line-height: 1; margin-bottom: 12px; }
.summary-card .sc-row { display: flex; justify-content: space-between; padding: 8px 0; border-top: 1px solid rgba(255,255,255,.1); }
.summary-card .sc-name { font-size: 12px; color: rgba(255,255,255,.55); }
.summary-card .sc-val  { font-size: 12px; color: #fff; font-weight: 500; }

/* Smeta action buttons */
.btn-generate {
  background: var(--ink); color: #fff; border: none; border-radius: 8px;
  padding: 9px 22px; font-family: 'Onest', sans-serif; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: opacity .2s;
}
.btn-generate:hover { opacity: .85; }
.btn-preview {
  background: var(--white); color: var(--ink); border: 1px solid var(--line2); border-radius: 8px;
  padding: 9px 18px; font-family: 'Onest', sans-serif; font-size: 13px; font-weight: 400;
  cursor: pointer; transition: background .2s;
}
.btn-preview:hover { background: var(--card); }

/* ═══════════════════════════════════════════════════════════════
/* Preview pages — used in print-doc for PDF generation */
.preview-page {
  width: 794px; min-height: 560px; background: #fff;
  box-shadow: 0 4px 24px rgba(0,0,0,0.25); position: relative; flex-shrink: 0;
  font-family: 'Merriweather', serif;
}
/* In modal/standalone context — scale down; inside .spp-a4 this is overridden */
.preview-page:not(.spp-a4) {
  transform-origin: top center; transform: scale(0.85); margin-bottom: -60px;
}
.preview-page.cover-pg { display: flex; flex-direction: column; align-items: center; justify-content: center; }

/* ═══════════════════════════════════════════════════════════════
   PDF / PRINT
═══════════════════════════════════════════════════════════════ */

@font-face {
  font-family: 'Merriweather';
  src: url('https://raw.githubusercontent.com/MishkinIN/Font_GOST_2.304/master/gost_2.304.ttf') format('truetype');
  font-weight: normal; font-style: normal;
}
@media print {
  @page { size: A4 landscape; margin: 0; }
  .app-shell { display: none !important; }
  .modal-overlay { display: none !important; }
  .print-doc { display: block !important; }
  body { background: #fff; }
}
.print-doc { display: none; }
.a4 { width: 297mm; min-height: 210mm; background: #fff; page-break-after: always; position: relative; font-family: 'Merriweather', serif; color: #1c1c1c; }
.a4:last-child { page-break-after: auto; }
.cov { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 210mm; background: #fff; }
.cov-circle { width: 80px; height: 80px; border: 2px solid #1c1c1c; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 28px; font-weight: 400; font-family: 'Merriweather', serif; }
#covLogoImg { max-height: 90px; max-width: 220px; display: none; }
.cov-name { font-size: 26px; font-weight: 400; letter-spacing: 6px; text-transform: uppercase; margin-top: 14px; font-family: 'Merriweather', serif; }
.cov-slogan { font-size: 9px; letter-spacing: 5px; color: #888; text-transform: uppercase; margin-top: 5px; font-family: 'Merriweather', serif; }
.cov-dtype { font-size: 13px; font-weight: 300; color: #444; margin-top: 55px; letter-spacing: 1px; font-family: 'Merriweather', serif; }
.cov-foot { position: absolute; bottom: 18mm; right: 18mm; display: flex; align-items: center; gap: 8px; }
.cov-foot .cfc { width: 24px; height: 24px; border: 1.5px solid #aaa; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 8px; font-weight: 500; color: #aaa; font-family: 'Merriweather', serif; }
.cov-foot .cfn { font-size: 8px; font-weight: 400; letter-spacing: 2px; color: #aaa; font-family: 'Merriweather', serif; }
.pg { padding: 14mm 20mm 16mm; min-height: 210mm; display: flex; flex-direction: column; }
.pg-title { font-size: 20px; font-weight: 400; text-align: center; margin-bottom: 8mm; letter-spacing: 1px; font-family: 'Merriweather', serif; }
.pg-foot { margin-top: auto; padding-top: 5mm; display: flex; justify-content: flex-end; align-items: center; gap: 7px; }
.pg-foot .pfc { width: 22px; height: 22px; border: 1.5px solid #bbb; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 7px; font-weight: 500; color: #bbb; font-family: 'Merriweather', serif; }
.pg-foot .pfn { font-size: 8px; font-weight: 400; letter-spacing: 2px; color: #bbb; font-family: 'Merriweather', serif; }
.plan-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10mm; flex: 1; }
.plan-img-box { border: 1px solid #ddd; display: flex; align-items: center; justify-content: center; background: #fafafa; min-height: 110mm; overflow: hidden; }
.plan-img-box img { max-width: 100%; max-height: 135mm; object-fit: contain; }
.plan-img-ph { text-align: center; color: #ccc; font-size: 28px; }
.obj-info { font-size: 10.5px; line-height: 2.1; color: #222; margin-bottom: 5mm; font-family: 'Merriweather', serif; }
.obj-info strong { font-weight: 500; }
.obj-note { font-size: 9.5px; color: #444; line-height: 2; margin-bottom: 5mm; font-family: 'Merriweather', serif; }
.exp-ttl { font-size: 11px; font-weight: 500; text-align: center; margin: 4mm 0 3mm; font-family: 'Merriweather', serif; letter-spacing: .5px; }
.exp-t { width: 100%; border-collapse: collapse; font-size: 9.5px; font-family: 'Merriweather', serif; }
.exp-t th { border: 1px solid #bbb; padding: 6px 8px; text-align: center; font-weight: 500; font-size: 9px; background: #f0f0ee; }
.exp-t td { border: 1px solid #ddd; padding: 5px 8px; text-align: center; }
.exp-t td:first-child { text-align: left; }
.exp-t tfoot td { font-weight: 600; background: #f0f0ee; border: 1px solid #bbb; padding: 6px 8px; text-align: center; }
.exp-t tfoot td:first-child { text-align: right; }
.smeta-ttl { font-size: 18px; font-weight: 400; text-align: center; margin-bottom: 7mm; letter-spacing: 1px; font-family: 'Merriweather', serif; }
.sm-t { width: 100%; border-collapse: collapse; font-size: 9px; font-family: 'Merriweather', serif; }
.sm-t th { border: 1px solid #bbb; padding: 6px 5px; text-align: center; font-weight: 500; font-size: 8.5px; background: #f0f0ee; line-height: 1.4; }
.sm-t td { border: 1px solid #ddd; padding: 5px 5px; vertical-align: top; line-height: 1.5; }
.sm-t td:first-child { text-align: center; width: 26px; }
.sm-t td:nth-child(3) { text-align: center; }
.sm-t td:nth-child(4) { text-align: center; }
.sm-t td:nth-child(5) { text-align: right; }
.sm-t td:nth-child(6) { text-align: right; font-weight: 500; }
.sm-t .tot-r td { font-weight: 600; font-size: 10px; background: #f0f0ee; }
.fin-t { width: 100%; border-collapse: collapse; font-size: 10px; margin-top: 3mm; font-family: 'Merriweather', serif; }
.fin-t th { border: 1px solid #bbb; padding: 7px 10px; background: #f0f0ee; font-weight: 500; font-size: 9px; text-align: center; }
.fin-t td { border: 1px solid #ddd; padding: 8px 10px; }
.fin-t td:first-child { text-align: center; width: 28px; }
.fin-t td:nth-child(5) { text-align: right; }
.fin-t td:nth-child(6) { text-align: right; font-weight: 600; }
.fin-total { display: flex; justify-content: flex-end; gap: 14px; align-items: baseline; margin-top: 6mm; }
.fin-total span { font-size: 11px; color: #555; font-family: 'Merriweather', serif; }
.fin-total strong { font-size: 18px; font-weight: 500; font-family: 'Merriweather', serif; }

/* ═══════════════════════════════════════════════════════════════
   DESKTOP SMETA LAYOUT (right preview panel)
═══════════════════════════════════════════════════════════════ */

/* Topbar pill switcher */
.topbar-pill-wrap {
  position: absolute; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center;
}
.topbar-pill {
  position: relative; display: flex;
  background: var(--card); border: 1px solid var(--line2);
  border-radius: 10px; padding: 3px; gap: 0;
}
.pill-btn {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 6px;
  padding: 6px 18px; border: none; background: transparent;
  font: 500 12px/1 'Onest', sans-serif;
  color: var(--muted); border-radius: 8px; cursor: pointer;
  transition: color .18s; white-space: nowrap;
}
.pill-btn.active { color: var(--ink); }
.pill-slider {
  position: absolute; top: 3px; left: 3px; bottom: 3px;
  background: var(--white); border-radius: 7px;
  box-shadow: 0 1px 4px rgba(0,0,0,.12);
  transition: transform .22s cubic-bezier(.4,0,.2,1), width .22s cubic-bezier(.4,0,.2,1);
  pointer-events: none; z-index: 0;
}

/* Right live preview panel */
.smeta-preview-panel {
  flex: 1; display: flex; flex-direction: column;
  background: #eceae6; overflow: hidden;
}
.spp-header {
  background: var(--white); border-bottom: 1px solid var(--line2);
  padding: 0 24px; flex-shrink: 0;
  display: flex; align-items: center; height: 44px;
}
.spp-tabs { display: flex; gap: 2px; }
.spp-tab {
  padding: 6px 14px; border: none; background: transparent;
  font: 500 12px/1 'Onest', sans-serif;
  color: var(--muted); border-radius: 6px; cursor: pointer;
  transition: background .15s, color .15s;
}
.spp-tab:hover { background: var(--card); color: var(--ink); }
.spp-tab.active { background: #e8eeff; color: #3a5ed0; font-weight: 600; }
.spp-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;   /* ← ВОТ ЭТО ГЛАВНОЕ ИСПРАВЛЕНИЕ */
  padding: 24px 16px 40px;
  gap: 20px;
  overflow-anchor: none;
  margin-top: 0 !important;
  transform: none !important;
  position: relative;
  top: 0;
}
.spp-page {
  width: 100%;
  display: flex !important;
  justify-content: center;
  transition: opacity .2s;
}
.spp-page.spp-hidden {
  display: none !important;
}

/* A4 page in right panel — scales to fit available width */
.spp-a4 {
  width: 100%;
  max-width: 860px;
  aspect-ratio: 297 / 210;
  background: #fff;
  box-shadow: 0 3px 20px rgba(0,0,0,.13);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  margin: 0 auto;
}

.spp-a4.cover-pg {
  aspect-ratio: 297 / 210 !important;
  height: auto !important;
  min-height: auto !important;
  max-height: none !important;
  overflow: hidden !important;
  display: flex;
  flex-direction: column;
  position: relative;
}
  background: #fff;
  box-shadow: 0 3px 20px rgba(0,0,0,.13);
  border-radius: 4px;
  position: relative;
  overflow: hidden;           /* чтобы содержимое не вылезало */
  display: flex;
  flex-direction: column;
  margin: 0 auto;
}

/* Inline edit on spp-a4 elements */
.spp-a4 [data-editable] {
  cursor: text;
  border-radius: 3px;
  transition: background .12s, outline .12s;
  outline: 1.5px dashed transparent;
  outline-offset: 3px;
}
.spp-a4 [data-editable]:hover {
  outline-color: #4a9eff;
  background: rgba(74,158,255,0.05);
}
.spp-a4 [data-editable]:focus {
  outline-color: #2171e0;
  background: rgba(33,113,224,0.07);
}

/* Sidebar head button adjustments */
.sidebar-head { padding: 16px 20px 12px; }
.sidebar-scroll { padding: 16px 20px 40px; }

/* ═══════════════════════════════════════════════════════════════
   BLOCK EDITOR v2
═══════════════════════════════════════════════════════════════ */

/* Plan page layout */
.be-plan-grid {
  flex: 1;
}
.be-plan-left {
  position: relative;
}
.be-plan-right {
  position: relative;
}

/* A4 page sizing in right panel */
.spp-a4 {
  width: 100%;
  max-width: 740px;
  margin: 0 auto;
  background: var(--white);
  box-shadow: 0 2px 20px rgba(0,0,0,.13), 0 1px 4px rgba(0,0,0,.07);
  border-radius: 2px;
  font-family: 'Merriweather', serif;
  position: relative;
}

/* Margin guide */
.be-margin-guide {
  position: absolute;
  pointer-events: none;
  z-index: 1;
  border: 1px dashed rgba(160,160,160,0.3);
  box-sizing: border-box;
  border-radius: 1px;
}

/* Block hover/selected states */
.be-block {
  position: relative;
  border-radius: 2px;
}
.be-block:hover {
  outline: 1.5px dashed rgba(74,159,255,0.3);
  outline-offset: 2px;
}
.be-block.be-selected {
  outline: 2px solid #4a9eff !important;
  outline-offset: 2px;
}
.be-block.be-editing {
  outline: 2px solid #2171e0 !important;
  background: rgba(33,113,224,0.03);
}
.be-block.be-hidden {
  opacity: 0.1;
}

/* Toolbar */
.be-toolbar {
  display: none;
  position: absolute;
  top: -36px; left: 0;
  z-index: 9999;
  background: #1a1a2e;
  border-radius: 8px;
  padding: 4px 7px;
  gap: 3px;
  align-items: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.38);
  white-space: nowrap;
  user-select: none;
  pointer-events: all;
}
.be-block.be-selected > .be-toolbar,
.be-block.be-editing > .be-toolbar { display: flex; }

.be-sep {
  width: 1px; height: 14px;
  background: rgba(255,255,255,0.15);
  flex-shrink: 0;
}
.be-handle {
  cursor: grab;
  color: rgba(255,255,255,0.5);
  font-size: 15px;
  padding: 0 4px;
  line-height: 1;
}
.be-handle:active { cursor: grabbing; }
.be-btn {
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: 5px;
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 7px;
  cursor: pointer;
  font-family: 'Onest', sans-serif;
  line-height: 1.3;
  transition: background .12s;
}
.be-btn:hover { background: rgba(255,255,255,0.28); }
.be-del { background: rgba(180,40,30,0.55) !important; }
.be-del:hover { background: rgba(220,60,45,0.85) !important; }
