/* =========================
   GLOBAL RESET & BASE
========================= */

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

/* VIENĪGAIS GLOBĀLAIS BACKGROUND */
body {
    min-height: 100vh;
    background: #eef2f7;
    background-attachment: fixed;
    color: #0f172a;
}

/* page-bg vairs nekontrolē fonu */
.page-bg {
    background: transparent;
}

/* noņemam vecos bootstrap paneļus */
.panel,
.panel-default,
.panel-info,
.panel-body,
.panel-heading {
    background: transparent !important;
    border: none !important;
}

/* =========================
   AUTH (login / register)
========================= */

.page-auth {
    min-height: 100vh;
    background: linear-gradient(135deg, #4e73df, #1cc88a);
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-box {
    background: #ffffff;
    color: #111827;
    padding: 30px;
    border-radius: 6px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.auth-box h3 {
    text-align: center;
    margin-bottom: 25px;
}

/* =========================
   LAYOUT
========================= */

.container {
    background: transparent;
}

.content-box {
    padding-top: 30px;
    padding-bottom: 30px;
}

/* Navbar */
.custom-navbar {
    border-radius: 0;
    margin-bottom: 0;
}

/* =========================
   TABLES – DARK DASHBOARD
========================= */

.table-dark-list {
    background: transparent;
    color: #0f172a;
    margin-bottom: 0;
}

.table-dark-list thead th {
    border-bottom: 1px solid #d5dde8;
    color: #334155;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
}

.table-dark-list tbody tr {
    transition: background .15s ease, box-shadow .15s ease;
    cursor: pointer;
}

.table-dark-list tbody tr:nth-child(odd) {
    background: #f8fafc;
}

.table-dark-list tbody tr:nth-child(even) {
    background: #f1f5f9;
}

.table-dark-list tbody tr:hover {
    background: #e0e7ff;
    box-shadow: inset 0 0 0 1px #c7d2fe;
}

.table-dark-list tbody tr:hover td {
    color: #0f172a;
}

.table-dark-list td {
    border-top: none;
    vertical-align: middle;
}

.table-dark-list strong {
    color: #0f172a;
}

.table-dark-list .text-muted {
    color: #64748b !important;
}

/* =========================
   RESPONSIVE
========================= */

@media (max-width: 768px) {

    .auth-box {
        padding: 20px;
    }

    .custom-navbar {
        padding: 10px;
    }

    .table td {
        font-size: 14px;
    }

    th:nth-child(4),
    td:nth-child(4) {
        display: none;
    }
}

@media (max-width: 480px) {

    .auth-box {
        padding: 15px;
    }

    .table td {
        font-size: 12px;
    }

    .btn,
    .form-control {
        padding: 12px;
        font-size: 14px;
    }
    select.form-control {
        height: 44px;
        padding: 10px 36px 10px 12px;
        line-height: 1.4;
    }
}
/* =========================
   FORCE DARK TABLE OVERRIDE
========================= */

.table-dark-list,
.table-dark-list thead,
.table-dark-list tbody,
.table-dark-list tr,
.table-dark-list th,
.table-dark-list td {
    background: transparent !important;
    color: #0f172a !important;
}

.table-dark-list thead th {
    border-bottom: 1px solid #d5dde8 !important;
    color: #334155 !important;
}

.table-dark-list tbody tr {
    background: #f8fafc !important;
}

.table-dark-list tbody tr:nth-child(even) {
    background: #f1f5f9 !important;
}

.table-dark-list tbody tr:hover {
    background: #e0e7ff !important;
}

.table-dark-list td {
    border-top: none !important;
}

.table-dark-list strong {
    color: #0f172a !important;
}

.table-dark-list .text-muted {
    color: #64748b !important;
}


:root{
    --bg:#eef2f7;
    --card:#ffffff;
    --border:#d5dde8;
    --text:#0f172a;
    --muted:#64748b;
    --accent:#16a34a;
    --warn:#f59e0b;
    --danger:#ef4444;
}

body.page-bg{
    background:#eef2f7;
    color:var(--text);
    font-family: system-ui,-apple-system,Segoe UI,Roboto,sans-serif;
}

.navbar-inverse {
    background-image: none;
    background-color: #fff;
    border-color: #d5dde8;
}
.navbar-inverse .navbar-brand,
.navbar-inverse .navbar-nav > li > a,
.navbar-inverse .navbar-text,
.navbar-inverse .navbar-text a {
    color: #0f172a !important;
}
.navbar-inverse .navbar-nav > li > a:hover,
.navbar-inverse .navbar-nav > li > a:focus,
.navbar-inverse .navbar-brand:hover {
    color: #2563eb !important;
    background: transparent;
}
.navbar-inverse .navbar-toggle {
    border-color: #cbd5e1;
}
.navbar-inverse .navbar-toggle .icon-bar {
    background-color: #334155;
}
.navbar-inverse .navbar-collapse {
    border-color: #d5dde8;
}
.navbar-inverse .navbar-nav > .open > a,
.navbar-inverse .navbar-nav > .open > a:hover,
.navbar-inverse .navbar-nav > .open > a:focus,
.navbar-inverse .navbar-nav > .active > a,
.navbar-inverse .navbar-nav > .active > a:hover,
.navbar-inverse .navbar-nav > .active > a:focus {
    background-color: #e2e8f0;
    color: #0f172a;
}

.card{
    background:#fff;
    border:1px solid #d5dde8;
    border-radius:16px;
    padding:20px;
    margin-bottom:24px;
    box-shadow:0 8px 24px rgba(15,23,42,.06);
}

.card > h3{
    margin:-20px -20px 18px;
    padding:13px 20px 12px;
    font-size:15px;
    font-weight:650;
    letter-spacing:.03em;
    color:#0f172a;
    background:#f4f7fb;
    border-bottom:1px solid #d5dde8;
    border-radius:16px 16px 0 0;
}

.form-control{
    background:#fff;
    border:1px solid var(--border);
    color:var(--text);
    border-radius:10px;
}

select.form-control {
    -webkit-appearance: none;
    appearance: none;
    height: 42px;
    padding: 8px 36px 8px 12px;
    line-height: 1.4;
    background-color: #fff;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748b' d='M1.2 1.2l4.8 4.8 4.8-4.8'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px 8px;
}

.form-control:focus,
.form-control[readonly]:focus{
    border-color:#38bdf8;
    box-shadow:0 0 0 3px rgba(56,189,248,.2);
}

.form-control[readonly]{
    background:#fff !important;
    color:var(--text) !important;
    opacity:1;
    cursor:pointer;
}

label{color:var(--muted);font-weight:500}

.btn{
    border-radius:10px;
    border:none;
    font-weight:500;
}

.btn-success{background:var(--accent)}
.btn-warning{background:var(--warn);color:#000}
.btn-danger{background:var(--danger)}
.btn-secondary{background:#e2e8f0;color:#0f172a}

hr{border-color:#d5dde8}

/* TIMELINE */
.timeline{list-style:none;padding:0;margin:0}
.timeline li{
    display:grid;
    grid-template-columns:120px 1fr;
    gap:16px;
    margin-bottom:16px;
}
.timeline time{
    font-size:12px;
    color:var(--muted);
    text-align:right;
}
.timeline-card{
    background:#f8fafc;
    border:1px solid var(--border);
    border-radius:12px;
    padding:12px 48px 12px 14px;
    position:relative;
}
.timeline-card strong{display:block;margin-bottom:4px}
.timeline-card .log-delete{
    position:absolute;
    top:10px;
    right:10px;
}

.history-timeline{
    position:relative;
    margin:12px 0 4px;
    padding:8px 0 20px;
}
.history-timeline:before{
    content:"";
    position:absolute;
    left:13px;
    top:8px;
    bottom:16px;
    width:2px;
    background:linear-gradient(to bottom,#14b8a6,#94a3b8);
}
.history-year,
.history-date-mark{
    position:relative;
    z-index:2;
    display:table;
    margin:8px 0 14px 0;
    padding:4px 14px;
    border-radius:999px;
    font-weight:700;
    letter-spacing:.04em;
    text-align:center;
}
.history-year{
    background:#0f766e;
    color:#ecfdf5;
    font-size:13px;
    box-shadow:0 0 0 4px #fff;
}
.history-date-mark{
    background:#e2e8f0;
    color:#0f172a;
    font-size:12px;
    border:1px solid #cbd5e1;
    box-shadow:0 0 0 4px #fff;
    margin-top:4px;
    margin-bottom:10px;
}
.history-item{
    position:relative;
    width:100%;
    padding:24px 0 22px 36px;
    box-sizing:border-box;
}
.history-dot{
    position:absolute;
    top:24px;
    left:7px;
    width:13px;
    height:13px;
    border-radius:50%;
    background:#64748b;
    border:3px solid #fff;
    box-shadow:0 0 0 2px #64748b;
    z-index:2;
}
.history-item-apkope .history-dot{background:#22c55e;box-shadow:0 0 0 2px #22c55e}
.history-item-whatsapp .history-dot{background:#25d366;box-shadow:0 0 0 2px #25d366}
.history-item-sms .history-dot{background:#38bdf8;box-shadow:0 0 0 2px #38bdf8}
.history-item-atgadinajums .history-dot{background:#94a3b8;box-shadow:0 0 0 2px #94a3b8}
.history-item-rinda .history-dot{background:#3b82f6;box-shadow:0 0 0 2px #3b82f6}
.history-item-atlikta .history-dot{background:#f59e0b;box-shadow:0 0 0 2px #f59e0b}
.history-item-piezime .history-dot{background:#a78bfa;box-shadow:0 0 0 2px #a78bfa}
.history-item-maksajums .history-dot{background:#14b8a6;box-shadow:0 0 0 2px #14b8a6}
.history-item-lokacija .history-dot{background:#0d7377;box-shadow:0 0 0 2px #0d7377}
.history-card-wrap{
    position:relative;
}
.history-who{
    position:absolute;
    left:7px;
    top:-22px;
    z-index:2;
    margin:0;
    padding:3px 41px 4px;
    max-width:calc(100% - 72px);
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
    background:#f8fafc;
    border:1px solid var(--border);
    border-radius:8px 8px 0 0;
    font-size:11px;
    font-weight:600;
    color:#64748b;
    line-height:1.25;
}

/* DANGER */
.danger{
    background:rgba(239,68,68,.08);
    border:1px solid rgba(239,68,68,.45);
}
.danger > h3{
    background:linear-gradient(180deg, rgba(239,68,68,.24), rgba(239,68,68,.08));
    box-shadow:inset 3px 0 0 #ef4444;
}
.image-grid{
    display:grid;
    grid-template-columns:repeat(auto-fill,minmax(120px,1fr));
    gap:12px;
}

.image-grid a{
    display:block;
    border-radius:12px;
    overflow:hidden;
    border:1px solid var(--border);
}

.image-grid img{
    width:100%;
    height:120px;
    object-fit:cover;
    transition:.2s;
}

.image-grid img:hover{
    transform:scale(1.05);
}

.upload-box{
    border:2px dashed var(--border);
    border-radius:14px;
    padding:16px;
    text-align:center;
    color:var(--muted);
}
.alphabet-bar{
    display:flex;
    flex-wrap:wrap;
    justify-content:center;
    gap:6px;
}

@media (max-width:768px){
    body .container{
        max-width:100% !important;
        padding-left:4px !important;
        padding-right:4px !important;
    }
}
.readonly-field {
    background-color: #f0f0f0;
    pointer-events: none;
    opacity: 0.6;
}

.date-unknown-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.date-picker-wrap {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
}

.date-picker-wrap .form-control {
    width: 100%;
    cursor: pointer;
}

.date-unknown-row.is-unknown .form-control {
    cursor: default;
}

.lv-cal {
    position: absolute;
    left: 0;
    top: calc(100% + 6px);
    z-index: 50;
    width: 272px;
    max-width: calc(100vw - 32px);
    background: #fff;
    border: 1px solid #d5dde8;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 16px 40px rgba(15,23,42,.12);
}

.lv-cal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.lv-cal-title {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.lv-cal-month {
    font-weight: 600;
    color: #0f172a;
    font-size: 13px;
    text-transform: capitalize;
    white-space: nowrap;
}

.lv-cal-year {
    -webkit-appearance: none;
    appearance: none;
    background: #fff !important;
    color: #0f172a !important;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 4px 22px 4px 8px;
    font-weight: 700;
    font-size: 13px;
    line-height: 1.3;
    cursor: pointer;
    color-scheme: light;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%230f172a' d='M1 1l5 5 5-5'/></svg>");
    background-repeat: no-repeat;
    background-position: right 7px center;
}

.lv-cal-year:focus {
    outline: none;
    border-color: #38bdf8;
}

.lv-cal-nav,
.lv-cal-grid button {
    -webkit-appearance: none;
    appearance: none;
}

.lv-cal-nav {
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 8px;
    background: #f1f5f9;
    color: #0f172a;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.lv-cal-nav:hover {
    background: #e2e8f0;
}

.lv-cal-week,
.lv-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    text-align: center;
}

.lv-cal-week span {
    font-size: 11px;
    color: #94a3b8;
    padding: 4px 0;
    font-weight: 600;
}

.lv-cal-grid button {
    border: 0;
    background: transparent;
    color: #0f172a;
    border-radius: 8px;
    height: 32px;
    cursor: pointer;
}

.lv-cal-grid button.is-muted {
    color: #64748b;
}

.lv-cal-grid button.is-today {
    box-shadow: inset 0 0 0 1px #38bdf8;
}

.lv-cal-grid button.is-selected {
    background: #38bdf8;
    color: #0f172a;
    font-weight: 700;
}

.lv-cal-grid button:hover {
    background: rgba(56, 189, 248, .2);
}

.lv-cal-grid button.is-selected:hover {
    background: #7dd3fc;
}

.date-unknown-check {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.date-unknown-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0 12px;
    min-width: 92px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--muted);
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.02em;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.date-unknown-pill:hover {
    border-color: #38bdf8;
    color: #0f172a;
}

.date-unknown-check:focus + .date-unknown-pill {
    box-shadow: 0 0 0 3px rgba(56, 189, 248, .2);
}

.date-unknown-check:checked + .date-unknown-pill,
.date-unknown-row.is-unknown .date-unknown-pill {
    background: rgba(56, 189, 248, .16);
    border-color: #38bdf8;
    color: #0369a1;
}

.date-unknown-row.is-unknown .form-control {
    opacity: .55;
}

.priv-search-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
    margin-bottom: 12px;
}
.priv-search-row .form-control {
    flex: 1 1 auto;
    min-width: 0;
}
.priv-search-row .btn {
    flex: 0 0 auto;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
}
.priv-search-hint,
.priv-search-empty {
    color: var(--muted);
    padding: 10px 2px 4px;
}
.priv-search-empty {
    color: #fbbf24;
}
mark {
    background: #ffe58a;
    color: #111827;
    padding: 1px 3px;
    border-radius: 3px;
}
.priv-letter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 18px;
}
.priv-letter-head {
    margin: 28px 0 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
    font-size: 20px;
    font-weight: 700;
    color: #1e3a8a;
    scroll-margin-top: 16px;
}
.priv-letter-head:first-of-type {
    margin-top: 8px;
}
.priv-list-table {
    table-layout: fixed;
    width: 100%;
    margin-bottom: 0;
}
.priv-list-table .priv-letter-col {
    width: 42px;
}
.priv-list-table th,
.priv-list-table td {
    vertical-align: middle;
}
.priv-list-table .priv-letter-cell {
    width: 42px;
    font-size: 20px;
    font-weight: 700;
    color: #1e3a8a;
    vertical-align: top;
    padding-top: 12px;
    scroll-margin-top: 12px;
    border-top: 1px solid #d5dde8 !important;
    cursor: default;
}
.priv-list-table tr.priv-letter-start td {
    border-top: 1px solid #d5dde8 !important;
}
.birka-ocr-file {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    pointer-events: none;
}
.birka-name-wrap {
    position: relative;
    display: flex;
    align-items: stretch;
    gap: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}
.ocr-sn-wrap {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
}
#birkaNameWrap.is-ocr-progress::after,
.ocr-sn-wrap.is-ocr-progress::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    height: 2px;
    width: var(--ocr-pct, 8%);
    background: linear-gradient(90deg, #38bdf8, #7dd3fc);
    border-radius: 0 1px 1px 0;
    pointer-events: none;
    z-index: 2;
    transition: width .12s linear;
}
.birka-name-wrap:focus-within {
    border-color: #38bdf8;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, .2);
}
.birka-name-wrap:has(.is-ocr-filled) {
    border-color: #38bdf8;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, .28);
}
.birka-name-wrap .form-control {
    flex: 1 1 auto;
    min-width: 0;
    border: 0 !important;
    border-radius: 0;
    box-shadow: none !important;
    background: transparent;
}
.birka-photo-btn {
    -webkit-appearance: none;
    appearance: none;
    flex: 0 0 auto;
    width: 42px;
    min-height: 38px;
    margin: 0;
    padding: 0;
    border: 0;
    border-left: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
    color: #64748b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.birka-photo-btn:hover,
.birka-name-wrap.is-busy .birka-photo-btn {
    color: #fff;
    background: #2563eb;
}
.birka-name-wrap.is-busy .birka-photo-btn {
    pointer-events: none;
}
#gpsAddressWrap.is-busy .birka-photo-btn .glyphicon {
    animation: gps-pulse 0.8s ease-in-out infinite;
}
@keyframes gps-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .35; }
}
.birka-hint {
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(15, 23, 42, .45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.birka-hint[hidden] {
    display: none !important;
}
.birka-hint-box {
    width: 100%;
    max-width: 360px;
    background: #fff;
    border: 1px solid #d5dde8;
    border-radius: 14px;
    padding: 20px 18px 16px;
    text-align: center;
    color: #0f172a;
    box-shadow: 0 16px 40px rgba(15,23,42,.18);
}
.birka-hint-box p {
    margin: 0 0 16px;
    font-size: 15px;
    line-height: 1.45;
}
.birka-hint-box .btn {
    margin: 0 4px 6px;
}
.form-control.is-ocr-running {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.04em;
    color: #0369a1;
}
.form-control.is-ocr-filled,
select.is-ocr-filled {
    border-color: #38bdf8;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, .28);
}

@media (max-width: 480px) {
    .priv-search-row {
        flex-wrap: wrap;
    }
    .priv-search-row .form-control {
        flex: 1 1 100%;
    }
    .priv-search-row .btn {
        flex: 1 1 calc(50% - 4px);
        justify-content: center;
        width: auto;
    }
}