
:root{
  --bg:#0b1220;
  --panel:#111a2e;
  --panel2:#0f182b;
  --text:#e8eefc;
  --muted:#9bb0d3;
  --border:rgba(255,255,255,.08);
  --accent:#5b8cff;
}

body{
  background: var(--bg);
  color: var(--text);
}

a{ color:#d7e5ff; }
a:hover{ color:#ffffff; }

.app-shell{
  display:flex;
  min-height:100vh;
}

.sidebar{
  width:270px;
  background: linear-gradient(180deg, #0f1830, #0b1220);
  border-right: 1px solid var(--border);
  position: sticky;
  top:0;
  height:100vh;
  padding:16px;
  overflow-y:auto;
  overscroll-behavior: contain;
}

/* nicer scrollbars (optional) */
.sidebar::-webkit-scrollbar{ width:8px; }
.sidebar::-webkit-scrollbar-thumb{ background: rgba(255,255,255,.12); border-radius: 10px; }
.sidebar::-webkit-scrollbar-track{ background: rgba(255,255,255,.04); }

.sidebar-brand{
  display:flex;
  align-items:center;
  gap:12px;
  padding:8px 6px 16px;
  border-bottom:1px solid var(--border);
  margin-bottom:12px;
}
.brand-icon{
  width:40px;height:40px;
  display:grid;place-items:center;
  background: rgba(91,140,255,.15);
  border:1px solid rgba(91,140,255,.35);
  border-radius:12px;
  color: var(--accent);
  font-size:18px;
}
.brand-title{ font-weight:700; letter-spacing:.2px;}
.brand-sub{ font-size:12px;color:var(--muted); }

.sidebar-nav{
  display:flex;
  flex-direction:column;
  gap:6px;
  padding-top:10px;
}

.nav-item{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 12px;
  border-radius:12px;
  text-decoration:none;
  color: var(--text);
  border:1px solid transparent;
  transition:.15s;
}
.nav-item i{opacity:.9;}
.nav-item:hover{
  background: rgba(255,255,255,.04);
  border-color: var(--border);
}
.nav-divider{
  height:1px;
  background: var(--border);
  margin:10px 0;
}
.nav-danger{
  color:#ffd2d2;
}
.nav-danger:hover{ background:rgba(255,0,0,.08); }

.content{
  flex:1;
  min-width:0;
}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:14px 18px;
  border-bottom:1px solid var(--border);
  background: rgba(17,26,46,.65);
  backdrop-filter: blur(8px);
}
.page-title{
  font-weight:700;
}
.user-pill{
  padding:8px 12px;
  border-radius:999px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.03);
  color: var(--text);
  font-size:14px;
}

.card-dark{
  background: rgba(17,26,46,.9);
  border:1px solid var(--border);
  border-radius:16px;
}
.card-glass{
  background: rgba(17,26,46,.6);
  border:1px solid var(--border);
  border-radius:16px;
}
.modal-dark{
  background: rgba(17,26,46,.96);
  border:1px solid var(--border);
  color: var(--text);
}
.modal-dark .modal-header{ border-bottom:1px solid var(--border); }
.modal-dark .modal-footer{ border-top:1px solid var(--border); }

.table-darkish{
  --bs-table-bg: rgba(255,255,255,.02);
  --bs-table-striped-bg: rgba(255,255,255,.03);
  --bs-table-color: var(--text);
  --bs-table-border-color: var(--border);
  border-color: var(--border);
}

.form-control, .form-select{
  background: rgba(255,255,255,.03);
  border:1px solid var(--border);
  color: var(--text);
}
.form-control:focus, .form-select:focus{
  background: rgba(255,255,255,.04);
  border-color: rgba(91,140,255,.55);
  box-shadow: 0 0 0 .2rem rgba(91,140,255,.15);
  color: var(--text);
}
.form-text{ color: var(--muted); }

.btn-outline-light{
  border-color: var(--border);
  color: var(--text);
}
.btn-outline-light:hover{
  border-color: rgba(255,255,255,.18);
}

.btn-primary{
  background: var(--accent);
  border-color: var(--accent);
}

.auth-shell{
  min-height:100vh;
  display:grid;
  place-items:center;
  padding:24px;
}
.auth-card{
  width:100%;
  max-width:420px;
  background: rgba(17,26,46,.9);
  border:1px solid var(--border);
  border-radius:18px;
  padding:22px;
}
.auth-logo{
  width:64px;height:64px;
  border-radius:18px;
  display:grid;place-items:center;
  background: rgba(91,140,255,.12);
  border:1px solid rgba(91,140,255,.25);
  font-size:28px;
  color: var(--accent);
  margin:0 auto 10px;
}

.stat-strip{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
}
.stat-chip{
  flex:1;
  min-width:170px;
  padding:12px 14px;
  background: rgba(255,255,255,.03);
  border:1px solid var(--border);
  border-radius:16px;
}
.stat-label{ color: var(--muted); font-size:12px;}
.stat-value{ font-weight:800; font-size:18px; }

.mini-stat{
  padding:10px 12px;
  background: rgba(255,255,255,.03);
  border:1px solid var(--border);
  border-radius:14px;
}
.mini-label{ color: var(--muted); font-size:12px;}
.mini-value{ font-weight:800; font-size:16px; }

/* Daily Calculation - Mobile friendly form rows (no horizontal drag) */
@media (max-width: 768px){
  #linesTable thead{ display:none; }
  #linesTable tbody, #linesTable tr, #linesTable td{ display:block; width:100%; }
  #linesTable tbody tr{
    border:1px solid var(--border);
    border-radius:16px;
    padding:10px 12px;
    margin-bottom:12px;
    background: rgba(255,255,255,.02);
  }
  #linesTable tbody td{
    padding:8px 0;
    border:0;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:10px;
  }
  #linesTable tbody td:before{
    content: attr(data-label);
    font-weight:700;
    color: var(--muted);
    min-width:110px;
  }
  #linesTable tbody td[data-label=""]:before{ content:''; min-width:0; }
  #linesTable .form-control, #linesTable .form-select{ width: 62%; }
}
.mini-sub{ color: var(--muted); font-size:12px; margin-top:2px; }

