/* ==========================================================
   FiberMap — styles
   Ink-blue chrome, single-mode-yellow accent, TIA-598 colour stripe
   ========================================================== */
:root {
  --ink: #1b2a41;
  --ink-2: #2c3e5a;
  --paper: #f5f6f8;
  --panel: #ffffff;
  --line: #dde2ea;
  --text: #1c2430;
  --muted: #677386;
  --yellow: #f2c230;
  --yellow-2: #e0ad12;
  --blue: #1f5fd1;
  --red: #d63b33;
  --green: #1f9d55;
  --orange: #f07c1b;
  --r-sm: 4px;
  --r-md: 8px;
  --topbar: 54px;
  --side: 340px;
  --drawer: 420px;
  --font: 'Barlow', 'Segoe UI', system-ui, sans-serif;
  --cond: 'Barlow Condensed', 'Arial Narrow', 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 15px/1.45 var(--font); color: var(--text); background: var(--paper); overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
h2, h3, h4 { font-family: var(--cond); font-weight: 600; line-height: 1.15; margin: 0; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 13px; }

/* ---- the signature: TIA-598 fiber colour order ---- */
.fiber-stripe {
  height: 4px;
  background: linear-gradient(90deg,
    #1f5fd1 0 8.33%, #f07c1b 0 16.66%, #1f9d55 0 25%, #8a5a2b 0 33.33%, #7b8794 0 41.66%, #f4f6f8 0 50%,
    #d63b33 0 58.33%, #1a1d21 0 66.66%, #f2c230 0 75%, #7a4fd6 0 83.33%, #ef7fa6 0 91.66%, #2bb3c0 0 100%);
}

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--panel);
  border-radius: var(--r-sm); padding: 7px 14px; font-weight: 600; line-height: 1.2; transition: background .12s, border-color .12s; white-space: nowrap; }
