:root{
  --bg:#0a1630;        /* deep Transia navy */
  --card:#111f3b;
  --muted:#c2cee0;
  --text:#ffffff;
  --border:#20375c;
  --accent:#f4b53f;    /* Transia gold */
  --danger:#ff5c7a;
  --ok:#42d392;
}

*{
  box-sizing:border-box;
}

body{
  margin:0;
  min-height:100vh;
  font-family:ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Arial;
  background:radial-gradient(circle at top,#182753 0,#050816 55%,#02030a 100%);
  color:var(--text);
}

/* HEADER / BRAND --------------------------------------------------- */

.header{
  max-width:1120px;
  margin:24px auto 8px;
  padding:0 16px;
}

.brand-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:20px;
  margin-bottom:10px;
}

.brand-left{
  display:flex;
  align-items:center;
  gap:12px;
}

.brand-logo{
  height:40px;
  width:auto;
  border-radius:4px;
}

.brand-text{
  display:flex;
  flex-direction:column;
  gap:2px;
}

.brand-name{
  font-size:14px;
  font-weight:600;
  letter-spacing:.11em;
  text-transform:uppercase;
}

.brand-tagline{
  font-size:11px;
  color:var(--muted);
}

.brand-right{
  font-size:12px;
  color:var(--muted);
  display:flex;
  align-items:center;
  gap:10px;
}

.back-link{
  font-size:12px;
  color:var(--muted);
  text-decoration:none;
  padding:4px 12px;
  border-radius:999px;
  border:1px solid var(--border);
  background:rgba(255,255,255,.04);
  transition:border-color .15s,color .15s;
}

.back-link:hover{
  border-color:rgba(244,181,63,.8);
  color:var(--accent);
}

.brand-tool-label{
  padding:4px 10px;
  border-radius:999px;
  border:1px solid var(--border);
  background:rgba(255,255,255,.04);
}

.title-row{
  display:flex;
  align-items:center;
  gap:12px;
  margin:4px 0 4px;
}

.title-row h1{
  font-size:26px;
  margin:0;
}

.pill{
  font-size:12px;
  padding:4px 10px;
  border-radius:999px;
  border:1px solid rgba(244,181,63,.7);
  color:var(--muted);
  background:rgba(244,181,63,.08);
}

.subtitle{
  margin:0;
  margin-top:4px;
  font-size:13px;
  line-height:1.5;
  color:var(--muted);
}

.disclaimer{
  margin:10px 0 0;
  font-size:11.5px;
  line-height:1.6;
  color:rgba(194,206,224,.4);
  border-top:1px solid rgba(32,55,92,.4);
  padding-top:8px;
}

.disclaimer strong{color:rgba(194,206,224,.6);font-weight:600}

/* LAYOUT ----------------------------------------------------------- */

.shell{
  max-width:1120px;
  margin:0 auto 32px;
  padding:0 16px 24px;
}

.layout{
  display:flex;
  flex-direction:column;
  gap:20px;
}

.sidebar{
  display:flex;
  flex-direction:column;
  gap:16px;
}

.main{
  display:flex;
  flex-direction:column;
  gap:16px;
}


/* CARDS ------------------------------------------------------------ */

.card{
  background:var(--card);
  border-radius:16px;
  border:1px solid rgba(32,55,92,.8);
  box-shadow:0 18px 40px rgba(0,0,0,.65);
  padding:16px 18px;
}

.card-title{
  font-size:15px;
  margin:0 0 4px;
}

.card-title.small{
  font-size:13px;
}

.card-text{
  margin:0 0 10px;
  font-size:13px;
  color:var(--muted);
}

.search-card{
  padding-bottom:12px;
}

.table-card{
  padding-top:10px;
}

/* TEXT UTILITIES --------------------------------------------------- */

.muted{
  color:var(--muted);
  font-size:12px;
}

.muted.small{
  font-size:11px;
  margin-top:10px;
}

/* BUTTONS ---------------------------------------------------------- */

.btn-row{
  display:flex;
  gap:8px;
  margin-top:14px;
  flex-wrap:wrap;
}

.btn{
  border-radius:999px;
  border:1px solid var(--border);
  background:rgba(255,255,255,.05);
  color:var(--text);
  font-size:12px;
  padding:6px 14px;
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  gap:6px;
}