.svc-logo{
  width:34px;
  height:34px;
  border-radius:10px;
  object-fit:cover;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.04);
}
.svc-logo.placeholder{
  display:grid;place-items:center;
}

.chip-check{
  position:relative;
  display:inline-flex;
  align-items:center;
  gap:10px;
  padding:8px 12px;
  border-radius:999px;
  background: rgba(255,255,255,.03);
  border:1px solid var(--border);
  cursor:pointer;
  user-select:none;
  font-size:13px;
}
.chip-check input{ display:none; }
.chip-check span{ color: var(--text); }
.chip-check:has(input:checked){
  border-color: rgba(91,140,255,.55);
  background: rgba(91,140,255,.12);
}
.chip-check.chip-danger:has(input:checked){
  border-color: rgba(255,99,99,.5);
  background: rgba(255,99,99,.12);
}

.idcard-card{
  text-decoration:none;
  overflow:hidden;
}
.idcard-thumb{
  height:160px;
  overflow:hidden;
  background: rgba(255,255,255,.02);
  border-bottom:1px solid var(--border);
  display:grid;
  place-items:center;
}
.idcard-thumb img{
  width:100%;
  height:100%;
  object-fit:cover;
}
.idcard-placeholder{
  color: var(--muted);
  text-align:center;
}
.idcard-placeholder i{ font-size:32px; }

.img-box{
  border:1px solid var(--border);
  border-radius:14px;
  padding:10px;
  background: rgba(255,255,255,.02);
}
.img-box img{
  width:100%;
  border-radius:10px;
  border:1px solid rgba(255,255,255,.08);
}

.smart-results .item{
  padding:10px 12px;
  border-radius:14px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.02);
  margin-bottom:8px;
  display:flex;
  justify-content:space-between;
  gap:12px;
  align-items:center;
}
.smart-results .meta{ color: var(--muted); font-size:12px; }

.list-group-dark .list-group-item{
  background: rgba(255,255,255,.02);
  border-color: var(--border);
  color: var(--text);
}

.accordion-dark .accordion-item{
  background: rgba(255,255,255,.02);
  border:1px solid var(--border);
  border-radius:14px;
  overflow:hidden;
  margin-bottom:10px;
}
.accordion-dark .accordion-button{
  background: rgba(255,255,255,.02);
  color: var(--text);
  border:0;
}
.accordion-dark .accordion-button:not(.collapsed){
  background: rgba(91,140,255,.12);
}
.accordion-dark .accordion-body{
  border-top:1px solid var(--border);
}

@media (max-width: 768px){
  .sidebar{
    position:fixed;
    left:-290px;
    z-index:1040;
    transition: .2s;
  }
  .sidebar.show{
    left:0;
  }
  .topbar{ position:sticky; top:0; z-index:1030; }
}

.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple{
  background: rgba(255,255,255,.03) !important;
  border:1px solid var(--border) !important;
  border-radius: 12px !important;
  min-height: 38px;
}
.select2-container--default .select2-selection--single .select2-selection__rendered,
.select2-container--default .select2-selection--multiple .select2-selection__rendered{
  color: var(--text) !important;
}
.select2-dropdown{
  background: rgba(17,26,46,.98) !important;
  border:1px solid var(--border) !important;
  color: var(--text);
}
.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable{
  background: rgba(91,140,255,.25) !important;
}
/* =========================
   Dark Theme Readability Fix
   ========================= */