.btn:hover { border-color: #b7c0cd; background: #f0f2f6; }
.btn.primary { background: var(--yellow); border-color: var(--yellow-2); color: var(--ink); }
.btn.primary:hover { background: var(--yellow-2); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: #fdecea; border-color: #f0b4ae; }
.btn.small { padding: 5px 10px; font-size: 13.5px; }
.btn.block { width: 100%; padding: 10px; font-size: 16px; }
.btn:disabled { opacity: .55; cursor: progress; }
.btn.ghost-dark { background: transparent; color: #e7ecf4; border-color: #4a5d7b; }
.btn.ghost-dark:hover { background: var(--ink-2); }
.icon-btn { border: 0; background: transparent; width: 32px; height: 32px; border-radius: var(--r-sm); font-size: 16px; line-height: 1; color: var(--muted); }
.icon-btn:hover { background: #eef1f5; color: var(--text); }
.icon-btn.sm { width: 24px; height: 24px; font-size: 13px; }
.link { border: 0; background: none; padding: 0; color: var(--blue); font-weight: 600; text-align: left; }
.link:hover { text-decoration: underline; }
a { color: var(--blue); }

/* ---- topbar ---- */
.topbar { height: var(--topbar); background: var(--ink); color: #fff; display: flex; align-items: center; gap: 12px; padding: 0 14px; position: relative; z-index: 1200; }
.brand { display: flex; align-items: center; gap: 10px; font: 700 21px/1 var(--cond); letter-spacing: .01em; min-width: max-content; }
.brand-mark { width: 22px; height: 22px; border-radius: 50%; border: 5px solid var(--yellow); box-shadow: inset 0 0 0 3px var(--ink), inset 0 0 0 7px #fff; }
.search { position: relative; flex: 1; max-width: 520px; margin-left: 8px; }
.search input { width: 100%; background: var(--ink-2); border: 1px solid #45587a; color: #fff; border-radius: var(--r-sm); padding: 8px 12px; }
.search input::placeholder { color: #9fb0c8; }
.search-results { display: none; position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--r-md); box-shadow: 0 12px 30px rgba(20, 32, 52, .22); max-height: 60vh; overflow: auto; padding: 4px; }
.search-results.show { display: block; }
.search-results button { display: flex; gap: 8px; align-items: center; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: var(--r-sm); }
.search-results button:hover { background: #f0f3f7; }
.base-pick { display: flex; align-items: center; gap: 6px; color: #b9c6d8; font-size: 13px; }
.base-pick select { background: var(--ink-2); border: 1px solid #45587a; color: #fff; border-radius: var(--r-sm); padding: 6px 8px; }
.user-menu { position: relative; margin-left: auto; }
.user-btn { display: flex; flex-direction: column; align-items: flex-end; background: none; border: 0; color: #fff; padding: 4px 6px; line-height: 1.15; }
.user-btn small { color: var(--yellow); font-size: 12px; }
.menu { display: none; position: absolute; right: 0; top: calc(100% + 6px); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md); min-width: 180px; padding: 4px; box-shadow: 0 12px 30px rgba(20, 32, 52, .22); }
.menu.show { display: block; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; color: var(--text); border-radius: var(--r-sm); }
.menu button:hover { background: #f0f3f7; }
.only-mobile { display: none; color: #fff; }

/* ---- layout ---- */
.layout { position: relative; height: calc(100% - var(--topbar) - 4px); display: flex; }
.sidebar { width: var(--side); flex: none; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; z-index: 900; }
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); }
.tabs button { border: 0; background: none; padding: 10px 2px 9px; font: 600 15px/1 var(--cond); color: var(--muted); border-bottom: 3px solid transparent; }
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--ink); border-bottom-color: var(--yellow); }
.panel { flex: 1; overflow: auto; padding: 14px; }
.panel section { margin-bottom: 20px; }
.panel h3 { font-size: 18px; margin-bottom: 8px; color: var(--ink); }
.map-wrap { position: relative; flex: 1; min-width: 0; }
#map { position: absolute; inset: 0; background: #e8ecf1; }
body.mode-on #map { cursor: crosshair; }
body.mode-on .leaflet-interactive { cursor: crosshair; }

/* ---- tools ---- */
.tools { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tool { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel); font-weight: 600; text-align: left; }
.tool:hover { border-color: var(--ink); background: #f7f8fa; }
.ti-cable { width: 24px; height: 4px; border-radius: 2px; background: var(--blue); position: relative; }
.ti-cable::before, .ti-cable::after { content: ''; position: absolute; top: -3px; width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 2px solid var(--blue); }
.ti-cable::before { left: -4px; } .ti-cable::after { right: -4px; }
.layers { display: grid; gap: 4px; }
.chk { display: flex; align-items: center; gap: 8px; padding: 3px 0; cursor: pointer; }
.chk input { width: 16px; height: 16px; accent-color: var(--ink); }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; font-size: 14px; }
.legend li { display: flex; align-items: center; gap: 10px; }
.lg-line { display: inline-block; width: 30px; border-radius: 2px; flex: none; }
.lg-line.dashed-red { height: 4px; background: repeating-linear-gradient(90deg, #e02f25 0 8px, transparent 8px 13px); }
.lg-line.dotted { height: 4px; background: repeating-linear-gradient(90deg, var(--blue) 0 3px, transparent 3px 9px); }

/* ---- map markers ---- */
.fm-ic { background: none; border: 0; }
.mk { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; font: 700 11px/1 var(--cond); letter-spacing: .02em;
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .45); }
.mk-olt { background: #5b3cc4; border-radius: 6px; }
.mk-odf { background: #0e7d8a; border-radius: 6px; }
.mk-splitter { background: #1f9d55; }
.mk-joint { background: #d9831a; clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); border: 0; box-shadow: none; }
.mk.st-faulty { outline: 3px solid var(--red); outline-offset: 1px; }
.mk.st-planned { opacity: .6; border-style: dashed; }
.mk.st-inactive { filter: grayscale(1); opacity: .55; }
.mk.mini { width: 22px; height: 22px; font-size: 9px; flex: none; }
.mk.mk-inline { width: 40px; height: 40px; font-size: 13px; flex: none; }
.mk-pole { display: inline-block; width: 12px; height: 12px; background: #fff; border: 3px solid #4d5a6c; border-radius: 2px; box-shadow: 0 0 0 1px #fff; flex: none; }
.mk-pole.st-faulty { border-color: var(--red); }
.mk-pole.st-planned { border-style: dashed; }
.mk-cust { display: inline-block; width: 16px; height: 16px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--green); border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .45); flex: none; }
.mk-cust.st-pending { background: var(--orange); }
.mk-cust.st-suspended { background: var(--red); }
.mk-cust.st-inactive { background: #8792a2; }
.mk-cust.big { width: 30px; height: 30px; }
.mk-fault { display: inline-block; width: 26px; height: 26px; border-radius: 50%; background: var(--red); border: 3px solid #fff; position: relative; box-shadow: 0 0 0 0 rgba(214, 59, 51, .6); flex: none; }
.mk-fault::before, .mk-fault::after { content: ''; position: absolute; left: 50%; top: 50%; width: 12px; height: 3px; background: #fff; border-radius: 2px; }
.mk-fault::before { transform: translate(-50%, -50%) rotate(45deg); }
.mk-fault::after { transform: translate(-50%, -50%) rotate(-45deg); }
.mk-fault.open { animation: pulse 1.8s infinite; }
.mk-fault.in_progress { background: var(--orange); }
.mk-fault.resolved { background: #8792a2; animation: none; }
.mk-fault.sv-low, .mk-fault.sv-medium { width: 22px; height: 22px; }
.mk-fault.mini { width: 20px; height: 20px; border-width: 2px; animation: none; }
.mk-fault.mini::before, .mk-fault.mini::after { width: 9px; height: 2px; }
.mk-fault.big { width: 38px; height: 38px; animation: none; }
.mk-otdr { display: block; width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--red); background: rgba(242, 194, 48, .85); box-shadow: 0 0 0 4px rgba(214, 59, 51, .25); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(214, 59, 51, .55); } 70% { box-shadow: 0 0 0 14px rgba(214, 59, 51, 0); } 100% { box-shadow: 0 0 0 0 rgba(214, 59, 51, 0); } }
@media (prefers-reduced-motion: reduce) { .mk-fault.open { animation: none; } }
.pole-label { display: none; background: rgba(255, 255, 255, .92); border: 1px solid #b5bfcc; border-radius: 3px; padding: 0 4px; font: 600 12px/1.4 var(--cond); color: var(--ink); box-shadow: none; }
.pole-label::before { display: none; }
.show-labels .pole-label { display: block; }
.leaflet-tooltip { font-family: var(--font); font-size: 13px; }
.leaflet-container { font-family: var(--font); }

/* ---- hint & action bar ---- */
.hint, .actionbar { position: absolute; left: 50%; transform: translateX(-50%); z-index: 1000; background: var(--ink); color: #fff; border-radius: var(--r-md);
  padding: 9px 14px; box-shadow: 0 8px 24px rgba(20, 32, 52, .3); display: none; max-width: calc(100% - 24px); }
.hint { top: 12px; font-size: 14px; }
.hint.show { display: block; }
.hint kbd { background: var(--ink-2); border: 1px solid #56698a; border-radius: 3px; padding: 0 5px; font-size: 12px; }
.actionbar { bottom: 22px; align-items: center; gap: 10px; flex-wrap: wrap; }
.actionbar.show { display: flex; }
.actionbar .btn.ghost { color: #fff; border-color: #56698a; }

/* ---- drawer ---- */
.drawer { position: absolute; right: 0; top: 0; bottom: 0; width: var(--drawer); max-width: 100%; background: var(--panel); border-left: 1px solid var(--line);
  box-shadow: -10px 0 30px rgba(20, 32, 52, .12); transform: translateX(105%); transition: transform .2s ease; overflow: auto; padding: 18px 18px 40px; z-index: 950; }
.drawer.open { transform: none; }
@media (prefers-reduced-motion: reduce) { .drawer { transition: none; } }
.drawer-x { position: absolute; right: 10px; top: 10px; }
.drawer h4 { font-size: 17px; margin: 22px 0 8px; color: var(--ink); display: flex; gap: 8px; align-items: baseline; }
.drawer h4 .muted { font: 400 13px var(--font); }
.d-head { display: flex; gap: 12px; align-items: center; padding-right: 36px; }
.d-head h2 { font-size: 25px; color: var(--ink); }
.d-head p { margin: 2px 0 0; }
.d-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 12px; }
.info { display: grid; grid-template-columns: 118px 1fr; gap: 6px 12px; margin: 0; font-size: 14px; }
.info dt { color: var(--muted); }
.info dd { margin: 0; overflow-wrap: anywhere; }
.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.row-link { display: flex; gap: 8px; align-items: center; width: 100%; text-align: left; border: 0; background: none; padding: 6px 8px; border-radius: var(--r-sm); }
.row-link:hover { background: #f0f3f7; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { border: 1px solid #b9c3d0; background: #fff; border-radius: 3px; padding: 2px 8px; font: 600 14px/1.4 var(--cond); color: var(--ink); }
.chip:hover { background: var(--yellow); border-color: var(--yellow-2); }

/* splitter / PON ports */
.ports { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 5px; }
.port { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 5px 7px; font-size: 12.5px; text-align: left; background: #fff; min-height: 46px; }
.port b { display: block; font: 700 15px/1.1 var(--cond); }
.port span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.port.free { background: repeating-linear-gradient(135deg, #fafbfc 0 6px, #f1f3f6 6px 12px); color: var(--muted); }
.port.used { border-left: 4px solid var(--green); }
.port.used.st-suspended { border-left-color: var(--red); }
.port.used.st-pending { border-left-color: var(--orange); }
button.port:hover { border-color: var(--ink); }

/* core table */
.tbl-wrap { overflow-x: auto; margin: 0 -4px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font: 600 13px var(--cond); color: var(--muted); padding: 5px 6px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 4px 6px; border-bottom: 1px solid #eef1f4; vertical-align: middle; }
.tbl td.num { font: 700 15px var(--cond); width: 30px; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover td { background: #f6f8fb; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .35); vertical-align: -1px; margin-right: 3px; }
.sw-l { font-size: 12.5px; }
.core-st { border: 1px solid var(--line); border-radius: 3px; padding: 2px 4px; font-size: 13px; background: #fff; }
.core-st.st-used { background: #e7f5ec; border-color: #9fd3b3; }
.core-st.st-reserved { background: #fff5d6; border-color: #ecd27f; }
.core-st.st-faulty { background: #fdecea; border-color: #f0b4ae; }
.core-bar { display: flex; height: 22px; border-radius: var(--r-sm); overflow: hidden; font: 600 12px/22px var(--cond); color: #fff; text-align: center; margin-bottom: 8px; }
.core-bar span { min-width: 22px; }
.cb-free { background: #aab4c2; } .cb-used { background: var(--green); } .cb-reserved { background: var(--yellow-2); color: var(--ink); } .cb-faulty { background: var(--red); }
.line-sw { display: inline-block; width: 22px; height: 4px; border-radius: 2px; flex: none; }
.line-sw.big { width: 40px; height: 8px; border-radius: 4px; }
.lt-backbone { background: #c0392b; } .lt-distribution { background: var(--blue); } .lt-drop { background: var(--green); }

/* OTDR */
.otdr { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; align-items: end; background: #f6f8fb; border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px; }
.otdr label { display: grid; gap: 3px; font-size: 12.5px; color: var(--muted); }
.otdr input, .otdr select { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 6px 7px; background: #fff; min-width: 0; width: 100%; }
.otdr > .btn { grid-column: 1 / -1; }
.otdr-out { grid-column: 1 / -1; font-size: 14px; }
.otdr-out p { margin: 0 0 8px; }
.err { color: var(--red); }

/* customer path */
.path { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 3px solid var(--yellow); display: grid; gap: 9px; }
.path li { position: relative; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.path li::before { content: ''; position: absolute; left: -23px; top: 6px; width: 11px; height: 11px; border-radius: 50%; background: #fff; border: 3px solid var(--ink); }
.rx { font: 600 13px var(--cond); padding: 1px 6px; border-radius: 3px; }
.rx.good { background: #e7f5ec; color: #146c3b; } .rx.warn { background: #fff5d6; color: #8a6200; } .rx.bad { background: #fdecea; color: #a4271f; }

/* badges */
.badge { display: inline-block; font: 600 12.5px/1.5 var(--cond); padding: 0 7px; border-radius: 3px; background: #eef1f5; color: var(--ink-2); white-space: nowrap; }
.b-active, .b-resolved, .b-used { background: #e7f5ec; color: #146c3b; }
.b-planned, .b-pending, .b-reserved, .b-medium { background: #fff5d6; color: #8a6200; }
.b-damaged, .b-faulty, .b-open, .b-suspended, .b-critical, .b-high { background: #fdecea; color: #a4271f; }
.b-in_progress { background: #ffeedd; color: #a14c00; }
.b-inactive { background: #eceef1; color: #6b7482; }
.b-olt { background: #ece6fb; color: #4a2fa3; } .b-odf { background: #e0f3f5; color: #0b6570; } .b-splitter { background: #e3f4ea; color: #16713d; }
.b-joint { background: #fdf0de; color: #93560e; } .b-pole { background: #e9edf2; color: #3e4a5b; } .b-cable { background: #e5edfb; color: #1a4fae; }
.b-cust, .b-onu { background: #eef6d9; color: #4d6614; }
.b-super_admin { background: var(--ink); color: var(--yellow); } .b-admin { background: #e5edfb; color: #1a4fae; } .b-engineer { background: #e3f4ea; color: #16713d; } .b-viewer { background: #eceef1; color: #4b5563; }

/* lists */
.list-head { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.list-head input[type=search] { flex: 1 1 100%; }
.list-head input, .list-head select { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 7px 9px; background: #fff; min-width: 0; }
.list-head select { flex: 1; }
.mini-lbl { display: grid; font-size: 12px; color: var(--muted); flex: 1; }
.list-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.list { display: grid; gap: 1px; }
.list-sum { margin: 2px 0 6px; }
.item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid #eef1f4; padding: 8px 4px; }
.item:hover { background: #f5f7fa; }
.item-main { flex: 1; min-width: 0; display: grid; }
.item-main b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-main small { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { color: var(--muted); padding: 18px 4px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: var(--yellow); display: grid; place-items: center; font: 700 16px var(--cond); flex: none; }
.role-help { margin-top: 14px; line-height: 1.55; }
.log-row { display: grid; gap: 1px; padding: 7px 2px; border-bottom: 1px solid #eef1f4; font-size: 14px; }

/* dashboard */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 12px; background: #fff; }
.stat b { display: block; font: 700 30px/1 var(--cond); color: var(--ink); }
.stat span { font-size: 13px; color: var(--muted); }
.stat.wide { grid-column: 1 / -1; }
.stat.alert { border-color: #f0b4ae; background: #fdf3f2; }
.stat.alert b { color: var(--red); }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 110px; border-bottom: 1px solid var(--line); padding-bottom: 18px; position: relative; }
.bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; position: relative; }
.bar i { display: block; background: var(--red); border-radius: 2px 2px 0 0; min-height: 1px; }
.bar span { position: absolute; bottom: -17px; left: 0; right: 0; text-align: center; font: 500 11px var(--cond); color: var(--muted); }

/* ---- modal & forms ---- */
.modal { position: fixed; inset: 0; background: rgba(18, 28, 44, .45); z-index: 2000; display: none; align-items: flex-start; justify-content: center; padding: 6vh 12px; overflow: auto; }
.modal.open { display: flex; }
.modal-card { background: var(--panel); border-radius: var(--r-md); width: 560px; max-width: 100%; box-shadow: 0 24px 60px rgba(10, 20, 40, .35); border-top: 4px solid var(--yellow); }
.modal-card.wide { width: 760px; }
.modal-card header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px 6px; }
.modal-card h3 { font-size: 22px; color: var(--ink); }
.modal-card footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--line); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; padding: 8px 18px 14px; }
.modal-card.wide .form-grid { grid-template-columns: 1fr 1fr 1fr; }
.fg { display: grid; gap: 4px; min-width: 0; }
.fg.full, .f-info.full, .f-section.full { grid-column: 1 / -1; }
.fg label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.fg label em { color: var(--red); font-style: normal; }
.fg input, .fg select, .fg textarea { border: 1px solid #cdd4de; border-radius: var(--r-sm); padding: 8px 9px; background: #fff; width: 100%; min-width: 0; }
.fg input:focus, .fg select:focus, .fg textarea:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px rgba(31, 95, 209, .15); }
.fg input[readonly] { background: #f3f5f8; }
.fg small { color: var(--muted); font-size: 12px; }
.f-info { background: #f6f8fb; border-left: 3px solid var(--yellow); padding: 8px 10px; font-size: 14px; border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.f-section { font: 600 16px var(--cond); color: var(--ink); border-bottom: 1px solid var(--line); padding: 6px 0 3px; margin-top: 4px; }
.form-err { display: none; margin: 0 18px 10px; padding: 8px 10px; background: #fdecea; color: #a4271f; border-radius: var(--r-sm); font-size: 14px; }
.form-err.show { display: block; }

/* ---- toasts ---- */
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 3000; display: grid; gap: 6px; justify-items: center; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 9px 16px; border-radius: var(--r-md); box-shadow: 0 8px 24px rgba(0, 0, 0, .25); font-size: 14px; border-left: 4px solid var(--green); }
.toast.t-err { border-left-color: var(--red); }

/* ---- role based visibility ---- */
body[data-role=viewer] .need-edit { display: none !important; }
body:not([data-role=admin]):not([data-role=super_admin]) .need-admin { display: none !important; }
body:not([data-role=super_admin]) .need-super { display: none !important; }

/* ---- auth pages ---- */
body.auth-page { overflow: auto; display: grid; place-items: center; min-height: 100%; padding: 24px 12px; background: var(--ink); }
.auth-card { background: var(--panel); width: 380px; max-width: 100%; border-radius: var(--r-md); overflow: hidden; padding: 0 28px 24px; box-shadow: 0 30px 80px rgba(0, 0, 0, .35); }
.auth-card .fiber-stripe { margin: 0 -28px 26px; height: 6px; }
.auth-title { font: 700 34px/1 var(--cond); color: var(--ink); margin: 0 0 6px; }
.auth-sub { color: var(--muted); margin: 0 0 18px; }
.auth-ok { margin: 0 0 18px; }
.auth-form { display: grid; gap: 12px; }
.auth-form label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.auth-form input { border: 1px solid #cdd4de; border-radius: var(--r-sm); padding: 10px 11px; font-size: 16px; }
.auth-form input:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px rgba(31, 95, 209, .15); }
.auth-card .form-err { margin: 0 0 12px; }
.auth-foot { text-align: center; color: var(--muted); font-size: 13px; margin: 18px 0 0; }

/* ---- responsive ---- */
@media (max-width: 1100px) { :root { --side: 300px; --drawer: 380px; } .base-pick { font-size: 0; } }
@media (max-width: 900px) {
  .only-mobile { display: inline-grid; place-items: center; }
  .brand span:last-child { display: none; }
  .search { margin-left: 0; }
  #btnPrint, #btnPdf { display: none; }
  .user-btn small { display: none; }
  .sidebar { position: absolute; left: 0; top: 0; bottom: 0; transform: translateX(-102%); transition: transform .2s; box-shadow: 10px 0 30px rgba(20, 32, 52, .2); }
  body.side-open .sidebar { transform: none; }
  .drawer { width: 100%; top: 38%; border-top: 4px solid var(--yellow); border-left: 0; transform: translateY(105%); }
  .drawer.open { transform: none; }
  .modal-card.wide .form-grid, .form-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .form-grid, .modal-card.wide .form-grid { grid-template-columns: 1fr; }
  .base-pick { display: none; }
  .otdr { grid-template-columns: 1fr 1fr; }
}

/* ---- PDF capture ---- */
body.exporting .leaflet-control-zoom, body.exporting .hint, body.exporting .actionbar { display: none !important; }

/* ---- print ---- */
.print-head, .print-legend { display: none; }
@media print {
  @page { size: A4 landscape; margin: 8mm; }
  html, body { height: auto; overflow: visible; background: #fff; }
  .topbar, .fiber-stripe, .sidebar, .drawer, .hint, .actionbar, .toasts, .modal, .leaflet-control-zoom { display: none !important; }
  .layout { display: block; height: auto; }
  .map-wrap { position: relative; width: 100%; height: 175mm; border: 1px solid #333; }
  #map { position: absolute; inset: 0; }
  .print-head { display: flex; justify-content: space-between; align-items: baseline; font: 13px var(--font); margin-bottom: 3mm; position: absolute; top: -9mm; left: 0; right: 0; }
  .print-head b { font: 700 18px var(--cond); }
  .print-legend { display: block; position: absolute; left: 3mm; bottom: 8mm; background: #fff; border: 1px solid #999; padding: 3mm; z-index: 1000; font-size: 10px; }
  .print-legend .legend { gap: 3px; font-size: 10px; }
  body.printing .map-wrap { margin-top: 10mm; }
  .mk, .mk-cust, .mk-fault, .mk-pole, .leaflet-tile, .line-sw, .lg-line { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .mk-fault.open { animation: none; }
}