.btn:hover{
  border-color:rgba(244,181,63,.8);
}

.btn.accent{
  border-color:rgba(244,181,63,.75);
  background:linear-gradient(180deg,rgba(244,181,63,.22),rgba(244,181,63,.12));
}

.btn.ghost{
  background:transparent;
}

/* DROPZONE --------------------------------------------------------- */

.dropzone{
  padding:18px 14px 16px;
  border-radius:12px;
  border:1px dashed rgba(194,206,224,.6);
  background:rgba(3,7,18,.45);
  text-align:center;
  transition:border-color .15s ease,background .15s ease;
}

.dropzone.dragover{
  border-style:solid;
  border-color:rgba(244,181,63,.9);
  background:rgba(244,181,63,.06);
}

.drop-main{
  margin:0;
  font-size:14px;
  font-weight:500;
}

.drop-sub{
  margin:4px 0 8px;
  font-size:12px;
  color:var(--muted);
}

/* STATUS + META ---------------------------------------------------- */

.status-row{
  display:flex;
  align-items:center;
  gap:8px;
  margin-top:14px;
}

.status-dot{
  width:8px;
  height:8px;
  border-radius:999px;
  background:#667188;
  flex-shrink:0;
}

.status-dot--idle{ background:#667188; }
.status-dot--working{ background:#f4b53f; }
.status-dot--ok{ background:var(--ok); }
.status-dot--error{ background:var(--danger); }

.status-text{
  font-size:12px;
  color:var(--muted);
}

.meta-row{
  display:flex;
  align-items:center;
  gap:8px;
  margin-top:10px;
  flex-wrap:wrap;
}

.badge{
  font-size:11px;
  padding:2px 8px;
  border-radius:999px;
  border:1px solid rgba(194,206,224,.6);
}

.badge.soft{
  border-color:rgba(244,181,63,.8);
  background:rgba(244,181,63,.08);
}

/* INFO LIST -------------------------------------------------------- */

.info-card{
  font-size:12px;
}

.info-list{
  padding-left:20px;
  margin:6px 0 0;
  color:var(--muted);
}

.info-list li{
  margin-bottom:4px;
}

/* SEARCH ----------------------------------------------------------- */

.search-header{
  display:flex;
  align-items:center;
  gap:12px;
}

.search-row{
  flex:1;
  display:flex;
  gap:8px;
  align-items:center;
  min-width:0;
}

.search{
  flex:3;
  min-width:0;
  padding:8px 10px;
  border-radius:10px;
  border:1px solid var(--border);
  background:rgba(255,255,255,.03);
  color:var(--text);
  font-size:13px;
  outline:none;
}

.search::placeholder{
  color:rgba(194,206,224,.75);
}

.btn--expiring{
  flex:1;
  min-width:0;
  white-space:nowrap;
  justify-content:center;
  border-color:rgba(255,92,122,.7);
  background:linear-gradient(180deg,rgba(255,92,122,.22),rgba(255,92,122,.12));
  color:#ffd3db;
}

.btn--expiring:hover{
  border-color:rgba(255,92,122,.95);
}

.btn--expiring.active{
  border-color:rgba(255,92,122,1);
  background:linear-gradient(180deg,rgba(255,92,122,.5),rgba(255,92,122,.35));
  color:#fff;
}

.btn--expired{
  flex:1;
  min-width:0;
  white-space:nowrap;
  justify-content:center;
  border-color:rgba(194,206,224,.3);
  background:linear-gradient(180deg,rgba(194,206,224,.1),rgba(194,206,224,.05));
  color:rgba(194,206,224,.6);
}

.btn--expired:hover{
  border-color:rgba(194,206,224,.55);
  color:rgba(194,206,224,.85);
}

.btn--expired.active{
  border-color:rgba(194,206,224,.7);
  background:linear-gradient(180deg,rgba(194,206,224,.25),rgba(194,206,224,.15));
  color:#fff;
}

@media (max-width:700px){
  .search-header{
    flex-direction:column;
    align-items:stretch;
  }
  .search-row{
    flex-direction:column;
  }
}

/* TABLE ------------------------------------------------------------ */

.table-wrap{
  overflow-x:auto;
  overflow-y:visible;
  /* gold scrollbar */
  scrollbar-width:thin;
  scrollbar-color:rgba(244,181,63,.65) rgba(11,18,32,.9);
}

.table-wrap::-webkit-scrollbar{
  height:7px;
}
.table-wrap::-webkit-scrollbar-track{
  background:rgba(11,18,32,.9);
  border-radius:999px;
}
.table-wrap::-webkit-scrollbar-thumb{
  background:rgba(244,181,63,.65);
  border-radius:999px;
}
.table-wrap::-webkit-scrollbar-thumb:hover{
  background:rgba(244,181,63,.95);
}

.table{
  width:100%;
  border-collapse:collapse;
  font-size:12px;
  min-width:1400px;
}

.table thead{
  background:rgba(8,22,44,.9);
}

.table th,
.table td{
  border-bottom:1px solid rgba(32,55,92,.85);
  padding:8px 8px;
  text-align:left;
  vertical-align:top;
}

/* CELL CLAMP ------------------------------------------------------- */

.cell-clamp{
  display:-webkit-box;
  -webkit-line-clamp:2;
  line-clamp:2;
  -webkit-box-orient:vertical;
  overflow:hidden;
  max-width:130px;
  line-height:1.35;
  word-break:break-word;
  cursor:pointer;
  user-select:none;
}
.cell-clamp.expanded{
  display:block;
  -webkit-line-clamp:unset;
  line-clamp:unset;
  overflow:visible;
  white-space:pre-wrap;
  max-width:none;
  cursor:text;
  user-select:text;
  background:rgba(32,55,92,.18);
  border-radius:4px;
  padding:4px 6px;
  outline:1px solid rgba(194,206,224,.2);
}

.cell-clamp--wide{
  max-width:220px;
}

.moa-dl-link,
.tgs-dl-link{
  color:var(--accent);
  text-decoration:none;
  font-weight:600;
}
.moa-dl-link:hover,
.tgs-dl-link:hover{
  text-decoration:underline;
  opacity:.85;
}

.table th{
  font-weight:600;
  font-size:11px;
  letter-spacing:.03em;
  text-transform:uppercase;
  color:var(--muted);
}

.table tbody tr{
  background:rgba(11,18,32,.75);
}

.table tbody tr.tgs-entry-row{
  background:rgba(17,31,59,.85);
}

.table tbody tr.tgs-entry-row .tm-subtable tbody tr{
  background:rgba(26,44,78,.9);
}

.table tbody tr:hover{
  background:rgba(244,181,63,.08);
}

/* GROUPED ROWS ----------------------------------------------------- */

.group-parent-row{
  background:rgba(244,181,63,.06);
}

.group-parent-row td{
  border-bottom:1px solid rgba(244,181,63,.18);
}

.group-toggle{
  display:inline-flex;
  align-items:center;
  gap:5px;
  font-size:11px;
  padding:3px 9px;
  border-radius:999px;
  border:1px solid rgba(244,181,63,.7);
  background:rgba(244,181,63,.12);
  color:var(--accent);
  cursor:pointer;
  white-space:nowrap;
  font-family:inherit;
}

.group-toggle:hover{
  background:rgba(244,181,63,.24);
}

.toggle-arrow{
  font-size:10px;
  line-height:1;
}

.sub-row td:first-child{
  border-left:3px solid rgba(244,181,63,.45);
  padding-left:10px;
}

.sub-row{
  background:rgba(5,12,28,.55);
}

/* FILE CELL -------------------------------------------------------- */

.file-name{
  font-size:12px;
  margin:0 0 2px;
}

.file-meta{
  font-size:11px;
  color:var(--muted);
}

/* ACTION BUTTONS --------------------------------------------------- */

.actions{
  display:flex;
  gap:6px;
  flex-wrap:wrap;
}

.iconbtn{
  font-size:11px;
  border-radius:999px;
  border:1px solid var(--border);
  background:rgba(255,255,255,.04);
  color:var(--text);
  padding:3px 8px;
  cursor:pointer;
}

.iconbtn:hover{
  border-color:rgba(244,181,63,.85);
}

.iconbtn.danger{
  border-color:rgba(255,92,122,.7);
  background:rgba(255,92,122,.12);
  color:#ffd3db;
}

/* RESPONSIVE ------------------------------------------------------- */

@media (max-width:480px){
  .header{
    margin-top:16px;
  }
  .brand-row{
    flex-direction:column;
    align-items:flex-start;
  }
  .title-row{
    flex-direction:column;
    align-items:flex-start;
  }
}

/* DROPZONE PAIR -------------------------------------------- */

.dropzone-pair{
  display:flex;
  gap:10px;
  margin-top:8px;
}

.dropzone-section{
  flex:1;
  min-width:0;
  display:flex;
  flex-direction:column;
}

.dropzone-section .dropzone{
  flex:1;
}

.dropzone-tgs-col{
  flex:1;
  min-width:0;
  display:flex;
  flex-direction:column;
  gap:8px;
}

.drop-zone-label{
  font-size:11px;
  font-weight:600;
  letter-spacing:.06em;
  text-transform:uppercase;
  color:var(--muted);
  margin:0 0 4px 2px;
}

.dropzone{
  margin-top:0;
}

.dropzone--tgs{
  border-color:rgba(66,211,146,.5);
}

.dropzone--tgs.dragover{
  border-style:solid;
  border-color:rgba(66,211,146,.9);
  background:rgba(66,211,146,.06);
}

.btn--tgs{
  border-color:rgba(66,211,146,.7);
  background:linear-gradient(180deg,rgba(66,211,146,.18),rgba(66,211,146,.09));
}

.dropzone--tgs-long{
  border-color:rgba(255,92,122,.5);
}

.dropzone--tgs-long.dragover{
  border-style:solid;
  border-color:rgba(255,92,122,.9);
  background:rgba(255,92,122,.06);
}

.btn--tgs-long{
  border-color:rgba(255,92,122,.7);
  background:linear-gradient(180deg,rgba(255,92,122,.18),rgba(255,92,122,.09));
  color:#ffd3db;
}

/* TGS MAP -------------------------------------------------- */

.tgs-map-card{
  padding:16px 18px;
}

.map-card-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom:4px;
  flex-wrap:wrap;
}

.map-filter-row{
  display:flex;
  gap:6px;
  flex-wrap:wrap;
}

.btn--map-short{
  border-color:rgba(51,136,255,.45);
  background:linear-gradient(180deg,rgba(51,136,255,.1),rgba(51,136,255,.05));
  color:rgba(120,170,255,.6);
}
.btn--map-short:hover{
  border-color:rgba(51,136,255,.75);
  color:rgba(150,190,255,.9);
}
.btn--map-short.active{
  border-color:rgba(51,136,255,.85);
  background:linear-gradient(180deg,rgba(51,136,255,.32),rgba(51,136,255,.2));
  color:#80b4ff;
}

.btn--map-long{
  border-color:rgba(255,92,122,.45);
  background:linear-gradient(180deg,rgba(255,92,122,.1),rgba(255,92,122,.05));
  color:rgba(255,160,175,.6);
}
.btn--map-long:hover{
  border-color:rgba(255,92,122,.75);
  color:rgba(255,180,190,.9);
}
.btn--map-long.active{
  border-color:rgba(255,92,122,.85);
  background:linear-gradient(180deg,rgba(255,92,122,.32),rgba(255,92,122,.2));
  color:#ffb4c2;
}

.btn--map-expired{
  border-color:rgba(138,149,163,.38);
  background:linear-gradient(180deg,rgba(138,149,163,.09),rgba(138,149,163,.04));
  color:rgba(138,149,163,.55);
}
.btn--map-expired:hover{
  border-color:rgba(138,149,163,.65);
  color:rgba(165,175,190,.9);
}
.btn--map-expired.active{
  border-color:rgba(138,149,163,.75);
  background:linear-gradient(180deg,rgba(138,149,163,.28),rgba(138,149,163,.16));
  color:#c2cee0;
}

.tgs-map{
  height:380px;
  border-radius:10px;
  overflow:hidden;
  margin-top:10px;
  border:1px solid var(--border);
  background:var(--bg);
}

/* Override Leaflet popup for dark theme */
.leaflet-popup-content-wrapper{
  background:var(--card);
  color:var(--text);
  border:1px solid var(--border);
  border-radius:10px;
  box-shadow:0 8px 24px rgba(0,0,0,.5);
}

.leaflet-popup-tip{
  background:var(--card);
}

.leaflet-popup-content{
  margin:10px 14px;
  font-size:13px;
  line-height:1.5;
}

@media (max-width:600px){
  .dropzone-pair{
    flex-direction:column;
  }
}

/* PIN CONFIRM MODAL ----------------------------------------- */

.pin-confirm-overlay{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.72);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index:9999;
}