/* Label / headings */
body:not(.theme-light) .form-label,
body:not(.theme-light) label,
body:not(.theme-light) .card-title,
body:not(.theme-light) .card-header,
body:not(.theme-light) h1,body:not(.theme-light) h2,body:not(.theme-light) h3,body:not(.theme-light) h4,body:not(.theme-light) h5,body:not(.theme-light) h6 {
  color: rgba(255,255,255,.92) !important;
}

/* Normal text */
body:not(.theme-light), body:not(.theme-light) .card, body:not(.theme-light) .card-body, body:not(.theme-light) .modal-content {
  color: rgba(255,255,255,.88) !important;
}

/* Muted text (Installer page, help texts etc.) */
body:not(.theme-light) .text-muted, body:not(.theme-light) small, body:not(.theme-light) .form-text {
  color: rgba(255,255,255,.65) !important;
}

/* Inputs: text + background */
body:not(.theme-light) .form-control,
body:not(.theme-light) .form-select,
body:not(.theme-light) .input-group-text {
  color: rgba(255,255,255,.92) !important;
  background-color: rgba(255,255,255,.06) !important;
  border-color: rgba(255,255,255,.14) !important;
}

/* Placeholder (dark only) */
body:not(.theme-light) .form-control::placeholder {
  color: rgba(255,255,255,.45) !important;
}

/* Table text (dark only) */
body:not(.theme-light) .table, body:not(.theme-light) .table th, body:not(.theme-light) .table td {
  color: rgba(255,255,255,.88) !important;
}
/* =========================
   Fix: Select dropdown options not visible
   ========================= */

/* Native select dropdown options */
select.form-select option,
select.form-control option,
select.form-select optgroup,
select.form-control optgroup {
  color: #0b1220 !important;         /* option text dark */
  background-color: #ffffff !important; /* option bg white */
}


/* ===== Light Theme (optional) ===== */
body.theme-light{
  --bg:#f4f6f8;
  --panel:#ffffff;
  --panel2:#ffffff;
  --text:#111827;
  --muted: rgba(0,0,0,.55);
  --border: rgba(0,0,0,.12);
  background: #f4f6f8;
  color: #111827;
}
body.theme-light .topbar,
body.theme-light .sidebar{
  background: #ffffff;
  border-color: rgba(0,0,0,.08);
}
body.theme-light .sidebar .nav-item{
  color: rgba(0,0,0,.75);
}
body.theme-light .sidebar .nav-item:hover,
body.theme-light .sidebar .nav-item.active{
  background: rgba(0,0,0,.05);
  color: rgba(0,0,0,.85);
}
body.theme-light .nav-title{
  color: rgba(0,0,0,.55);
}
body.theme-light .main{
  background: transparent;
}
body.theme-light .card-dark,
body.theme-light .modal-dark{
  background: #ffffff;
  border: 1px solid rgba(0,0,0,.08);
}
body.theme-light .table-darkish{
  --bs-table-bg: #ffffff;
  --bs-table-color: #111827;
  --bs-table-striped-color: #111827;
  --bs-table-striped-bg: rgba(0,0,0,.02);
  --bs-table-hover-color: #111827;
  --bs-table-hover-bg: rgba(0,0,0,.04);
}
body.theme-light .form-control,
body.theme-light .form-select{
  background-color: #ffffff;
  color: #111827;
  border-color: rgba(0,0,0,.20);
}
body.theme-light .form-text{
  color: rgba(0,0,0,.55);
}
body.theme-light .btn-outline-light{
  color: rgba(0,0,0,.80);
  border-color: rgba(0,0,0,.20);
}
body.theme-light .btn-outline-light:hover{
  background: rgba(0,0,0,.05);
}
body.theme-light .mini-stat{
  background: #ffffff;
  border: 1px solid rgba(0,0,0,.08);
}
body.theme-light .mini-label{
  color: rgba(0,0,0,.55);
}
body.theme-light .mini-value{
  color: #111827;
}
body.theme-light .text-muted{
  color: rgba(0,0,0,.55) !important;
}
body.theme-light .user-pill{
  border-color: rgba(0,0,0,.12);
}
body.theme-light .select2-container--default .select2-selection--single,
body.theme-light .select2-container--default .select2-selection--multiple{
  background-color: #ffffff;
  border-color: rgba(0,0,0,.20);
  color: #111827;
}
body.theme-light .select2-container--default .select2-selection--single .select2-selection__rendered{
  color: #111827;
}
body.theme-light .select2-dropdown{
  background: #ffffff !important;
  border-color: rgba(0,0,0,.20) !important;
  color: #111827 !important;
}
body.theme-light .select2-results__option{
  color: #111827 !important;
}

/* Capital form polish */
#capTxForm .form-text{ margin-top: 4px; }
#capTxForm .form-label{ font-weight: 600; }
#capTxForm .form-control, #capTxForm .form-select{ min-height: 42px; }
#capTxForm{ row-gap: 12px; }