.pin-confirm-modal{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:12px;
  width:min(640px,95vw);
  max-height:90vh;
  display:flex;
  flex-direction:column;
  overflow:hidden;
}

.pin-confirm-header{
  padding:16px 20px 12px;
  border-bottom:1px solid var(--border);
}

.pin-confirm-title{
  margin:0 0 4px;
  font-size:15px;
  font-weight:700;
  color:var(--accent);
}

.pin-confirm-name{
  margin:0;
  font-size:12px;
  color:var(--muted);
  word-break:break-word;
}

.pin-confirm-body{
  padding:14px 20px;
  overflow-y:auto;
}

.pin-confirm-road{
  margin:0 0 4px;
  font-size:12px;
  color:var(--muted);
}

.pin-confirm-hint{
  margin:0 0 10px;
  font-size:11px;
  color:var(--muted);
  opacity:.75;
}

.pin-confirm-map{
  height:320px;
  border-radius:8px;
  overflow:hidden;
  border:1px solid var(--border);
}

.pin-confirm-coords{
  margin:6px 0 0;
  font-size:11px;
  color:var(--muted);
  opacity:.7;
  font-family:ui-monospace,monospace;
}

.pin-confirm-footer{
  padding:12px 20px;
  border-top:1px solid var(--border);
  display:flex;
  gap:10px;
  justify-content:flex-end;
}

/* ROW HIGHLIGHT (map pin → register table navigation) ------- */

@keyframes row-flash{
  0%  { background:rgba(244,181,63,.38); }
  100%{ background:transparent; }
}

.row-highlight{
  animation:row-flash 2.5s ease-out forwards;
}

/* ── TGS sub-panel ─────────────────────────────────────────────────────────── */
.tgs-panel-row td{padding:0;border-top:2px solid rgba(32,55,92,.6)}
.tgs-subtable{width:100%;border-collapse:collapse;font-size:12.5px}
.tgs-subtable th{padding:7px 12px;text-align:left;font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.06em;color:rgba(194,206,224,.45);border-bottom:1px solid rgba(32,55,92,.5);white-space:nowrap;background:rgba(5,8,22,.5)}
.tgs-subtable td{padding:7px 12px;border-bottom:1px solid rgba(32,55,92,.25);color:rgba(194,206,224,.85);vertical-align:top}
.tgs-subtable tbody tr:hover{background:rgba(32,55,92,.12)}
.tgs-subtable .sub-row td:first-child{border-left:2px solid rgba(32,55,92,.5);padding-left:22px}
.tgs-subtable .group-parent-row{background:rgba(32,55,92,.08)}
.tgs-subtable .group-parent-row td{border-bottom-color:rgba(32,55,92,.4)}
/* TM company mini-table */
.tm-subtable{width:100%;border-collapse:collapse;font-size:12.5px;margin:0}
.tm-subtable th{padding:6px 14px;text-align:left;font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.06em;color:rgba(194,206,224,.45);border-bottom:1px solid rgba(32,55,92,.5);white-space:nowrap;background:rgba(5,8,22,.4)}
.tm-subtable td{padding:6px 14px;border-bottom:1px solid rgba(32,55,92,.2);color:rgba(194,206,224,.85);vertical-align:middle}
.tm-subtable tbody tr:hover{background:rgba(32,55,92,.14)}

/* ── Unmatched TGS table ───────────────────────────────────────────────────── */
.orphan-tgs-wrap{padding:0 4px}
.orphan-tgs-list{display:flex;flex-direction:column}
.orphan-tgs-row{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:8px 14px;border-bottom:1px solid rgba(32,55,92,.5)}
.orphan-tgs-row:last-child{border-bottom:none}
.orphan-tgs-row:hover{background:rgba(244,181,63,.06)}
.orphan-tgs-name{font-size:13.5px;color:var(--muted);flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}