/* =========================================================
   Baasstiil. Värvid CSS muutujatena -- vaheta neid, kui
   saadad lõpliku värvilahenduse.
   ========================================================= */

:root {
    /* Tavero brändivärvid */
    --color-primary: #002376;       /* tumesinine (logo tekst) */
    --color-primary-dark: #001a5c;
    --color-accent-blue: #0089e9;   /* erksinine (logo gradient) */
    --color-accent-orange: #ff5e0a; /* oranž (logo linnuke) */

    --color-bg: #f5f6f8;
    --color-surface: #ffffff;
    --color-border: #e2e4e9;
    --color-text: #1a1d23;
    --color-text-muted: #6b7280;
    --color-success-bg: #e7f8ee;
    --color-success-text: #157347;
    --color-error-bg: #fdecec;
    --color-error-text: #b42318;
    --color-warning-bg: #fff4ec;
    --color-warning-text: #b8420a;

    --status-planned-bg: #eef0f3;
    --status-planned-text: #4b5563;
    --status-active-bg: #e6f2fd;
    --status-active-text: #0089e9;
    --status-paused-bg: #fff0e6;
    --status-paused-text: #ff5e0a;
    --status-done-bg: #dcfce7;
    --status-done-text: #157347;

    --radius: 8px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
}

/* ---- Sisselogimine / setup ---- */

.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-box {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 32px;
    width: 360px;
}

.login-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
}

.login-logo img {
    width: 36px;
    height: auto;
}

.login-logo span {
    font-weight: 800;
    font-size: 20px;
    color: var(--color-primary);
}

.login-box h1 {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text-muted);
    margin: 0 0 20px;
}

/* ---- Vormid (ühine) ---- */

form label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-muted);
    margin: 14px 0 4px;
}

form input,
form select {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 14px;
    color: var(--color-text);
}

form input:focus,
form select:focus {
    outline: none;
    border-color: var(--color-accent-blue);
    box-shadow: 0 0 0 3px rgba(0, 137, 233, 0.15);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

button, .btn {
    cursor: pointer;
    border: none;
    border-radius: 6px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
}

.btn-primary, button[type="submit"] {
    background: var(--color-accent-orange);
    color: #fff;
}

.btn-primary:hover, button[type="submit"]:hover {
    background: #e0530a;
}

.btn-secondary {
    background: var(--color-bg);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn-success {
    background: #2ea44f;
    color: #fff;
    border: 1px solid #2c9a49;
}
.btn-success:hover { background: #2c9a49; }
.btn-success:disabled { opacity: .9; cursor: default; }

.login-box button[type="submit"] {
    width: 100%;
    margin-top: 20px;
}

/* ---- Teated ---- */

.alert {
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 16px;
}

.alert-success { background: var(--color-success-bg); color: var(--color-success-text); }
.alert-error   { background: var(--color-error-bg);   color: var(--color-error-text); }
.alert-warning { background: var(--color-warning-bg); color: var(--color-warning-text); }

/* ---- Paigutus ---- */

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

.sidebar {
    width: 92px;
    background: #12152a;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
    flex-shrink: 0;
}

.sidebar-logo {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    overflow: hidden;
}

.sidebar-logo img {
    width: 30px;
    height: auto;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: 1;
    width: 100%;
}

.sidebar-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    width: 76px;
    padding: 10px 4px;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.5);
    text-decoration: none;
    font-size: 11px;
    font-weight: 500;
    text-align: center;
}

.sidebar-nav a svg {
    width: 20px;
    height: 20px;
}

.sidebar-nav a:hover {
    color: rgba(255, 255, 255, 0.85);
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-nav a.active {
    color: #ffffff;
    background: var(--color-accent-blue);
}

.sidebar-footer {
    margin-top: auto;
}

.sidebar-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--color-accent-orange);
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    padding: 0;
}

/* Ettevõtete vahetaja hüpik (telefoni-OTP sisselogimine) */
.sidebar-avatar-wrap { position: relative; }
.company-menu {
    position: absolute;
    left: calc(100% + 10px);
    bottom: 0;
    min-width: 230px;
    background: #fff;
    border: 1px solid #e4e7ec;
    border-radius: 12px;
    box-shadow: 0 12px 34px rgba(16, 24, 40, .18);
    padding: 6px;
    z-index: 100;
}
.company-menu-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    color: #98a2b3;
    padding: 8px 10px 6px;
}
.company-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    border: none;
    background: none;
    border-radius: 8px;
    padding: 9px 10px;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    color: #101828;
    position: relative;
}
.company-menu-item:hover { background: #f4f6f9; }
.company-menu-item.is-active { background: #eaf3ff; }
.company-menu-item.is-active::before {
    content: "";
    position: absolute;
    left: 0; top: 6px; bottom: 6px;
    width: 3px; border-radius: 3px;
    background: var(--color-accent-blue);
}
.company-menu-ini {
    width: 28px; height: 28px; border-radius: 7px; flex-shrink: 0;
    background: #eef1f6; color: #344054;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700;
}
.company-menu-item.is-active .company-menu-ini { background: var(--color-accent-blue); color: #fff; }
.company-menu-name { font-weight: 600; white-space: nowrap; }
.company-menu-logout {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    border-top: 1px solid #eef1f4;
    margin-top: 4px;
    padding: 11px 12px 8px;
    color: #d92d20;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
}
.company-menu-logout:hover { color: #b42318; }
.company-menu-logout svg { width: 17px; height: 17px; }

.content {
    flex: 1;
    min-width: 0; /* lubab sisual kokku tõmbuda -> lai tabel kerib enda sees, mitte kogu leht */
    padding: 28px 32px;
}

/* Grid-lehed (objektid): sisu täidab viewport'i kõrguse, tabel kerib enda sees,
   horisontaalne kerimisriba jääb lehe alaserva. */
.content--grid {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    padding-bottom: 16px;
}

.content--grid .obj-grid-wrapper {
    flex: 1;
    min-height: 0;
    overflow: auto;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.page-header h1 {
    font-size: 22px;
    margin: 0;
}

.page-subtitle {
    font-size: 13px;
    color: var(--color-text-muted);
    margin-top: 4px;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--color-text-muted);
    margin-bottom: 12px;
}

.breadcrumb a {
    color: var(--color-accent-blue);
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.modal-subtitle {
    font-size: 13px;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}

/* ---- Filtririba ---- */

.filter-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.filter-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 8px 12px;
    min-width: 220px;
}

.filter-permit {
    min-width: 160px;
}

.filter-search svg {
    width: 16px;
    height: 16px;
    color: var(--color-text-muted);
    flex-shrink: 0;
}

.filter-search input {
    border: none;
    padding: 0;
    font-size: 14px;
}

.filter-search input:focus {
    outline: none;
    box-shadow: none;
}

.filter-select {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 14px;
    color: var(--color-text);
}

.filter-date {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 12px;
    color: var(--color-text-muted);
}

.filter-date input {
    border: none;
    padding: 0;
    font-size: 13px;
    color: var(--color-text);
}

.filter-date input:focus {
    outline: none;
    box-shadow: none;
}

.filter-submit {
    padding: 9px 16px;
}

.filter-clear {
    font-size: 13px;
    color: var(--color-text-muted);
    text-decoration: none;
    padding: 0 4px;
}

.filter-clear:hover {
    color: var(--color-error-text);
}

/* ---- Objekti vaate sakid ---- */

.tab-bar {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 20px;
}

.tab-bar a {
    padding: 10px 16px;
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.tab-bar a:hover {
    color: var(--color-text);
}

.tab-bar a.active {
    color: var(--color-accent-blue);
    border-bottom-color: var(--color-accent-blue);
}

.tab-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.info-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px;
}

.info-label {
    font-size: 12px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 6px;
}

.info-value {
    font-size: 18px;
    font-weight: 600;
}

.checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 6px;
    max-height: 180px;
    overflow-y: auto;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 10px;
}

#objectsPickerBlock {
    margin-top: 4px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 400;
    color: var(--color-text);
    margin: 0;
}

.checkbox-item input {
    width: auto;
}

button:disabled, .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.inline-form {
    display: flex;
    align-items: center;
    gap: 6px;
}

.inline-select {
    padding: 6px 8px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 13px;
    max-width: 160px;
}

.btn-small {
    padding: 6px 10px;
    font-size: 12px;
    white-space: nowrap;
}

/* Uste juhtimise nupud (Seadmed tabel) */
.door-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.door-msg { margin-top: 5px; font-size: 12px; min-height: 1.1em; color: var(--color-text-muted); }
.door-msg.ok { color: var(--color-success-text); }
.door-msg.err { color: var(--color-error-text); }

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    color: var(--color-text-muted);
    cursor: pointer;
}

.btn-icon svg {
    width: 15px;
    height: 15px;
}

.btn-icon:hover {
    background: var(--color-bg);
    color: var(--color-accent-blue);
    border-color: var(--color-accent-blue);
}

.page-hint {
    font-size: 13px;
    color: var(--color-text-muted);
    margin: -8px 0 16px;
}

.table-wrapper {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th {
    text-align: left;
    padding: 12px 16px;
    background: var(--color-bg);
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--color-border);
    vertical-align: top;
    white-space: nowrap;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.row-clickable {
    cursor: pointer;
}

.row-clickable:hover {
    background: var(--color-bg);
}

.cell-title {
    font-weight: 600;
}

.cell-subtitle {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-top: 2px;
}

.cell-strong {
    font-weight: 600;
}

.empty-state {
    text-align: center;
    color: var(--color-text-muted);
    padding: 32px !important;
}

/* ---- Staatuse märgid ---- */

.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.status-planned { background: var(--status-planned-bg); color: var(--status-planned-text); }
.status-active  { background: var(--status-active-bg);  color: var(--status-active-text); }
.status-paused  { background: var(--status-paused-bg);  color: var(--status-paused-text); }
.status-done    { background: var(--status-done-bg);    color: var(--status-done-text); }

/* ===== Uksed / Läbipääsupunktid ===== */
.uks-table th { background: var(--color-surface); }

/* Loenduri märk pealkirja kõrval */
.count-badge {
    display: inline-block;
    min-width: 20px;
    padding: 1px 8px;
    margin-left: 6px;
    border-radius: 999px;
    background: #eef0f3;
    color: var(--color-text-muted);
    font-size: 13px;
    font-weight: 600;
    vertical-align: middle;
}

/* ===== Seadmed ===== */
.dev-name-form { display: flex; align-items: center; gap: 8px; }
.dev-name-input {
    width: auto;
    min-width: 190px;
    padding: 7px 10px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 14px;
}
.dev-muted { color: var(--color-text-muted); }
.dev-online { display: inline-flex; align-items: center; }
.dev-offline { color: var(--color-text-muted); }

.dev-badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 6px;
    background: #eef0f3;
    color: var(--color-text-muted);
    font-size: 12px;
    font-weight: 600;
}
.dev-badge-ok { background: var(--color-success-bg); color: var(--color-success-text); }
.dev-badge-danger { background: var(--color-error-bg); color: var(--color-error-text); }
.uks-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 7px;
    vertical-align: middle;
}
.uks-dot.is-on  { background: #22a35a; }
.uks-dot.is-off { background: #c7ccd6; }

.sync-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}
.sync-synced   { background: var(--color-success-bg); color: var(--color-success-text); }
.sync-pending  { background: #fef3c7; color: #92400e; }
.sync-deleting,
.sync-failed   { background: var(--color-error-bg); color: var(--color-error-text); }

.uks-actions { display: flex; gap: 8px; }
.btn-icon-danger { color: var(--color-error-text); }
.btn-icon-danger:hover {
    background: var(--color-error-bg);
    color: var(--color-error-text);
    border-color: #f0c4c0;
}

/* ---- Muuda läbipääsupunkti -- lai modaal ---- */
.modal-box.modal-box-uks { width: min(1120px, 95vw); }

.uks-form-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px 18px;
    margin-bottom: 8px;
}
.uks-field { min-width: 0; }
.uks-field label { margin-top: 4px; }
.uks-field input,
.uks-field select { width: 100%; }
.uks-hint { font-size: 12px; color: var(--color-text-muted); margin: 6px 0 0; line-height: 1.4; }

.uks-collapse {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    padding: 10px 0;
    margin-top: 4px;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    cursor: pointer;
}
.uks-collapse-chev { width: 16px; height: 16px; color: var(--color-text-muted); transition: transform .18s ease; }
.uks-collapse.is-collapsed .uks-collapse-chev { transform: rotate(-90deg); }

.uks-extra[hidden] { display: none; }
.uks-modal-actions { justify-content: flex-start; }

@media (max-width: 1080px) {
    .uks-form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
    .uks-form-grid { grid-template-columns: 1fr 1fr; }
}

/* ---- Modaal ---- */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-overlay.open {
    display: flex;
}

.modal-box {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 28px;
    width: 420px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-box h2 {
    margin: 0 0 4px;
    font-size: 18px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
}

/* =========================================================
   Objekti Töölaud (dashboard) vaade
   ========================================================= */

.object-topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--color-surface);
    margin: -28px -32px 20px;
    padding: 18px 32px;
    border-bottom: 1px solid var(--color-border);
}

.back-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--color-bg);
    color: var(--color-text);
    flex-shrink: 0;
}

.back-arrow svg {
    width: 18px;
    height: 18px;
}

.back-arrow:hover {
    background: var(--color-border);
}

.object-topbar-title {
    font-size: 22px;
    margin: 0;
    white-space: nowrap;
}

.object-section-nav {
    display: flex;
    gap: 4px;
    flex: 1;
}

.object-section-nav a {
    padding: 8px 14px;
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    border-bottom: 2px solid transparent;
}

.object-section-nav a:hover {
    color: var(--color-text);
}

.object-section-nav a.active {
    color: var(--color-accent-orange);
    border-bottom-color: var(--color-accent-orange);
}

.object-tv-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.object-tv-btn svg {
    width: 16px;
    height: 16px;
}
.object-tv-btn .tv-chev { width: 14px; height: 14px; opacity: .6; margin-left: 2px; }

.tv-drop { position: relative; flex-shrink: 0; }
.tv-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 120;
    min-width: 250px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(16, 24, 40, .16);
    padding: 6px;
}
.tv-menu[hidden] { display: none; }
.tv-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    width: 100%;
    padding: 11px 12px;
    background: transparent;
    border: none;
    border-radius: 7px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    color: var(--color-text);
    text-align: left;
    cursor: pointer;
}
.tv-menu-item:hover { background: var(--color-bg); }
.tv-menu-info { width: 16px; height: 16px; flex-shrink: 0; color: var(--color-text-muted); }

/* ===== TV-seinavaade (täisekraan) ===== */
.tv-fs {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    background: #eef1f5;
    color: #1a1d23;
    font-family: Lato, "Trebuchet MS", sans-serif;
}
.tv-fs[hidden] { display: none; }

.tv-fs-close {
    position: absolute;
    top: 14px;
    right: 16px;
    z-index: 5;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, .1);
    color: #9aa1ad;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    opacity: .35;
    transition: opacity .15s;
}
.tv-fs-close:hover { opacity: 1; background: rgba(0, 0, 0, .12); color: #333; }
.tv-fs-close svg { width: 18px; height: 18px; }

.tv-fs-side {
    width: 236px;
    flex-shrink: 0;
    background: #14161c;
    color: #fff;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.tv-fs-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 11px;
    font-size: 28px;
    font-weight: 800;
    padding: 26px 22px 20px;
    letter-spacing: .2px;
}
.tv-fs-logo-mark { width: 40px; height: 40px; display: block; object-fit: contain; flex-shrink: 0; }

.tv-fs-clock { padding: 10px 22px 24px; text-align: center; }
.tv-fs-date { font-size: 17px; font-weight: 600; margin-bottom: 2px; }
.tv-fs-time { font-size: 46px; font-weight: 700; line-height: 1; letter-spacing: 1px; }
.tv-fs-time sup { font-size: 18px; font-weight: 600; margin-left: 2px; top: -1.1em; }

.tv-fs-stat {
    padding: 18px 22px;
    border-top: 1px solid rgba(255, 255, 255, .08);
    text-align: center;
}
.tv-fs-stat-label { font-size: 14px; color: #aeb4c0; margin-bottom: 6px; }
.tv-fs-stat-num { font-size: 34px; font-weight: 700; line-height: 1.05; }
.tv-fs-stat-num.yellow { color: #f4c430; }
.tv-fs-stat-num.green { color: #46c46a; }
.tv-fs-stat-sub { font-size: 12px; color: #8a90a0; margin-top: 6px; line-height: 1.35; }

.tv-fs-chart { margin-top: 12px; display: grid; grid-template-columns: 22px 1fr; grid-template-rows: 56px auto; gap: 2px 6px; }
.tv-fs-chart-yaxis {
    grid-column: 1; grid-row: 1;
    display: flex; flex-direction: column; justify-content: space-between;
    font-size: 10px; color: #6b7180; text-align: right;
}
.tv-fs-chart-bars {
    grid-column: 2; grid-row: 1;
    display: flex; align-items: flex-end; gap: 3px; height: 56px;
    border-left: 1px solid rgba(255,255,255,.12); border-bottom: 1px solid rgba(255,255,255,.12);
    padding-left: 3px;
    position: relative;
}
.tv-fs-bar { flex: 1; background: #f4c430; border-radius: 1px 1px 0 0; min-height: 2px; cursor: pointer; }
.tv-fs-bar:hover { background: #ffd94a; }
.tv-fs-chart-tip {
    position: absolute;
    transform: translate(-50%, -100%);
    margin-top: -6px;
    background: #fff;
    color: #1f2430;
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 7px;
    padding: 6px 9px;
    font-size: 11px;
    line-height: 1.3;
    white-space: nowrap;
    pointer-events: none;
    z-index: 6;
    box-shadow: 0 6px 18px rgba(0,0,0,.28);
}
.tv-fs-chart-tip .tt-time { font-weight: 700; margin-bottom: 3px; }
.tv-fs-chart-tip .tt-row { display: flex; align-items: center; gap: 6px; color: #4b5160; }
.tv-fs-chart-tip .tt-sq { width: 9px; height: 9px; background: #f4c430; border-radius: 2px; display: inline-block; flex-shrink: 0; }
.tv-fs-chart-xaxis {
    grid-column: 2; grid-row: 2;
    display: flex; justify-content: space-between;
    font-size: 10px; color: #6b7180; padding-left: 3px;
}

.tv-fs-main {
    flex: 1;
    min-width: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    padding: 16px 18px;
    overflow: auto;
    align-content: start;
}
.tv-fs-col {
    background: #fff;
    border: 1px solid #e4e7ec;
    border-radius: 6px;
    overflow: hidden;
    align-self: start;
}

.tv-fs-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.tv-fs-table th {
    background: #f1f3f5;
    color: #7a8190;
    font-weight: 500;
    font-size: 13px;
    text-align: left;
    padding: 11px 16px;
    border-bottom: 1px solid #e4e7ec;
}
.tv-fs-table th.num, .tv-fs-table td.num { text-align: right; width: 76px; white-space: nowrap; }
.tv-fs-table td {
    padding: 10px 16px;
    border-bottom: 1px solid #eef0f3;
}
.tv-fs-table tbody tr:last-child td { border-bottom: none; }
.tv-fs-name { display: flex; align-items: center; gap: 8px; }

.tv-fs-table tr.is-active .tv-fs-name { color: #14161c; font-weight: 700; }
.tv-fs-table tr.is-active td.num { color: #14161c; font-weight: 600; }
.tv-fs-table tr.is-muted .tv-fs-name { color: #aab0ba; font-weight: 400; }
.tv-fs-table tr.is-muted td.num { color: #aab0ba; }

.tv-fs-role {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 20px;
    padding: 0 5px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}
.tv-fs-role-ptv { background: #2f6fed; }
.tv-fs-role-jv  { background: #e0a12e; }
.tv-fs-role-k   { background: #3aab5a; }

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    align-items: start;
}

.dashboard-col {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.dash-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px;
}

.dash-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-border);   /* horisontaalne joon päise alla */
    margin-bottom: 14px;
}

.dash-card-link {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-accent-blue);
    text-decoration: none;
    letter-spacing: normal;
    text-transform: none;
}

.dash-card-link:hover {
    text-decoration: underline;
}

.dash-card-footer-link {
    display: block;
    text-align: center;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--color-border);
    font-size: 13px;
    font-weight: 600;
    color: var(--color-accent-blue);
    text-decoration: none;
}

.dash-card-footer-link:hover {
    text-decoration: underline;
}

.dash-stat-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 18px;
}
.dash-stat { text-align: center; }   /* Ettevõtted / Inimesed lahtri keskel */
/* Vertikaalne joon Ettevõtete ja Inimeste vahel */
.dash-stat + .dash-stat {
    border-left: 1px solid var(--color-border);
    padding-left: 24px;
}

.dash-stat-value {
    font-size: 26px;
    font-weight: 700;
}

.dash-stat-label {
    font-size: 13px;
    font-weight: 600;
    margin-top: 2px;
}

.dash-stat-sub {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-top: 2px;
}

/* Horisontaalne joon "Töötajate arv..." graafiku kohale (eraldab statistikast) */
.dash-chart {
    border-top: 1px solid var(--color-border);
    padding-top: 16px;
}

.dash-chart-title {
    font-size: 12px;
    color: var(--color-text-muted);
    text-align: center;
    margin-bottom: 10px;
}

.dash-chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 90px;
    position: relative;
}
.dash-bar { cursor: pointer; }
.dash-bar:hover { opacity: 0.6; }
.dash-chart-bars .dash-bar-now { opacity: 1; background: var(--color-accent-blue); }
.dash-chart-bars .dash-bar-now:hover { opacity: 0.85; }
.dash-chart-xaxis {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: 6px;
}
.dash-chart-tip {
    position: absolute;
    transform: translate(-50%, -100%);
    margin-top: -6px;
    background: #fff;
    color: #1f2430;
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 7px;
    padding: 6px 9px;
    font-size: 11px;
    line-height: 1.3;
    white-space: nowrap;
    pointer-events: none;
    z-index: 6;
    box-shadow: 0 6px 18px rgba(0,0,0,.22);
}
.dash-chart-tip .tt-time { font-weight: 700; margin-bottom: 3px; }
.dash-chart-tip .tt-row { display: flex; align-items: center; gap: 6px; color: #4b5160; }
.dash-chart-tip .tt-sq { width: 9px; height: 9px; background: var(--color-accent-blue); border-radius: 2px; display: inline-block; flex-shrink: 0; }

.dash-bar {
    flex: 1;
    background: var(--color-accent-blue);
    opacity: 0.35;
    border-radius: 2px 2px 0 0;
    min-height: 3px;
}

.dash-chart-note {
    font-size: 11px;
    color: var(--color-text-muted);
    text-align: center;
    margin-top: 8px;
    font-style: italic;
}

/* ===== Hetkel töömaal -- otsing + ettevõtete nimekiri (Töölaud) ===== */
/* .dash-onsite on nüüd omaette kaardis -- hall vahe tuleb dashboard-col gap'ist */
.dash-onsite {}
.dash-onsite-searchrow { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.dash-onsite-search {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--color-border);
    border-radius: 20px;
    background: var(--color-surface);
}
.dash-onsite-search svg { width: 16px; height: 16px; color: var(--color-text-muted); flex-shrink: 0; }
.dash-onsite-search input { flex: 1; border: none; outline: none; background: none; font-size: 13px; font-family: inherit; color: var(--color-text); }
.dash-onsite-gear {
    width: 38px; height: 38px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 10px;
    color: var(--color-text-muted); cursor: pointer; padding: 0;
}
.dash-onsite-gear:hover { background: var(--color-bg); }
.dash-onsite-gear svg { width: 18px; height: 18px; }

.dash-onsite-list { display: flex; flex-direction: column; }
.dash-onsite-item { border-bottom: 1px solid var(--color-border); }
.dash-onsite-item:last-child { border-bottom: none; }
.dash-onsite-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 2px;
    cursor: pointer;
}
.dash-onsite-row:hover { background: var(--color-bg); border-radius: 8px; }
.dash-onsite-caret {
    flex-shrink: 0;
    width: 22px; height: 22px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: none; border: none; cursor: pointer; color: var(--color-text-muted);
}
.dash-onsite-caret svg { width: 16px; height: 16px; transition: transform .15s ease; }
.dash-onsite-item.open .dash-onsite-caret svg { transform: rotate(90deg); }

/* Laiendatud inimeste tabel */
.dash-onsite-expand { padding: 0 2px 14px; }
.dash-onsite-people { width: 100%; border-collapse: collapse; }
.dash-onsite-people th, .dash-onsite-people td {
    border: 1px solid var(--color-border);
    padding: 9px 12px;
    font-size: 13px;
    text-align: right;
    white-space: nowrap;
}
.dash-onsite-people th {
    background: var(--color-bg);
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-muted);
}
.dash-onsite-people th:first-child, .dash-onsite-people td:first-child { text-align: left; width: 100%; }
.dash-onsite-people td:first-child { font-weight: 600; color: var(--color-text); }
.dash-onsite-pname { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dash-onsite-out {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px; height: 26px;
    flex-shrink: 0;
    border: none;
    background: none;
    border-radius: 6px;
    color: var(--color-text-muted);
    cursor: pointer;
    opacity: 0;
    transition: opacity .12s ease, background .12s ease, color .12s ease;
    padding: 0;
}
.dash-onsite-out svg { width: 16px; height: 16px; }
.dash-onsite-people tr:hover .dash-onsite-out { opacity: 1; }
.dash-onsite-out:hover { background: var(--color-bg); color: var(--color-accent-blue); }
.dash-onsite-out:focus-visible { opacity: 1; outline: 2px solid var(--color-accent-blue); outline-offset: 1px; }
.dash-onsite-out.reg-item-busy { opacity: .4; pointer-events: none; }
.dash-onsite-main { flex: 1; min-width: 0; }
.dash-onsite-name { display: flex; align-items: center; gap: 6px; }
.dash-onsite-nm { font-size: 14px; font-weight: 600; color: var(--color-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-onsite-sub { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; }
.dash-onsite-parent { margin-left: 10px; }
.dash-onsite-count { flex-shrink: 0; text-align: right; }
.dash-onsite-now { font-size: 14px; font-weight: 600; color: var(--color-text); }
.dash-onsite-today { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; }

/* Rollisilt (Töölaua nimekiri) */
.dash-role { display: inline-block; padding: 1px 8px; border-radius: 5px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.dash-role-main { color: var(--color-accent-blue); background: var(--status-active-bg); }
.dash-role-sub { color: var(--color-text-muted); background: var(--color-bg); }

.dash-empty-state {
    font-size: 13px;
    color: var(--color-text-muted);
    text-align: center;
    padding: 20px 10px;
}

/* Ebaõnnestunud läbipääsukatsed */
.dash-fails { display: flex; flex-direction: column; gap: 10px; }
.dash-fail {
    position: relative;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 11px 13px;
}
.dash-fail[hidden] { display: none; }
.dash-fail-top { display: block; }
.dash-fail-title { font-size: 13px; font-weight: 700; color: var(--color-error-text); line-height: 1.2; }
.dash-fail-meta {
    position: absolute;
    top: 11px;
    right: 13px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}
.dash-fail-time { font-size: 12px; color: var(--color-text-muted); }
.dash-fail-count {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-muted);
    background: #eef0f3;
    border-radius: 999px;
    padding: 1px 8px;
}
.dash-fail-card { font-size: 15px; font-weight: 700; color: var(--color-text); margin-top: 2px; letter-spacing: .01em; }
.dash-fail-points { font-size: 12px; color: var(--color-text-muted); margin-top: 3px; }

.dash-status-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    padding: 6px 0 4px;
}

.dash-status-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--color-border);
    color: var(--color-text-muted);
    flex-shrink: 0;
}

.dash-status-icon svg {
    width: 13px;
    height: 13px;
}

.dash-status-icon.ok {
    background: var(--status-done-bg);
    color: var(--status-done-text);
}

/* Läbipääsupunktide loend (Näita läbipääsupunkte) */
.dash-devices {
    margin-top: 8px;
    border-top: 1px solid var(--color-border);
}
.dash-device {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 2px;
    border-bottom: 1px solid var(--color-border);
}
.dash-device:last-child { border-bottom: none; }
.dash-device-num {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.dash-device-main { min-width: 0; }
.dash-device-name { font-size: 14px; font-weight: 600; color: var(--color-text); }
.dash-device-status { font-size: 12px; font-weight: 600; margin-top: 1px; }
.dash-device-status.ok { color: var(--status-done-text); }
.dash-device-status.off { color: var(--color-text-muted); }

.dash-posts {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.dash-post {
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-border);
}

.dash-post:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.dash-post-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}

.dash-post-content {
    font-size: 13px;
    color: var(--color-text);
    white-space: pre-line;
}

.dash-details-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.dash-details-table td {
    padding: 7px 0;
    border-bottom: 1px solid var(--color-border);
}

.dash-details-table tr:last-child td {
    border-bottom: none;
}

.dash-details-table td:first-child {
    color: var(--color-text-muted);
    width: 40%;
}

.dash-placeholder {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 60px 20px;
    text-align: center;
    color: var(--color-text-muted);
}

.dash-placeholder h2 {
    color: var(--color-text);
    margin-bottom: 8px;
}

@media (max-width: 1100px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.dash-extra-block {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dash-sync-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
    border-top: 1px solid var(--color-border);
}

.dash-sync-title {
    font-size: 13px;
    font-weight: 600;
}

.dash-sync-sub {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-top: 2px;
}

/* =========================================================
   Töövõtuahel (hierarhiline ettevõtete puu, tabelina)
   ========================================================= */

.chain-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--color-surface);
    margin: 0 -32px 0;
    padding: 14px 32px;
    border-bottom: 1px solid var(--color-border);
}

.chain-star-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-surface);
    color: var(--color-text-muted);
}

.chain-star-btn svg { width: 16px; height: 16px; }

.chain-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 8px 12px;
    min-width: 220px;
}

.chain-search svg { width: 16px; height: 16px; color: var(--color-text-muted); flex-shrink: 0; }

.chain-search input {
    border: none;
    padding: 0;
    font-size: 14px;
    width: 100%;
}

.chain-filter-btn, .chain-more-btn {
    white-space: nowrap;
}

.chain-toolbar-spacer {
    flex: 1;
}

.chain-excel-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    padding: 9px;
}

.chain-excel-btn svg { width: 16px; height: 16px; }

/* ---- Tabel ---- */

.chain-tree-wrapper {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow-x: auto;
    margin-top: 20px;
}

.chain-header-row,
.chain-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 1180px;
}

.chain-header-row {
    padding: 10px 14px;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-text-muted);
}

.chain-row {
    padding: 9px 14px;
    border-bottom: 1px solid var(--color-border);
    font-size: 13px;
}

.chain-row:hover {
    background: var(--color-bg);
}

.chain-col { flex-shrink: 0; }

.chain-col-check   { width: 18px; }
.chain-col-toggle  { width: 20px; display: flex; align-items: center; }
.chain-col-number  { width: 42px; color: var(--color-text-muted); font-size: 12px; }
.chain-col-name    { flex: 1 1 260px; min-width: 220px; display: flex; align-items: center; gap: 8px; }
.chain-col-visit   { width: 110px; color: var(--color-text-muted); font-size: 12px; }
.chain-col-ttki-status,
.chain-col-ttki-match { width: 100px; color: var(--color-text-muted); font-size: 12px; }
.chain-col-allowed { width: 110px; font-size: 12px; }
.chain-col-rules   { width: 150px; font-size: 12px; color: var(--color-text-muted); }
.chain-col-quals   { width: 170px; font-size: 12px; color: var(--color-text-muted); }
.chain-col-tags    { width: 150px; display: flex; gap: 6px; flex-wrap: wrap; }

.chain-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: transform 0.15s;
}

.chain-toggle-btn svg { width: 14px; height: 14px; }
.chain-toggle-btn.expanded { transform: rotate(90deg); }

.chain-icon {
    width: 16px;
    height: 16px;
    color: var(--color-text-muted);
    flex-shrink: 0;
}

.chain-icon-building {
    color: var(--color-accent-blue);
}

.chain-role-badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}

.chain-role-client { background: #dcfce7; color: #157347; }
.chain-role-main { background: #dbeafe; color: #1d4ed8; }
.chain-role-supervision { background: #fff0e6; color: #ff5e0a; }
.chain-role-sub { background: #eef0f3; color: #4b5563; }

.chain-company-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chain-group-row .chain-company-name {
    font-weight: 500;
    color: var(--color-text-muted);
}

.chain-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

.chain-pill-ok { background: #dcfce7; color: #157347; }
.chain-pill-bad { background: #fdecec; color: #b42318; }

.chain-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    font-size: 11px;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.chain-row-actions {
    display: flex;
    gap: 10px;
}

.chain-row-actions a {
    color: var(--color-accent-blue);
    text-decoration: none;
    font-weight: 600;
    font-size: 12px;
    white-space: nowrap;
}

.chain-row-actions a:hover {
    text-decoration: underline;
}

.chain-children {
    background: rgba(0,0,0,0.012);
}

/* =========================================================
   Seaded (objekti alamnavigatsioon)
   ========================================================= */

.settings-layout {
    display: flex;
    gap: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    min-height: 500px;
}

.settings-sidebar {
    width: 240px;
    flex-shrink: 0;
    border-right: 1px solid var(--color-border);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.settings-sidebar a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--color-text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}

.settings-sidebar a svg {
    width: 18px;
    height: 18px;
    color: var(--color-text-muted);
    flex-shrink: 0;
}

.settings-sidebar a:hover {
    background: var(--color-bg);
}

.settings-sidebar a.active {
    background: #e6f2fd;
    color: var(--color-accent-blue);
}

.settings-sidebar a.active svg {
    color: var(--color-accent-blue);
}

.settings-content {
    flex: 1;
    padding: 24px 28px;
    min-width: 0;
}

.settings-panel-card h2 {
    margin: 0 0 4px;
    font-size: 18px;
}

.settings-toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    margin-top: 16px;
    cursor: pointer;
}

.settings-toggle-row input {
    width: 18px;
    height: 18px;
}

.settings-toggle-on { color: #157347; }
.settings-toggle-off { color: var(--color-text-muted); }

.settings-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 50px 20px;
}

.settings-empty-illustration {
    width: 160px;
    height: auto;
    margin-bottom: 20px;
}

.settings-empty-state h2 {
    font-size: 19px;
    margin: 0 0 8px;
}

.settings-empty-state p {
    font-size: 13px;
    color: var(--color-text-muted);
    max-width: 320px;
    margin: 0 0 20px;
}

.settings-empty-state p a {
    color: var(--color-accent-blue);
    text-decoration: underline;
}

.settings-cta-btn {
    background: #16a34a;
    color: #fff;
    padding: 11px 24px;
    font-size: 14px;
}

/* ---- Tööohutuskoolituse seadistamise viisard (modaal) ---- */
.km-overlay {
    position: fixed;
    inset: 0;
    background: rgba(38, 46, 58, .72);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
}
.km-overlay[hidden] { display: none; }   /* [hidden] peab võitma display:flex üle */
.km-box {
    background: #fff;
    border-radius: 22px;
    width: 100%;
    max-width: 430px;
    padding: 34px 34px 26px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .28);
    text-align: center;
}
.km-box-wide { max-width: 500px; }

/* Aktiveerimise viisardi edenemisriba */
.km-progress {
    width: 120px;
    height: 5px;
    border-radius: 3px;
    background: #e4e7ec;
    margin: 0 auto 22px;
    overflow: hidden;
}
.km-progress span { display: block; height: 100%; background: var(--color-accent-blue); border-radius: 3px; }

/* Märkeruudu-kaardid (allkirjastamisviisid) */
.km-check-card {
    display: flex;
    align-items: center;
    gap: 14px;
    text-align: left;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 16px 18px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: border-color .12s ease, background .12s ease;
}
.km-check-card:hover { border-color: var(--color-accent-blue); background: #f8fbff; }
.km-check-in {
    width: 20px; height: 20px;
    flex-shrink: 0;
    accent-color: var(--color-accent-blue);
    cursor: pointer;
}
.km-check-txt { flex: 1; font-size: 15px; font-weight: 600; color: var(--color-text); }
.km-check-more { display: block; font-size: 13px; font-weight: 400; color: var(--color-text-muted); text-decoration: underline; margin-top: 2px; }
.km-readmore { display: inline-block; font-size: 14px; color: var(--color-text); text-decoration: underline; margin: 0 auto 22px; }

/* Kokkuvõte (kinnitussamm) */
.km-summary { text-align: left; margin: 4px 0 20px; }
.km-summary-row { display: flex; gap: 16px; padding: 14px 2px; border-bottom: 1px solid var(--color-border); }
.km-summary-row:last-child { border-bottom: none; }
.km-summary-k { flex: 0 0 130px; font-size: 14px; color: var(--color-text-muted); }
.km-summary-v { flex: 1; font-size: 14px; font-weight: 700; color: var(--color-text); }

/* Läbipaistev "Tühista" nupp */
.km-btn-plain { background: transparent; color: var(--color-text); }
.km-btn-plain:hover { background: var(--color-bg); }

/* Õnnestumise ikoon + link */
.km-icon-ok { border-color: #2ea44f; color: #2ea44f; }
.km-share-link { color: var(--color-accent-blue); font-weight: 700; text-decoration: none; }
.km-share-link:hover { text-decoration: underline; }

/* Punane -> roheline "läbipääsu" visuaal */
.km-flow { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 4px 0 20px; }
.km-pill {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    padding: 5px 11px;
    border-radius: 8px;
    border: 1px solid;
    white-space: nowrap;
}
.km-pill-red { color: #d92d20; border-color: #f3b9b3; background: #fef3f2; }
.km-pill-green { color: #157347; border-color: #a6e6be; background: #e7f8ee; }
.km-flow-arrow { width: 20px; height: 20px; color: var(--color-text-muted); flex-shrink: 0; }

/* Raadionupu-kaardid (läbipääsu-reegel) */
.km-radio-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    text-align: left;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 16px 18px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: border-color .12s ease, background .12s ease;
}
.km-radio-card:hover { border-color: var(--color-accent-blue); }
.km-radio-in {
    width: 20px; height: 20px;
    flex-shrink: 0;
    margin-top: 1px;
    accent-color: var(--color-accent-blue);
    cursor: pointer;
}
.km-radio-txt { flex: 1; }
.km-radio-title { display: block; font-size: 15px; font-weight: 600; color: var(--color-text); }
.km-radio-desc { display: block; font-size: 13px; color: var(--color-text-muted); line-height: 1.45; margin-top: 3px; }
.km-radio-desc a { color: var(--color-text-muted); text-decoration: underline; }
.km-icon {
    width: 78px;
    height: 78px;
    border-radius: 50%;
    border: 2px solid var(--color-accent-blue);
    color: var(--color-accent-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 18px;
}
.km-icon svg { width: 38px; height: 38px; }
.km-title {
    font-size: 23px;
    font-weight: 800;
    margin: 0 0 10px;
    color: var(--color-text);
}
.km-sub {
    font-size: 14px;
    line-height: 1.5;
    color: var(--color-text-muted);
    margin: 0 auto 22px;
    max-width: 330px;
}
.km-field {
    position: relative;
    text-align: left;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 8px 14px 6px;
    margin-bottom: 20px;
}
.km-field-lbl {
    display: block;
    font-size: 11px;
    color: var(--color-text-muted);
    margin-bottom: 2px;
}
.km-select {
    width: 100%;
    border: none;
    outline: none;
    background: transparent;
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text);
    font-family: inherit;
    appearance: none;
    -webkit-appearance: none;
    padding-right: 24px;
    cursor: pointer;
}
.km-field-chev {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--color-text-muted);
    pointer-events: none;
}
.km-btn {
    display: block;
    width: 100%;
    border: none;
    border-radius: 12px;
    padding: 15px;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    margin-top: 10px;
    transition: background .12s ease;
}
.km-btn-primary { background: #2ea44f; color: #fff; }
.km-btn-primary:hover { background: #2c9a49; }
.km-btn-ghost { background: var(--color-bg); color: var(--color-text); }
.km-btn-ghost:hover { background: #e9edf2; }
.km-info {
    text-align: left;
    margin-bottom: 18px;
}
.km-info-row {
    display: flex;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid var(--color-border);
}
.km-info-row:first-child { padding-top: 4px; }
.km-info-k {
    flex: 0 0 116px;
    font-size: 13px;
    color: var(--color-text-muted);
    padding-top: 1px;
}
.km-info-v { flex: 1; }
.km-info-v strong { display: block; font-size: 14px; color: var(--color-text); }
.km-info-hint {
    display: block;
    font-size: 12px;
    color: var(--color-text-muted);
    line-height: 1.45;
    margin-top: 3px;
}
.km-files {
    text-align: left;
    margin-bottom: 14px;
    max-height: 168px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.km-file {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 9px 12px;
}
.km-file svg { width: 18px; height: 18px; color: var(--color-accent-blue); flex-shrink: 0; }
.km-file-name { flex: 1; font-size: 13px; color: var(--color-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.km-file-size { font-size: 12px; color: var(--color-text-muted); flex-shrink: 0; }

/* ---- Tööohutuskoolituse haldusvaade ---- */
.tr-manage { max-width: 640px; }

.tr-activate {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 16px 18px;
    margin-bottom: 26px;
}
.tr-activate-icon {
    flex-shrink: 0;
    width: 26px; height: 26px;
    color: var(--color-text-muted);
}
.tr-activate.is-active .tr-activate-icon { color: #2ea44f; }
.tr-activate-icon svg { width: 26px; height: 26px; }
.tr-activate-dot {
    flex-shrink: 0;
    width: 9px; height: 9px;
    border-radius: 50%;
    background: #f79009;
    margin-top: 6px;
    align-self: flex-start;
}
.tr-activate.is-active .tr-activate-dot { background: #f79009; }
.tr-share-link { color: var(--color-accent-blue); font-weight: 700; text-decoration: none; }
.tr-share-link:hover { text-decoration: underline; }

/* Teavituste kaart (aktiveeritud vaates) */
.tr-notify-card { max-width: 640px; margin-bottom: 26px; }
.tr-notify-field { position: relative; margin-bottom: 8px; }
.tr-notify-hint { font-size: 13px; color: var(--color-text-muted); margin: 0 2px; line-height: 1.45; }

/* Külaliste ikoon (kollakas) */
.tr-mat-ava-guest { background: #fef3d6; color: #b7791f; }

/* Aktiveeritud vaate lisaseaded (TEADMISTE KONTROLL, ALLKIRJAD) */
.tr-setting-card { max-width: 640px; margin-bottom: 26px; }
.tr-setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 16px 18px;
}
.tr-setting-name { font-size: 15px; font-weight: 600; color: var(--color-text); }
.tr-setting-hint { font-size: 13px; color: var(--color-text-muted); line-height: 1.5; margin: 10px 2px 0; }
.tr-setting-hint a { color: var(--color-text-muted); text-decoration: underline; }

/* Allkirjastamismeetodite rippmenüü */
.tr-signdrop { max-width: 640px; position: relative; margin-bottom: 12px; }
.tr-signdrop-trigger {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    text-align: left;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 12px 16px;
    cursor: pointer;
    font-family: inherit;
}
.tr-signdrop-trigger:hover { border-color: var(--color-accent-blue); }
.tr-signdrop-main { flex: 1; min-width: 0; }
.tr-signdrop-lbl { display: block; font-size: 12px; color: var(--color-text-muted); }
.tr-signdrop-val { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; color: var(--color-text); margin-top: 2px; }
.tr-signdrop-badge {
    flex-shrink: 0;
    min-width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--color-accent-blue);
    color: #fff;
    font-size: 12px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0 5px;
}
.tr-signdrop-chev { width: 20px; height: 20px; color: var(--color-text-muted); flex-shrink: 0; transition: transform .15s ease; }
.tr-signdrop.open .tr-signdrop-chev { transform: rotate(180deg); }
.tr-signdrop-panel {
    position: absolute;
    left: 0; right: 0; top: calc(100% + 6px);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .12);
    padding: 6px;
    z-index: 30;
}
.tr-signdrop-panel[hidden] { display: none; }
.tr-signdrop-opt {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 9px;
    cursor: pointer;
    font-size: 15px;
    color: var(--color-text);
}
.tr-signdrop-opt:hover { background: var(--color-bg); }
.tr-signdrop-opt input { width: 18px; height: 18px; accent-color: var(--color-accent-blue); cursor: pointer; }
.tr-activate-main { flex: 1; min-width: 0; }
.tr-activate-title { font-size: 15px; font-weight: 700; color: var(--color-text); }
.tr-activate-sub { font-size: 13px; color: var(--color-text-muted); line-height: 1.45; margin-top: 3px; }
.tr-activate-btn {
    flex-shrink: 0;
    border: none;
    border-radius: 9px;
    background: #86df9d;
    color: #0d3f1c;
    font-weight: 700;
    font-size: 14px;
    padding: 10px 22px;
    cursor: pointer;
    font-family: inherit;
    transition: background .12s ease;
}
.tr-activate-btn:hover { background: #6fd589; }
.tr-activate-btn:disabled { opacity: .6; cursor: default; }
.tr-activate.is-active .tr-activate-btn { background: var(--color-bg); color: var(--color-text); }

.tr-section-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .04em;
    color: var(--color-text-muted);
    margin: 0 2px 10px;
}

.tr-mat-card {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    text-align: left;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 16px 18px;
    cursor: pointer;
    font-family: inherit;
    margin-bottom: 12px;
    transition: border-color .12s ease, background .12s ease;
}
.tr-mat-card:hover { border-color: var(--color-accent-blue); background: #f8fbff; }
.tr-mat-ava {
    flex-shrink: 0;
    width: 40px; height: 40px;
    border-radius: 10px;
    background: #eef1f6;
    color: #344054;
    display: flex; align-items: center; justify-content: center;
}
.tr-mat-ava svg { width: 20px; height: 20px; }
.tr-mat-main { flex: 1; min-width: 0; }
.tr-mat-name { display: block; font-size: 15px; font-weight: 700; color: var(--color-text); }
.tr-mat-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--color-text-muted); margin-top: 3px; }
.tr-mat-dot { color: var(--color-border); }
.tr-mat-lang { display: inline-flex; align-items: center; gap: 4px; }
.tr-mat-lang svg { width: 14px; height: 14px; }
.tr-mat-chev { width: 20px; height: 20px; color: var(--color-text-muted); flex-shrink: 0; }

.tr-add-card {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    text-align: left;
    background: transparent;
    border: 1px dashed var(--color-border);
    border-radius: 12px;
    padding: 16px 18px;
    cursor: pointer;
    font-family: inherit;
    transition: border-color .12s ease;
}
.tr-add-card:hover { border-color: var(--color-accent-blue); }
.tr-add-plus {
    flex-shrink: 0;
    width: 40px; height: 40px;
    border-radius: 10px;
    background: #eef1f6;
    color: #667085;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; font-weight: 500;
}
.tr-add-main { flex: 1; min-width: 0; }
.tr-add-name { display: block; font-size: 15px; font-weight: 700; color: var(--color-text); }
.tr-add-sub { display: block; font-size: 13px; color: var(--color-text-muted); line-height: 1.45; margin-top: 3px; }
.tr-add-optional { color: var(--color-accent-blue); font-weight: 600; }
.tr-add-sub a { color: var(--color-text-muted); text-decoration: underline; }

/* ---- Muuda materjale (paremalt avanev paneel) ---- */
.tr-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(16, 24, 40, .35);
    opacity: 0;
    transition: opacity .2s ease;
    z-index: 1200;
}
.tr-drawer-overlay.open { opacity: 1; }
.tr-drawer-overlay[hidden] { display: none; }
.tr-drawer {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 380px;
    max-width: 92vw;
    background: var(--color-surface);
    box-shadow: -12px 0 40px rgba(0, 0, 0, .16);
    z-index: 1201;
    display: flex;
    flex-direction: column;
    transform: translateX(120%);
    transition: transform .22s ease, right .22s ease;
}
.tr-drawer.open { transform: translateX(0); }
.tr-drawer[hidden] { display: none; }
.tr-drawer-detail { z-index: 1202; }
.tr-drawer-lang { z-index: 1203; width: 420px; }

/* Materjalide ülevaate paneel */
.tr-ov-head-main { flex: 1; min-width: 0; }
.tr-ov-version { font-size: 12px; color: var(--color-text-muted); margin-top: 1px; }
.tr-ov-edit {
    flex-shrink: 0;
    width: 40px; height: 40px;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
}
.tr-ov-edit:hover { background: var(--color-bg); }
.tr-ov-edit svg { width: 18px; height: 18px; }
.tr-ov-details { display: flex; flex-direction: column; }
.tr-ov-row { display: flex; gap: 16px; padding: 13px 2px; border-bottom: 1px solid var(--color-border); }
.tr-ov-k { flex: 0 0 120px; font-size: 14px; color: var(--color-text-muted); }
.tr-ov-v { flex: 1; font-size: 14px; color: var(--color-text); }
.tr-ov-badge {
    display: inline-block;
    font-size: 12px; font-weight: 700;
    color: #1d4ed8; background: #dbeafe;
    padding: 3px 9px; border-radius: 6px;
}
.tr-ov-by { display: block; font-size: 13px; color: var(--color-text-muted); font-weight: 400; margin-top: 2px; }
.tr-drawer-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}
.tr-drawer-x {
    border: none;
    background: transparent;
    color: var(--color-text);
    cursor: pointer;
    padding: 4px;
    display: inline-flex;
    border-radius: 8px;
}
.tr-drawer-x:hover { background: var(--color-bg); }
.tr-drawer-x svg { width: 22px; height: 22px; }
.tr-drawer-title { font-size: 17px; font-weight: 700; margin: 0; }
.tr-drawer-body { padding: 12px 16px; overflow-y: auto; flex: 1; }
.tr-drawer-list { display: flex; flex-direction: column; }

.tr-file-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 8px;
    border-bottom: 1px solid var(--color-border);
}
.tr-file-num { flex-shrink: 0; width: 18px; text-align: center; font-size: 14px; color: var(--color-text-muted); }
.tr-file-badge {
    flex-shrink: 0;
    width: 38px; height: 44px;
    border-radius: 6px;
    display: flex; align-items: flex-end; justify-content: center;
    padding-bottom: 5px;
    font-size: 9px; font-weight: 800; letter-spacing: .02em;
    color: #fff;
    background: #98a2b3;
}
.tr-badge-pdf { background: #e2453b; }
.tr-badge-doc { background: #2b6cb0; }
.tr-badge-ppt { background: #d24726; }
.tr-badge-xls { background: #217346; }
.tr-badge-img { background: #7a5af8; }
.tr-file-main { flex: 1; min-width: 0; }
.tr-file-name { display: block; font-size: 14px; font-weight: 600; color: var(--color-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-file-lang { display: block; font-size: 13px; color: var(--color-text-muted); margin-top: 2px; }
.tr-file-del {
    flex-shrink: 0;
    border: none; background: transparent; cursor: pointer;
    color: var(--color-text-muted); padding: 6px; border-radius: 7px;
    display: inline-flex;
}
.tr-file-del:hover { background: #fdecea; color: #d92d20; }
.tr-file-del svg { width: 18px; height: 18px; }
.tr-file-open { flex-shrink: 0; color: var(--color-text-muted); display: inline-flex; padding: 4px; }
.tr-file-open svg { width: 18px; height: 18px; }

.tr-upload-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--color-border);
    padding: 16px 8px;
    cursor: pointer;
    font-family: inherit;
}
.tr-upload-row:hover { background: #f8fbff; }
.tr-upload-plus {
    flex-shrink: 0;
    width: 38px; height: 38px;
    border-radius: 8px;
    background: #eef1f6;
    color: #667085;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
}
.tr-upload-main { flex: 1; min-width: 0; }
.tr-upload-name { display: block; font-size: 14px; font-weight: 700; color: var(--color-text); }
.tr-upload-sub { display: block; font-size: 13px; color: var(--color-text-muted); margin-top: 2px; line-height: 1.4; }
.tr-drawer-busy { padding: 14px 8px; font-size: 13px; color: var(--color-text-muted); }
.tr-drawer-busy[hidden] { display: none; }

/* Loendirea klikitavus + lohistuskäepide */
.tr-file-clickable { cursor: pointer; }
.tr-file-clickable:hover { background: #f8fbff; }
.tr-file-num-sp { flex-shrink: 0; width: 18px; }
.tr-file-chev { flex-shrink: 0; }
.tr-file-drag {
    flex-shrink: 0;
    border: none; background: transparent; cursor: grab;
    color: var(--color-text-muted); padding: 4px; display: inline-flex;
}
.tr-file-drag:active { cursor: grabbing; }
.tr-file-drag svg { width: 18px; height: 18px; }
.tr-file-row.tr-dragging { opacity: .5; background: var(--color-bg); }

/* Detailpaneel (Muuda materjali) -- avaneb loendipaneelist paremale */
/* Keelevaliku paneeli otsing + loend */
.tr-lang-search {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 16px;
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: var(--color-bg);
    flex-shrink: 0;
}
.tr-lang-search svg { width: 18px; height: 18px; color: var(--color-text-muted); flex-shrink: 0; }
.tr-lang-search input { border: none; outline: none; background: transparent; font-size: 15px; font-family: inherit; color: var(--color-text); width: 100%; }
.tr-lang-list { display: flex; flex-direction: column; }
.tr-lang-row {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--color-border);
    padding: 15px 8px;
    cursor: pointer;
    font-family: inherit;
}
.tr-lang-row:hover { background: #f8fbff; }
.tr-lang-flag { flex-shrink: 0; width: 30px; display: flex; align-items: center; justify-content: center; }
.tr-lang-flag svg {
    width: 28px; height: 19px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, .1);
    display: block;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .08);
}
.tr-lang-name { flex: 1; font-size: 15px; font-weight: 600; color: var(--color-text); }

.tr-add-trans { margin-top: 8px; }
.tr-delete-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 26px;
    padding: 14px;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: var(--color-surface);
    color: #d92d20;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background .12s ease;
}
.tr-delete-btn:hover { background: #fdecea; border-color: #f3c6c1; }
.tr-delete-btn svg { width: 18px; height: 18px; }

/* ---- Mobiilirakenduse seadete kaardid ---- */

.settings-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}

.settings-card-label {
    display: block;
    font-size: 12px;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}

.settings-card-value {
    font-size: 15px;
    font-weight: 700;
}

.settings-card-select {
    border: none;
    padding: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--color-text);
    background: transparent;
    cursor: pointer;
    width: auto;
}

.settings-card-select:focus {
    outline: none;
    box-shadow: none;
}

.settings-card-hint {
    font-size: 12px;
    color: var(--color-text-muted);
    margin: 10px 0 0;
    padding-top: 10px;
    border-top: 1px solid var(--color-border);
    line-height: 1.5;
}

.settings-card-hint a {
    color: var(--color-accent-blue);
    text-decoration: underline;
}

/* ===== Objektimeeskond -- Tööohutuse koordinaatori valik ===== */
.coord-card {
    max-width: 520px;
    padding: 0;
    overflow: hidden;
}
.coord-select { position: relative; }
.coord-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 16px;
    background: transparent;
    border: none;
    border-radius: 0;
    cursor: pointer;
    font-family: inherit;
    font-size: 15px;
    text-align: left;
    color: var(--color-text);
}
.coord-trigger:disabled { cursor: default; }
.coord-value { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.coord-placeholder { color: var(--color-text-muted); font-weight: 400; }
.coord-chev { width: 18px; height: 18px; flex-shrink: 0; color: var(--color-text-muted); transition: transform .18s ease; }
.coord-select.open .coord-chev { transform: rotate(180deg); }

.coord-hint {
    font-size: 12px;
    color: var(--color-text-muted);
    line-height: 1.5;
    margin: 0;
    padding: 12px 16px 16px;
    border-top: 1px solid var(--color-border);
}
.coord-hint[hidden] { display: none; }

.coord-panel { border-top: 1px solid var(--color-border); }
.coord-panel[hidden] { display: none; }
.coord-search {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px;
    padding: 8px 11px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
}
.coord-search:focus-within {
    border-color: var(--color-accent-blue);
    box-shadow: 0 0 0 3px rgba(0, 137, 233, .12);
}
.coord-search svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--color-text-muted); }
.coord-search input {
    border: none;
    outline: none;
    width: 100%;
    background: transparent;
    font-size: 14px;
    font-family: inherit;
    color: var(--color-text);
}
.coord-list { max-height: 380px; overflow-y: auto; }
.coord-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 13px 16px;
    background: transparent;
    border: none;
    border-radius: 0;
    border-top: 1px solid var(--color-border);
    font-size: 14px;
    font-weight: 400;
    font-family: inherit;
    color: var(--color-text);
    cursor: pointer;
}
.coord-item:first-child { border-top: none; }
.coord-item:hover { background: var(--color-bg); }
.coord-item.is-active { background: #eaf3ff; font-weight: 600; }
.coord-item-clear { color: var(--color-text-muted); font-style: italic; }
.coord-empty { padding: 14px; text-align: center; color: var(--color-text-muted); font-size: 13px; }

/* ===== Läbipääs (Seaded) -- seadete kaardid ja reeglid ===== */
.acc-settings { max-width: 560px; }

.acc-field-card { padding: 0; overflow: visible; }
.acc-field { position: relative; }
.acc-field-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: transparent;
    border: none;
    border-radius: var(--radius) var(--radius) 0 0;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    color: var(--color-text);
}
.acc-field-btn:disabled { cursor: default; }
.acc-field-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.acc-field-label { font-size: 12px; color: var(--color-text-muted); }
.acc-field-value {
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.acc-field-placeholder { font-weight: 700; color: var(--color-text); }
.acc-field-chev { width: 18px; height: 18px; flex-shrink: 0; color: var(--color-text-muted); transition: transform .18s ease; }
.acc-field.open .acc-field-chev { transform: rotate(180deg); }

.acc-field-menu {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    z-index: 20;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(16, 24, 40, .12);
    padding: 4px;
    overflow: hidden;
}
.acc-field-menu[hidden] { display: none; }
.acc-field-opt {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    color: var(--color-text);
    cursor: pointer;
}
.acc-field-opt:hover { background: var(--color-bg); }
.acc-field-opt.is-active { background: #eaf3ff; font-weight: 700; position: relative; }
.acc-field-opt.is-active::before { content: ""; position: absolute; left: 0; top: 6px; bottom: 6px; width: 3px; border-radius: 3px; background: var(--color-accent-blue); }

.acc-field-hint {
    font-size: 12px;
    color: var(--color-text-muted);
    line-height: 1.5;
    margin: 0;
    padding: 12px 16px 16px;
    border-top: 1px solid var(--color-border);
}
.acc-field-hint a { color: var(--color-accent-blue); text-decoration: underline; }

.acc-rules-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin: 22px 0 10px;
}

.acc-rules-card { padding: 0; overflow: hidden; }
.acc-rule-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
}
.acc-rule-row:hover { background: var(--color-bg); }
.acc-rule-star { flex-shrink: 0; color: #f0a500; display: flex; }
.acc-rule-star svg { width: 18px; height: 18px; }
.acc-rule-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.acc-rule-name { font-size: 15px; font-weight: 600; color: var(--color-text); }
.acc-rule-sub { font-size: 12px; color: var(--color-text-muted); }
.acc-rule-chev { width: 18px; height: 18px; flex-shrink: 0; color: var(--color-text-muted); }

.acc-rules-hint {
    font-size: 12px;
    color: var(--color-text-muted);
    line-height: 1.5;
    margin: 0;
    padding: 12px 16px 16px;
}
.acc-rules-hint a { color: var(--color-accent-blue); text-decoration: underline; }
.acc-rule-empty { padding: 16px; font-size: 14px; color: var(--color-text-muted); border-bottom: 1px solid var(--color-border); }
.acc-rule-def {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 999px;
    background: #eef0f3;
    color: var(--color-text-muted);
    font-size: 11px;
    font-weight: 600;
    vertical-align: middle;
}

/* ===== Läbipääsureegli muutmise sahtel ===== */
.rule-edit .pe-body { padding-bottom: 24px; overflow-y: auto; }
.rule-edit [hidden] { display: none !important; }
.rr-points-row .pe-row-txt { gap: 4px; }
.rr-points { display: flex; align-items: center; gap: 8px; }
.rr-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--color-accent-blue);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}
.rr-points strong { font-size: 15px; font-weight: 600; }
.rr-ap-row { justify-content: flex-start; }
.rr-ap-row .pe-row-txt { flex: 1; }
.rr-muted { color: var(--color-text-muted); font-weight: 600; font-size: 15px; }
.rr-info { width: 18px; height: 18px; color: var(--color-text-muted); flex-shrink: 0; }

.rr-toggle-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
}
.rr-toggle-txt { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.rr-toggle-txt strong { font-size: 15px; font-weight: 600; color: var(--color-text); }
.rr-toggle-txt span { font-size: 13px; color: var(--color-text-muted); line-height: 1.4; }

.rr-switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; cursor: pointer; }
.rr-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.rr-slider {
    position: absolute;
    inset: 0;
    background: #c7ccd6;
    border-radius: 999px;
    transition: background .18s ease;
}
.rr-slider::before {
    content: "";
    position: absolute;
    left: 3px;
    top: 3px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: transform .18s ease;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .25);
}
.rr-switch input:checked + .rr-slider { background: var(--color-accent-blue); }
.rr-switch input:checked + .rr-slider::before { transform: translateX(18px); }

.rr-add-row { border-top: none !important; }
.rr-add-ic {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text);
}
.rr-add-ic svg { width: 20px; height: 20px; }

/* Graafiku kokkuvõtte rida (kui graafik on määratud) */
.rr-sched-summary { cursor: pointer; }
.rr-sched-remove {
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 4px;
    display: inline-flex;
    flex-shrink: 0;
}
.rr-sched-remove:hover { color: var(--color-error-text); }
.rr-sched-remove svg { width: 16px; height: 16px; }

.rp-empty { padding: 16px 22px; font-size: 14px; color: var(--color-text-muted); }

/* ===== Vali läbipääsupunktid -- kaskaad-sahtel reegli-sahtli kõrval ===== */
.rule-edit { transition: transform .22s ease, right .22s ease; }
.rule-edit.stk1 { right: 380px; }

.rule-points-overlay { z-index: 202; }

.rule-points {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 600px;
    max-width: 94vw;
    background: var(--color-surface);
    box-shadow: -10px 0 34px rgba(16, 24, 40, .18);
    z-index: 203;
    transform: translateX(100%);
    transition: transform .22s ease;
    display: flex;
    flex-direction: column;
}
.rule-points.open { transform: translateX(0); }
.rule-points:not(.open) { box-shadow: none; }

.rp-save-btn {
    margin-left: auto;
    background: #16a34a;
    color: #fff;
    padding: 8px 20px;
    font-size: 14px;
}
.rp-save-btn:hover { background: #128a3e; }

.rp-body { overflow-y: auto; padding: 6px 0; }
.rp-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 22px;
    cursor: pointer;
}
.rp-item.rp-checked { background: #eaf3ff; }
.rp-item input[type=checkbox] {
    width: 20px;
    height: 20px;
    margin-top: 1px;
    flex-shrink: 0;
    accent-color: var(--color-accent-blue);
    cursor: pointer;
}
.rp-item-txt { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.rp-item-txt strong { font-size: 15px; font-weight: 600; color: var(--color-text); }
.rp-item-txt span { font-size: 12px; color: var(--color-text-muted); }

/* ===== Graafiku lisamine ===== */
.sch-body { overflow-y: auto; padding: 20px 22px; }
.sch-field-label { font-size: 12px; color: var(--color-text-muted); margin-bottom: 10px; }

.sch-days { display: flex; flex-wrap: wrap; gap: 10px; }
.sch-day {
    width: 60px;
    height: 44px;
    border: none;
    border-radius: 8px;
    background: #eef0f3;
    color: var(--color-text-muted);
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}
.sch-day.is-on { background: var(--color-accent-blue); color: #fff; }

.sch-times { display: flex; gap: 14px; margin-top: 26px; }
.sch-time-card {
    position: relative;
    flex: 1;
    min-width: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 12px 16px;
}
.sch-time-label { display: block; font-size: 12px; color: var(--color-text-muted); margin-bottom: 3px; }
.sch-time-select {
    appearance: none;
    -webkit-appearance: none;
    border: none;
    background: transparent;
    width: 100%;
    padding: 0 22px 0 0;
    font-family: inherit;
    font-size: 17px;
    font-weight: 700;
    color: var(--color-text);
    cursor: pointer;
}
.sch-time-select:focus { outline: none; }
.sch-time-chev {
    position: absolute;
    right: 14px;
    bottom: 14px;
    width: 18px;
    height: 18px;
    color: var(--color-text-muted);
    pointer-events: none;
}
.sch-delete { width: 100%; margin: 26px 0 0; }
.sch-delete[hidden] { display: none !important; }

.settings-card-textarea {
    width: 100%;
    min-height: 90px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    margin-top: 4px;
}

.settings-card-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}

/* ---- Töömaa asukoha valija (Google Maps paneel) ---- */

.settings-card-clickable {
    cursor: pointer;
}

.settings-card-clickable:hover {
    border-color: var(--color-accent-blue);
}

.settings-card-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.settings-card-chevron {
    width: 18px;
    height: 18px;
    color: var(--color-text-muted);
    flex-shrink: 0;
}

.location-panel-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    z-index: 200;
    justify-content: flex-end;
}

.location-panel-overlay.open {
    display: flex;
}

.location-panel {
    width: min(720px, 92vw);
    height: 100%;
    background: var(--color-surface);
    display: flex;
    flex-direction: column;
    box-shadow: -8px 0 24px rgba(0,0,0,0.12);
}

.location-panel-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.location-panel-header h2 {
    font-size: 17px;
    margin: 0;
}

.location-panel-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--color-bg);
    border: none;
    color: var(--color-text);
    cursor: pointer;
    flex-shrink: 0;
}

.location-panel-close svg {
    width: 16px;
    height: 16px;
}

.location-panel-search {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 14px 20px;
    padding: 10px 14px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    flex-shrink: 0;
}

.location-panel-search svg {
    width: 16px;
    height: 16px;
    color: var(--color-text-muted);
    flex-shrink: 0;
}

.location-panel-search input {
    border: none;
    padding: 0;
    font-size: 14px;
    width: 100%;
}

.location-panel-search input:focus {
    outline: none;
    box-shadow: none;
}

.location-panel-map {
    flex: 1;
    width: 100%;
    min-height: 200px;
}

.location-panel-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 20px;
    border-top: 1px solid var(--color-border);
    flex-shrink: 0;
}

.location-radius-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--color-text-muted);
}

.location-radius-label input {
    width: 80px;
    padding: 7px 9px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 13px;
}

/* ---- X-tee päringu nupp ja tulemuse modaal ---- */

.page-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-box-wide {
    width: min(720px, 92vw);
}

.xtee-result-box {
    margin-top: 8px;
}

.xtee-loading {
    padding: 30px 0;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 14px;
}

.xtee-result-meta {
    font-size: 13px;
    color: var(--color-text-muted);
    margin-bottom: 8px;
}

.xtee-result-pre {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 14px;
    font-size: 12px;
    font-family: ui-monospace, "SF Mono", Consolas, monospace;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 50vh;
    overflow-y: auto;
    color: var(--color-text);
}

.xtee-status-badge {
    display: inline-block;
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 9px;
    border-radius: 999px;
    white-space: nowrap;
}
.xtee-status-draft { color: var(--color-warning-text); background: var(--color-warning-bg); }
.xtee-status-registered { color: var(--color-success-text); background: var(--color-success-bg); }

/* ===== Objektide grid-vaade (pill-tööriistariba + andmeruudustik) ===== */

.obj-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.obj-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 38px;
    padding: 0 14px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text);
    cursor: pointer;
    white-space: nowrap;
    transition: border-color .15s, background .15s, box-shadow .15s;
}

.obj-pill:hover {
    border-color: #c7cbd3;
    background: #fbfbfc;
}

.obj-pill svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.obj-pill .chev {
    width: 14px;
    height: 14px;
    opacity: .6;
    margin-left: -1px;
}

.obj-pill.is-active {
    border-color: var(--color-accent-blue);
    background: var(--status-active-bg);
    color: var(--color-accent-blue);
}

/* "Viimane külastus" vahemikuvalija pill */
.chain-vp-text { display: inline-flex; flex-direction: column; align-items: flex-start; line-height: 1.15; text-align: left; }
.chain-vp-range { font-size: 12px; font-weight: 600; }
#chainVisitPill.is-active {
    background: var(--color-accent-blue);
    border-color: var(--color-accent-blue);
    color: #fff;
}
#chainVisitPill.is-active svg { color: #fff; }
.chain-vp-x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 2px;
    border-radius: 5px;
    cursor: pointer;
}
.chain-vp-x svg { width: 16px; height: 16px; }
.chain-vp-x:hover { background: rgba(255, 255, 255, .22); }
.chain-vp-x[hidden] { display: none; }   /* [hidden] peab võitma display:inline-flex üle */
.chain-vp-pop { padding: 0; min-width: 0; }
/* Nool: kinni = alla, lahti = üles */
#chainVisitChev { transition: transform .18s ease; }
#chainVisitChev[hidden] { display: none; }   /* peidus, kui kuupäevad valitud */
#chainVisitPill.vp-open #chainVisitChev { transform: rotate(180deg); }

/* Kitsam kalender (ainult "Viimane külastus"), tänane päev esile */
.chain-vp-pop.obj-popover-cal { width: auto; }   /* tühistab .obj-popover-cal width:620px */
.chain-vp-pop .drp-cal { padding: 10px 10px; flex: none; }
.chain-vp-pop .drp-grid { width: auto; table-layout: fixed; }   /* ühtlased tulbad, joondub nädalanumbriga */
.chain-vp-pop .drp-wk { width: 24px; font-size: 10px; }
.chain-vp-pop .drp-grid th { width: 30px; padding: 4px 0; }
.chain-vp-pop .drp-cell { width: 30px; }
.chain-vp-pop .drp-day { width: 30px; min-width: 30px; height: 30px; font-size: 12px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; line-height: 1; padding: 0; }
.chain-vp-pop .drp-presets { width: 128px; padding: 8px 6px; }
.chain-vp-pop .drp-preset { padding: 6px 8px; font-size: 12.5px; }
/* Tänane päev: ainult teist värvi number (ilma ringita) */
.chain-vp-pop .drp-today { color: var(--color-accent-blue); font-weight: 700; }
.chain-vp-pop .drp-today.drp-edge { color: #fff; }

.obj-pill-square {
    padding: 0;
    width: 38px;
    justify-content: center;
    color: var(--color-text-muted);
}

.obj-pill-search {
    flex: 1 1 240px;
    max-width: 340px;
    cursor: text;
    gap: 8px;
    padding-left: 14px;
}

.obj-pill-search svg {
    color: var(--color-text-muted);
}

.obj-pill-search input {
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
    width: 100%;
    color: var(--color-text);
}

.obj-drop {
    position: relative;
}

.obj-popover {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 60;
    min-width: 220px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(16, 24, 40, .14);
    padding: 14px;
    flex-direction: column;
    gap: 6px;
}

.obj-popover.open {
    display: flex;
}

.obj-popover-right {
    left: auto;
    right: 0;
}

.obj-pop-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-top: 4px;
}

.obj-pop-input {
    width: 100%;
    height: 38px;
    padding: 0 10px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--color-surface);
    color: var(--color-text);
}

.obj-popover .btn-small {
    margin-top: 10px;
    align-self: flex-end;
}

.obj-pop-link {
    color: var(--color-error-text);
    text-decoration: none;
    font-size: 14px;
    padding: 4px 0;
}

.obj-pop-link:hover { text-decoration: underline; }

/* --- Ruudustik --- */

.obj-grid-wrapper {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow-x: auto;
    position: relative;
}

.obj-grid {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}

.obj-grid th {
    text-align: left;
    padding: 11px 16px;
    background: var(--color-bg);
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: 12px;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 2;
    vertical-align: middle;
}

.obj-grid th,
.data-table th {
    font-family: Lato, "Trebuchet MS", sans-serif;
    font-size: 14px;
    font-weight: 400;
    height: 20px;
    line-height: 20px;
    color: rgb(16, 25, 31);
}

.obj-grid th .th-icon {
    width: 13px;
    height: 13px;
    opacity: .5;
    vertical-align: -2px;
    margin-left: 4px;
}

.obj-grid th .th-sort {
    color: var(--color-accent-blue);
    opacity: .9;
}

.obj-grid td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
    white-space: nowrap;
    background: var(--color-surface);
}

.obj-grid .row-clickable { cursor: pointer; }
.obj-grid .row-clickable:hover td { background: #f7f9fc; }

/* Vertikaalsed jooned veergude vahel */
.obj-grid th,
.obj-grid td {
    border-right: 1px solid var(--color-border);
}
.obj-grid th:last-child,
.obj-grid td:last-child {
    border-right: none;
}

/* Veergude laiuse muutmine (col resize) */
.obj-grid.is-resizable td {
    overflow: hidden;
    text-overflow: ellipsis;
}
.obj-grid.is-resizable th {
    overflow: visible; /* et täiskõrgusega käepide ei jääks lõikude taha */
}
.obj-grid .th-inner {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.col-resizer {
    position: absolute;
    top: 0;
    right: -4px;        /* keskele veerujoonele */
    width: 9px;
    cursor: col-resize;
    user-select: none;
    z-index: 4;
    /* kõrgus määratakse JS-iga = kogu tabeli kõrgus */
}
.col-resizer::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 4px;          /* keskkoht = veerujoon */
    width: 2px;
    background: transparent;
    transition: background .12s;
}
.col-resizer:hover::after,
.col-resizer.dragging::after {
    background: var(--color-accent-blue);
}

body.col-resizing,
body.col-resizing * {
    cursor: col-resize !important;
    user-select: none !important;
}

/* Kinnitatud esimene veerg */
.obj-grid th.col-name,
.obj-grid td.col-name {
    position: sticky;
    left: 0;
    z-index: 3;
    box-shadow: 1px 0 0 var(--color-border);
}
.obj-grid th.col-name { z-index: 4; }
.obj-grid td.col-name { background: var(--color-surface); }
.obj-grid .row-clickable:hover td.col-name { background: #f7f9fc; }

.obj-name-cell {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.obj-name-cell .row-idx {
    color: var(--color-text-muted);
    font-size: 12px;
    min-width: 14px;
    padding-top: 2px;
    text-align: right;
    opacity: .6;
}

.obj-grid .cell-title { font-weight: 600; }
.obj-grid .cell-subtitle { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; }
.obj-grid .cell-strong { font-weight: 600; }

.obj-grid .col-gear {
    width: 48px;
    text-align: center;
    position: sticky;
    right: 0;
    z-index: 3;
    background: var(--color-bg);
    box-shadow: -1px 0 0 var(--color-border);
}
.obj-grid th.col-gear { z-index: 4; }
.obj-grid td.col-gear { background: var(--color-surface); }
.obj-grid .row-clickable:hover td.col-gear { background: #f7f9fc; }

/* Sisse/välja lülitatud märgis (TTKI veerud) */
.badge-toggle {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid transparent;
    white-space: nowrap;
}
.badge-toggle-on {
    color: var(--color-success-text);
    border-color: #bfe3cd;
    background: #f2fbf5;
}
.badge-toggle-off {
    color: var(--color-text-muted);
    border-color: var(--color-border);
    background: var(--color-bg);
}

/* ===== Veeru-seadete sahtel (hammasratas) ===== */
.col-gear-btn {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    color: var(--color-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.col-gear-btn:hover { color: #000; }
.obj-grid th.col-gear .col-gear-btn svg,
.col-gear-btn svg {
    width: 20px;
    height: 20px;
    opacity: 1;      /* tühistab .th-icon opacity:.5 */
    flex-shrink: 0;
}

.col-settings-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(16, 24, 40, .35);
    z-index: 200;
}
.col-settings-overlay.open { display: block; }

.col-settings-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 440px;
    max-width: 92vw;
    background: var(--color-surface);
    box-shadow: -10px 0 34px rgba(16, 24, 40, .18);
    z-index: 201;
    transform: translateX(100%);
    transition: transform .22s ease;
    display: flex;
    flex-direction: column;
}
.col-settings-panel.open { transform: translateX(0); }

.col-settings-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}
.col-settings-icon-btn {
    width: 38px;
    height: 38px;
    padding: 0;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    cursor: pointer;
    color: var(--color-text);
}
.col-settings-icon-btn:hover { background: #eef0f3; }
.col-settings-icon-btn svg { width: 18px; height: 18px; flex-shrink: 0; }

.col-settings-title {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.col-settings-title strong { font-size: 15px; }
.col-settings-title span { font-size: 12px; color: var(--color-text-muted); }

.col-settings-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.col-settings-list {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    flex: 1;
}

.col-settings-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 18px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
}
.col-settings-item[draggable="true"] { cursor: grab; }
.col-settings-item.dragging { opacity: .5; background: var(--status-active-bg); }
.col-settings-item.is-locked { color: var(--color-text-muted); }

.col-settings-check {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    accent-color: var(--color-accent-blue);
    cursor: pointer;
}
.col-settings-item.is-locked .col-settings-check { cursor: default; }

.col-settings-label {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.col-settings-handle {
    color: var(--color-text-muted);
    display: inline-flex;
    cursor: grab;
}
.col-settings-handle svg { width: 20px; height: 20px; }
.col-settings-item.is-locked .col-settings-handle { visibility: hidden; }

/* ===== Muuda inimest -- sahtel ===== */
.chain-grid tr.chain-tr-person { cursor: pointer; }
.chain-grid tr.chain-tr-person:hover { background: var(--color-bg); }

.person-edit .pe-body {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0 24px;
}
.pe-field { padding: 12px 20px 4px; display: flex; flex-direction: column; gap: 6px; }
.pe-field label {
    font-size: 12px;
    color: var(--color-text-muted);
    font-weight: 400;
}
.pe-req { color: #e0793b; }
.ce-value { font-size: 15px; font-weight: 700; color: var(--color-text); padding: 2px 0 6px; }
.ce-value-muted { font-weight: 600; color: var(--color-text-muted); }
.pe-field input,
.pe-phone select,
.pe-phone input {
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    color: var(--color-text);
    background: var(--color-surface);
    width: 100%;
    box-sizing: border-box;
}
.pe-field input:focus,
.pe-phone select:focus,
.pe-phone input:focus {
    outline: none;
    border-color: var(--color-accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, .15);
}
.pe-phone { display: flex; gap: 10px; }
.pe-phone select { width: 150px; flex-shrink: 0; }
.pe-phone input { flex: 1; }

.pe-divider { height: 1px; background: var(--color-border); margin: 14px 0 4px; }

.pe-toggle {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 20px;
    cursor: pointer;
}
.pe-toggle input[type=checkbox] {
    width: 20px;
    height: 20px;
    margin-top: 1px;
    flex-shrink: 0;
    accent-color: var(--color-accent-blue);
    cursor: pointer;
}
.pe-toggle-txt { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.pe-toggle-txt strong { font-size: 15px; font-weight: 600; color: var(--color-text); }
.pe-toggle-txt span { font-size: 13px; color: var(--color-text-muted); line-height: 1.4; }
.pe-toggle-txt a { color: var(--color-accent-blue); text-decoration: none; }
.pe-toggle-txt a:hover { text-decoration: underline; }
.pe-toggle.is-disabled { cursor: default; }
.pe-toggle.is-disabled .pe-toggle-txt strong,
.pe-toggle.is-disabled input { opacity: .5; cursor: default; }

.pe-row {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 14px 20px;
    background: none;
    border: none;
    border-top: 1px solid var(--color-border);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    color: var(--color-text);
}
.pe-row:hover { background: var(--color-bg); }
.pe-row:first-of-type { border-top: 1px solid var(--color-border); margin-top: 6px; }
.pe-row-ic {
    flex-shrink: 0;
    color: var(--color-text-muted);
    display: inline-flex;
}
.pe-row-ic svg { width: 20px; height: 20px; }
.pe-row-txt { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pe-row-sub { font-size: 12px; color: var(--color-text-muted); }
.pe-row-txt strong { font-size: 15px; font-weight: 600; }
.pe-chev { width: 18px; height: 18px; color: var(--color-text-muted); flex-shrink: 0; }
.pe-row.is-disabled { cursor: default; }
.pe-row.is-disabled .pe-row-txt strong,
.pe-row.is-disabled .pe-row-ic { opacity: .45; }
.pe-row.is-disabled:hover { background: none; }

.pe-section-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .04em;
    color: var(--color-text-muted);
    padding: 22px 20px 4px;
    border-top: 1px solid var(--color-border);
    margin-top: 8px;
}
.pe-help {
    font-size: 13px;
    color: var(--color-text-muted);
    padding: 4px 20px 0;
    margin: 0;
    line-height: 1.4;
}
.pe-delete {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: calc(100% - 40px);
    margin: 24px 20px 0;
    padding: 11px;
    background: none;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    color: #d0342c;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.pe-delete svg { width: 18px; height: 18px; }
.pe-delete:hover { background: #fdf0ef; border-color: #f0c4c0; }

/* ===== Kvalifikatsioonid -- kaskaad-sahtlid (isiku-sahtli kõrval) ===== */
/* Kaskaad: uusim paremal (right:0), vanemad nihkuvad vasakule sammu (190px) võrra. */
.person-edit { transition: transform .22s ease, right .22s ease; }
.person-edit.stk1 { right: 190px; }
.person-edit.stk2 { right: 380px; }

.qual-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 460px;
    max-width: 92vw;
    background: var(--color-surface);
    box-shadow: -10px 0 34px rgba(16, 24, 40, .18);
    z-index: 202;
    transform: translateX(100%);
    transition: transform .22s ease, right .22s ease;
    display: flex;
    flex-direction: column;
}
.qual-panel.open { transform: translateX(0); }
.qual-panel.stk1 { right: 190px; }

.qual-detail-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 520px;
    max-width: 94vw;
    background: var(--color-surface);
    box-shadow: -10px 0 34px rgba(16, 24, 40, .18);
    z-index: 203;
    transform: translateX(100%);
    transition: transform .22s ease, right .22s ease;
    display: flex;
    flex-direction: column;
}
.qual-detail-panel.open { transform: translateX(0); }

/* Suletud (ekraanist väljas) paremriba-sahtlite vari ei tohi valguda viewporti
   paremasse serva -- vari ainult avatud olekus. */
.col-settings-panel:not(.open),
.qual-panel:not(.open),
.qual-detail-panel:not(.open) { box-shadow: none; }

/* Halda kaarte -- sahtel */
.card-mgr .cm-body { flex: 1; overflow-y: auto; padding: 6px 0; }
.cm-list { display: flex; flex-direction: column; }
.cm-card { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--color-border); }
.cm-num { font-size: 16px; font-weight: 600; letter-spacing: .5px; font-variant-numeric: tabular-nums; }
.cm-empty { padding: 18px 20px; color: var(--color-text-muted); font-size: 14px; }
.cm-add {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 16px 20px; background: transparent; border: none;
    border-bottom: 1px solid var(--color-border);
    font-size: 14px; font-weight: 600; font-family: inherit;
    color: var(--color-text); cursor: pointer; text-align: left;
}
.cm-add:hover { background: var(--color-bg); }
.cm-add svg { width: 18px; height: 18px; color: var(--color-text-muted); flex-shrink: 0; }

/* "Kaardid" rea eelvaade person-edit sahtlis */
.pe-cards-preview { display: inline-flex; align-items: center; gap: 7px; margin-left: auto; min-width: 0; }
.pe-card-count {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px;
    background: var(--color-accent-blue); color: #fff; font-size: 12px; font-weight: 700;
}
.pe-card-first { font-size: 13px; color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }

/* ===== "Vali inimene" -- sisse/välja registreerimise sahtel ===== */
.reg-search {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 14px 18px 4px;
    padding: 9px 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-bg);
    flex-shrink: 0;
}
.reg-search svg { width: 17px; height: 17px; color: var(--color-text-muted); flex-shrink: 0; }
.reg-search input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 14px;
    font-family: inherit;
    color: var(--color-text);
    width: 100%;
}
.reg-search input::placeholder { color: var(--color-text-muted); }

.reg-allout {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 8px 18px 6px;
    padding: 12px 14px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    cursor: pointer;
    flex-shrink: 0;
}
.reg-allout:hover { background: var(--color-bg); }
.reg-allout-icon {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--color-error-bg);
    color: var(--color-error-text);
}
.reg-allout-icon svg { width: 18px; height: 18px; }
.reg-allout-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.reg-allout-txt strong { font-size: 13.5px; font-weight: 600; }
.reg-allout-txt span { font-size: 12px; color: var(--color-text-muted); }

.reg-body { flex: 1; overflow-y: auto; padding: 4px 0 24px; }

.reg-list { display: flex; flex-direction: column; }
.reg-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    cursor: pointer;
    border-top: 1px solid var(--color-border);
}
.reg-list .reg-item:first-child { border-top: none; }
.reg-item:hover { background: var(--color-bg); }
.reg-item-clickable { cursor: pointer; }
.reg-item-busy { opacity: .5; pointer-events: none; }
.reg-avatar {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .3px;
}
.reg-item-main { flex: 1; min-width: 0; }
.reg-item-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.reg-item-company {
    font-size: 12px;
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.reg-badge {
    flex-shrink: 0;
    font-size: 11.5px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
    color: var(--color-success-text);
    border: 1px solid #bfe3cd;
    background: #f2fbf5;
}

.reg-section { border-top: 1px solid var(--color-border); margin-top: 6px; }
.reg-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 18px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
}
.reg-section-head:hover { background: var(--color-bg); }
.reg-section-caret {
    width: 26px;
    height: 26px;
    padding: 0;
    border: none;
    background: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    cursor: pointer;
}
.reg-section-caret svg { width: 18px; height: 18px; transition: transform .18s ease; }
.reg-section.open .reg-section-caret svg { transform: rotate(90deg); }
.reg-section-body { padding: 4px 18px 14px; }
.reg-empty { font-size: 13px; color: var(--color-text-muted); }

/* ===== Aruanded ===== */
.content--reports .rep-toolbar { flex-shrink: 0; }
.content--reports .obj-grid-wrapper { flex: 1; min-height: 0; overflow: auto; }

.rep-export-btn { color: #157347; }

.rep-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.rep-tool-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    color: var(--color-text-muted);
    cursor: pointer;
}
.rep-tool-icon:hover { background: var(--color-bg); }
.rep-tool-icon svg { width: 18px; height: 18px; }

.rep-filter {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    height: 40px;
    padding: 0 12px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    cursor: pointer;
    color: var(--color-text);
    font-family: inherit;
}
.rep-filter:hover { background: var(--color-bg); }

/* "Inimesed" filter -- rippmenüü */
.rep-people-drop { position: relative; }
.rep-people-drop.open .rep-filter-chev { transform: rotate(180deg); }
.rep-people-pop {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 60;
    width: 300px;
    max-height: 420px;
    display: flex;
    flex-direction: column;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(16, 24, 40, .16);
    overflow: hidden;
}
.rep-people-pop[hidden] { display: none; }
.rep-people-search {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px;
    padding: 8px 11px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
}
.rep-people-search:focus-within { border-color: var(--color-accent-blue); box-shadow: 0 0 0 3px rgba(0,137,233,.12); }
.rep-people-search svg { width: 16px; height: 16px; color: var(--color-text-muted); flex-shrink: 0; }
.rep-people-search input { border: none; outline: none; width: 100%; background: transparent; font-size: 14px; font-family: inherit; color: var(--color-text); }
.rep-people-list { overflow-y: auto; }
.rep-people-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 13px;
    cursor: pointer;
}
.rep-people-item:hover { background: var(--color-bg); }
.rep-people-all { border-bottom: 1px solid var(--color-border); font-weight: 600; }
.rep-people-item input[type=checkbox] { width: 17px; height: 17px; flex-shrink: 0; accent-color: var(--color-accent-blue); cursor: pointer; }
.rep-people-name { font-size: 14px; color: var(--color-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rep-people-empty { padding: 14px; font-size: 13px; color: var(--color-text-muted); }

/* Hammasratta seaded -- väike popover */
.rep-settings-pop {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 60;
    min-width: 230px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(16, 24, 40, .16);
    padding: 6px;
}
.rep-settings-pop[hidden] { display: none; }
.rep-settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 8px 10px;
    cursor: pointer;
}
.rep-settings-label { font-size: 14px; color: var(--color-text); }

/* "Aruande tüüp" valija */
.rep-type-pop {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 60;
    width: 256px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(16, 24, 40, .16);
    padding: 6px;
}
.rep-type-pop[hidden] { display: none; }
.rep-type-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 11px 13px;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
}
.rep-type-item:hover { background: var(--color-bg); }
.rep-type-item.is-active { background: #eaf3ff; }
.rep-type-title { font-size: 14px; font-weight: 600; color: var(--color-text); }
.rep-type-desc { font-size: 12px; color: var(--color-text-muted); line-height: 1.35; }

/* "Inimesed" aruanne -- isikute kaupa rühmitatud külastused */
.rep-people-grid thead th {
    vertical-align: top;
    white-space: nowrap;
}
.rep-people-grid .rpg-sub {
    display: block;
    margin-top: 3px;
    font-size: 12px;
    font-weight: 700;
    color: var(--color-text);
}
.rep-people-grid thead th.rpg-name .rpg-sub { font-weight: 400; color: var(--color-text-muted); }
.rpg-person { cursor: pointer; }
.rpg-person:hover { background: var(--color-bg); }
.rpg-person > td { font-weight: 600; }
.rpg-name { white-space: nowrap; }
.rpg-person .rpg-name { display: flex; align-items: center; gap: 6px; }
.rpg-chev {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    color: var(--color-text-muted);
    transition: transform .15s ease;
}
.rpg-chev svg { width: 15px; height: 15px; }
.rpg-person.is-open .rpg-chev { transform: rotate(90deg); }
.rpg-person-name { font-weight: 600; }
.rpg-visit > td { color: var(--color-text-muted); font-weight: 400; }
.rpg-visit-name { padding-left: 34px !important; color: var(--color-text) !important; }

/* "Ettevõtte inimesed" -- 3-tasandiline (ettevõte -> isik -> külastus) */
.rpc-company, .rpc-person { cursor: pointer; }
.rpc-company:hover, .rpc-person:hover { background: var(--color-bg); }
.rpc-company > td { font-weight: 600; }
.rpc-person > td { font-weight: 600; }
.rpc-company .rpc-name, .rpc-person .rpc-name { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.rpc-company .rpg-chev, .rpc-person .rpg-chev { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; color: var(--color-text-muted); transition: transform .15s ease; }
.rpc-company .rpg-chev svg, .rpc-person .rpg-chev svg { width: 15px; height: 15px; }
.rpc-company.is-open .rpg-chev, .rpc-person.is-open .rpg-chev { transform: rotate(90deg); }
.rpc-person-name { padding-left: 26px !important; }
.rpc-visit > td { color: var(--color-text-muted); font-weight: 400; }
.rpc-visit-name { padding-left: 58px !important; color: var(--color-text) !important; }

.rep-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
}
.av-c0 { background: #6c8ae4; }
.av-c1 { background: #e0793b; }
.av-c2 { background: #2fa27a; }
.av-c3 { background: #b866c8; }
.av-c4 { background: #d1517f; }
.av-c5 { background: #4aa3c7; }
.av-c6 { background: #c7a23a; }
.av-c7 { background: #7b7fe0; }
.rep-filter-ico { width: 17px; height: 17px; flex-shrink: 0; color: var(--color-text-muted); }
.rep-filter-chev { width: 15px; height: 15px; flex-shrink: 0; color: var(--color-text-muted); }
.rep-filter-value { font-size: 14px; font-weight: 600; white-space: nowrap; }
.rep-filter-txt { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.25; }
.rep-filter-label { font-size: 11px; font-weight: 400; color: var(--color-text-muted); }
.rep-filter--two .rep-filter-value { font-size: 13.5px; }

.rep-period { display: inline-flex; }
.rep-period .rep-filter { height: 40px; }
.rep-period-x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    border-radius: 6px;
    color: var(--color-text-muted);
    margin-left: -2px;
}
.rep-period-x svg { width: 15px; height: 15px; }
.rep-period-x:hover { background: var(--color-bg); color: var(--color-text); }
.rep-period-x[hidden] { display: none; }
.rep-filter.is-active { border-color: var(--color-accent-blue); }

/* Aruannete tabel */
.rep-grid td { font-size: 13.5px; }
.rep-gear-col { width: 44px; text-align: center; }

.rep-dir {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 9px;
    border-radius: 5px;
    border: 1px solid transparent;
}
.rep-dir-out { color: var(--color-error-text); background: var(--color-error-bg); border-color: #f3c9c4; }
.rep-dir-in  { color: var(--status-done-text); background: var(--status-done-bg); border-color: #bfe3cd; }

.rep-result-bad { color: var(--color-error-text); font-weight: 600; }
.rep-result-ok  { color: var(--status-done-text); font-weight: 600; }

/* "Mobiilne registreerimine" -- kaks valikut isiku-sahtli all (Ei ole lubatud / Lubatud). */
.pm-opt {
    display: flex; align-items: flex-start; gap: 12px;
    width: 100%; text-align: left; background: #fff; cursor: pointer;
    border: 1px solid var(--color-border); border-radius: 12px;
    padding: 14px 16px; margin-bottom: 10px;
    transition: border-color .12s, box-shadow .12s, background .12s;
}
.pm-opt:hover { border-color: #cfd6df; }
.pm-opt.is-active { border-color: var(--color-accent-blue); box-shadow: 0 0 0 1px var(--color-accent-blue); background: #f6f9ff; }
.pm-opt-txt { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.pm-badge {
    display: inline-block; align-self: flex-start; font-size: 12px; font-weight: 600;
    padding: 3px 10px; border-radius: 999px;
}
.pm-badge.rep-result-bad { color: #b42318; background: #fef3f2; }
.pm-badge.rep-result-ok  { color: #157347; background: #dcfce7; }
.pm-opt-desc { font-size: 13px; color: var(--color-text-muted); line-height: 1.4; }
.pm-check { width: 20px; height: 20px; flex-shrink: 0; color: var(--color-accent-blue); opacity: 0; margin-top: 2px; }
.pm-opt.is-active .pm-check { opacity: 1; }

.rep-find-owner { color: var(--color-text-muted); text-decoration: underline; cursor: pointer; }
.rep-find-owner:hover { color: var(--color-accent-blue); }

.rep-ttki-badge {
    display: inline-block;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .4px;
    padding: 1px 6px;
    border-radius: 4px;
    color: var(--color-text-muted);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    vertical-align: 1px;
}
.rep-card-num { font-variant-numeric: tabular-nums; }

.rep-sync-ok {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--status-done-bg);
    color: var(--status-done-text);
}
.rep-sync-ok svg { width: 12px; height: 12px; }
.rep-sync-no { color: var(--color-text-muted); }

.qd-body { flex: 1; overflow-y: auto; padding: 0 0 24px; }
.qd-row {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    padding: 13px 20px;
    border-bottom: 1px solid var(--color-border);
}
.qd-k {
    flex-shrink: 0;
    width: 150px;
    font-size: 14px;
    color: var(--color-text-muted);
}
.qd-v {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    min-width: 0;
    line-height: 1.4;
}

.qual-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}
.qual-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.qual-body { flex: 1; overflow-y: auto; padding: 16px 18px 24px; }

.qual-info {
    display: flex;
    gap: 12px;
    padding: 14px;
    background: #eef6fe;
    border: 1px solid #cfe6fb;
    border-radius: 10px;
    margin-bottom: 18px;
}
.qual-info-ic { flex-shrink: 0; display: inline-flex; }
.qual-info-ic svg { width: 22px; height: 22px; }
.qual-info-txt strong { display: block; font-size: 14px; margin-bottom: 2px; color: var(--color-text); }
.qual-info-txt p { margin: 0; font-size: 13px; color: var(--color-text-muted); line-height: 1.45; }

.qual-section-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .04em;
    color: var(--color-text-muted);
    margin: 4px 0 10px;
}

.qual-card {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 14px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    color: var(--color-text);
}
.qual-card:hover { background: var(--color-bg); }
.qual-card-ic { flex-shrink: 0; color: var(--color-text-muted); display: inline-flex; }
.qual-card-ic svg { width: 22px; height: 22px; }
.qual-card-txt { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.qual-card-txt strong { font-size: 14px; font-weight: 600; }
.qual-card-txt span { font-size: 12.5px; color: var(--color-text-muted); }
.qual-card .pe-chev { width: 18px; height: 18px; color: var(--color-text-muted); flex-shrink: 0; }

.qual-empty { font-size: 13px; color: var(--color-text-muted); padding: 20px 4px; text-align: center; }

/* ===== Töövõtuahel -- tühi olek ===== */
.chain-empty-row td { padding: 0 !important; background: var(--color-surface); }
.chain-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 56px 24px;
    text-align: center;
}
.chain-empty-title { font-size: 16px; font-weight: 600; color: var(--color-text); }
.chain-empty-text { font-size: 14px; color: var(--color-text-muted); max-width: 460px; }
.chain-empty-actions { display: flex; gap: 10px; margin-top: 10px; }

/* ===== Ettevõtte ülevaade -- sahtel ===== */
.chain-grid tr.chain-tr-company { cursor: pointer; }

.co-view .co-body {
    flex: 1;
    overflow-y: auto;
    padding: 0 0 24px;
}
.co-section-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .04em;
    color: var(--color-text-muted);
    padding: 20px 20px 10px;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
}
.co-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--color-border);
}
.co-k {
    flex-shrink: 0;
    width: 130px;
    font-size: 14px;
    color: var(--color-text-muted);
}
.co-v {
    flex: 1;
    font-size: 14px;
    color: var(--color-text);
    min-width: 0;
}
.co-v.co-strong { font-weight: 600; }
.co-row-btn {
    width: 100%;
    background: none;
    border: none;
    border-bottom: 1px solid var(--color-border);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}
.co-row-btn:hover { background: var(--color-bg); }
.co-chev { width: 18px; height: 18px; color: var(--color-text-muted); flex-shrink: 0; }

.co-toggle {
    display: block;
    width: 100%;
    padding: 14px;
    background: none;
    border: none;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-accent-blue);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
}
.co-toggle:hover { background: var(--color-bg); }

.co-status { padding: 22px 20px; text-align: center; }
.co-status-head {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 6px;
}
.co-status-head strong { font-size: 15px; color: var(--color-text); }
.co-status-ic { display: inline-flex; }
.co-status-ic svg { width: 20px; height: 20px; }
.co-status p {
    margin: 0;
    font-size: 13px;
    color: var(--color-text-muted);
    line-height: 1.45;
}

/* ===== Kuupäeva-pill (Alguskuupäev / Lõppkuupäev) ===== */
.obj-pill-date {
    padding: 0;
    overflow: hidden;
    align-items: stretch;
}
.obj-pill-toggle {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: none;
    border: none;
    padding: 0 12px;
    margin: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
}
.obj-pill-toggle svg { width: 16px; height: 16px; flex-shrink: 0; }
.obj-pill-toggle .chev { width: 14px; height: 14px; opacity: .6; }
.obj-pill-text { display: inline-flex; flex-direction: column; align-items: flex-start; line-height: 1.15; text-align: left; }
.obj-pill-title { font-size: 14px; font-weight: 500; }
.obj-pill-sub { font-size: 13px; font-weight: 600; }

.obj-pill-date.is-active {
    border-color: var(--color-accent-blue);
    background: var(--color-accent-blue);
    color: #fff;
}
.obj-pill-date.is-active .obj-pill-title { font-size: 11px; color: rgba(255, 255, 255, .85); }

.obj-pill-x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    color: #fff;
    text-decoration: none;
    border-left: 1px solid rgba(255, 255, 255, .3);
    flex-shrink: 0;
}
.obj-pill-x:hover { background: rgba(255, 255, 255, .15); }
.obj-pill-x svg { width: 13px; height: 13px; }

/* ===== Kalender (date range picker) ===== */
.obj-popover-cal {
    min-width: 0;
    width: 620px;
    max-width: 94vw;
    padding: 0;
    overflow: hidden;
}
.drp-body { display: flex; }
.drp-cal { flex: 1; padding: 12px 14px; }
.drp-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.drp-title { font-weight: 700; font-size: 15px; }
.drp-arrow {
    background: none; border: none; cursor: pointer; font-size: 20px; line-height: 1;
    color: var(--color-text); padding: 2px 10px; border-radius: 6px;
}
.drp-arrow:hover { background: var(--color-bg); }
.drp-grid { border-collapse: collapse; width: 100%; }
.drp-grid th { font-size: 11px; font-weight: 600; color: var(--color-text-muted); padding: 5px 0; text-align: center; }
.drp-grid td { padding: 0; text-align: center; }
.drp-wk { color: var(--color-text-muted); font-size: 11px; width: 30px; }
.drp-day {
    width: 100%; min-width: 34px; height: 34px; border: none; background: none;
    cursor: pointer; font-size: 13px; color: var(--color-text); border-radius: 8px;
}
.drp-day:hover { background: var(--color-bg); }
.drp-in { background: var(--status-active-bg); border-radius: 0; }
.drp-edge { background: var(--color-accent-blue) !important; color: #fff; border-radius: 8px; }
.drp-out { background: none; }

.drp-presets {
    width: 150px; flex-shrink: 0; border-left: 1px solid var(--color-border);
    padding: 10px 8px; display: flex; flex-direction: column; gap: 1px;
}
.drp-preset {
    text-align: left; background: none; border: none; padding: 7px 10px;
    border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--color-text-muted);
}
.drp-preset:hover { background: var(--color-bg); color: var(--color-text); }

.drp-clear {
    width: 100%; border: none; border-top: 1px solid var(--color-border);
    background: var(--color-bg); padding: 12px; cursor: pointer;
    font-size: 14px; font-weight: 600; color: var(--color-text);
}
.drp-clear:hover { background: #eef0f3; }

/* ===== Töövõtuahel (chain grid, näidisvaade) ===== */
.chain-grid td, .chain-grid th { padding: 11px 16px; }   /* sama tihedus kui Objektide grid */

/* Reakõrgus: Töövõtuahel 42px, Objektid 52px; sisu vertikaalselt keskel */
.obj-grid th, .obj-grid td { height: 42px; padding-top: 0; padding-bottom: 0; vertical-align: middle; }
.obj-grid:not(.chain-grid) th, .obj-grid:not(.chain-grid) td { height: 52px; }
.chain-name-col { min-width: 400px; }
.chain-grid td.chain-name-col { font-size: 14px; }
.chain-name-inner { display: flex; align-items: center; gap: 8px; }
.chain-check { width: 15px; height: 15px; flex-shrink: 0; accent-color: var(--color-accent-blue); cursor: pointer; }
.chain-tog {
    background: none; border: none; padding: 0; width: 20px; height: 20px;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--color-text-muted); flex-shrink: 0; transition: transform .12s;
}
.chain-tog svg { width: 16px; height: 16px; }
.chain-tog.open { transform: rotate(90deg); }
.chain-tog-sp { width: 20px; flex-shrink: 0; display: inline-block; }
.chain-num { color: var(--color-text-muted); font-size: 12px; min-width: 26px; flex-shrink: 0; }
.chain-nic { display: inline-flex; flex-shrink: 0; color: var(--color-text-muted); }
.chain-nic svg { width: 17px; height: 17px; }
.chain-nic-company { color: var(--color-accent-blue); }
.chain-nic-admin { color: var(--color-accent-blue); }  /* ettevõtte administraator -> sinine ikoon */
.chain-nm { font-weight: 600; white-space: nowrap; }

/* Ettevõtte rea tegevusnupud (ilmuvad hõljutamisel): muuda + lisa alltöövõtja */
.chain-row-actions { display: inline-flex; align-items: center; gap: 6px; margin-left: 8px; opacity: 0; transition: opacity .12s ease; }
.chain-tr-company:hover .chain-row-actions { opacity: 1; }
.chain-row-act {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; padding: 0; flex-shrink: 0;
    border: 1px solid var(--color-border); border-radius: 7px;
    background: var(--color-surface); color: var(--color-text-muted);
    cursor: pointer;
}
.chain-row-act:hover { background: var(--color-bg); color: var(--color-text); }
.chain-row-act svg { width: 15px; height: 15px; }
.chain-row-act-add { background: #16a34a; border-color: #16a34a; color: #fff; }
.chain-row-act-add:hover { background: #15803d; color: #fff; }

/* Rohelise "+" menüü */
.chain-add-menu {
    position: absolute;
    z-index: 200;
    min-width: 180px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    box-shadow: 0 12px 30px rgba(16, 24, 40, .18);
    padding: 6px;
}
.chain-add-item {
    display: flex; align-items: center; gap: 10px;
    width: 100%; text-align: left;
    border: none; background: none; border-radius: 7px;
    padding: 9px 10px; cursor: pointer; font-family: inherit;
    font-size: 14px; font-weight: 600; color: var(--color-text);
}
.chain-add-item:hover { background: var(--color-bg); }
.chain-add-item svg { width: 17px; height: 17px; color: #0089e9; flex-shrink: 0; }

/* Lisa-sahtlite abiväljad */
.pe-err { padding: 8px 20px 0; font-size: 13px; color: #d92d20; min-height: 18px; }
.person-edit .pe-row.is-disabled { opacity: .5; pointer-events: none; }
.chain-tr-people .chain-nm, .chain-tr-person .chain-nm { font-weight: 500; }
.chain-tr-company > .chain-name-col .chain-nm { color: var(--color-text); }

.chain-grid tbody tr:hover td { background: #f7f9fc; }
.chain-grid tbody tr:hover td.col-name { background: #f7f9fc; }

.chain-visit-green { color: var(--color-success-text); font-weight: 600; }

.chain-badge { display: inline-block; padding: 2px 9px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.chain-badge-active { color: var(--color-success-text); border: 1px solid #bfe3cd; background: #f2fbf5; }
.chain-badge-pending { color: var(--color-warning-text); border: 1px solid #f4d9b8; background: #fff7ed; }
.chain-badge-deleted { color: var(--color-error-text); border: 1px solid #f3c9c4; background: var(--color-error-bg); }

.chain-pill { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; border: 1px solid transparent; white-space: nowrap; }
.chain-pill-ok { color: var(--color-success-text); border-color: #bfe3cd; background: #f2fbf5; }
.chain-pill-bad { color: var(--color-error-text); border-color: #f4c7c3; background: #fdf0ef; }

.chain-card { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.chain-card-tag { font-size: 10px; font-weight: 700; color: var(--color-accent-blue); border: 1px solid var(--color-accent-blue); border-radius: 4px; padding: 0 4px; }
.chain-card-more { font-size: 11px; font-weight: 700; color: var(--color-text-muted); background: #eef0f3; border-radius: 999px; padding: 0 6px; margin-left: 2px; }

/* Checkbox eraldi kinnitatud veeruna (Töövõtuahel) */
.chain-check-col {
    width: 44px;
    min-width: 44px;   /* range fikseeritud laius, et kerimisel ei muutuks */
    max-width: 44px;
    text-align: center;
    position: sticky;
    left: 0;
    z-index: 3;
    background: var(--color-surface);
}
/* Kõrgem spetsiifilisus kui .chain-grid td/th ja .obj-grid th, et 16px padding ei
   paisutaks 44px veergu ning päise checkbox oleks samuti keskel (mitte vasakul). */
.chain-grid td.chain-check-col, .chain-grid th.chain-check-col { padding-left: 0; padding-right: 0; text-align: center; }
.chain-grid thead .chain-check-col { background: var(--color-bg); z-index: 4; }
.chain-grid tbody tr:hover .chain-check-col { background: #f7f9fc; }
/* Nimeveerg nihkub checkboxi laiuse võrra paremale.
   Eraldusjoon check-col ja nimeveeru vahel kuulub nimeveerule (border-left),
   sest see joonistub sticky-kerimisel peale (check-col border-right jääks katma). */
.chain-grid th.col-name, .chain-grid td.col-name { left: 44px; border-left: 1px solid var(--color-border); }
.chain-grid .chain-check-col { border-right: none; }
.chain-check-col .chain-check, .chain-check-col input[type="checkbox"] {
    width: 15px; height: 15px; accent-color: var(--color-accent-blue); cursor: pointer;
}

/* ===== Töövõtuahel: isikute valik + valikuriba ===== */
.chain-selbar {
    display: none;
    position: fixed; top: 0; left: 0; right: 0; z-index: 300;
    background: var(--color-accent-blue); color: #fff;
    align-items: center; gap: 14px; padding: 9px 18px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);
}
.chain-selbar.open { display: flex; }
.chain-selbar-x {
    width: 34px; height: 34px; border: none; border-radius: 8px; flex-shrink: 0;
    background: rgba(255, 255, 255, .18); color: #fff; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
}
.chain-selbar-x:hover { background: rgba(255, 255, 255, .28); }
.chain-selbar-x svg { width: 18px; height: 18px; }
.chain-selbar-count { font-size: 15px; font-weight: 600; }
.chain-selbar-actions { display: flex; gap: 10px; margin-left: 6px; }
.chain-sel-btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 14px; border-radius: 8px; border: none; cursor: pointer;
    font-size: 14px; font-weight: 600;
}
.chain-sel-btn svg { width: 16px; height: 16px; }
.chain-sel-danger { background: #fff; color: var(--color-error-text); }
.chain-sel-danger:hover { background: #fdf0ef; }
.chain-sel-edit { background: rgba(255, 255, 255, .16); color: #fff; }
.chain-sel-edit:hover { background: rgba(255, 255, 255, .26); }

/* Valitud isiku rida */
.chain-grid tbody tr.chain-selected td { background: #e6f2fd; }

/* Hallistatud (mitte-isiku) read valiku ajal -- sisu hall, taust jääb läbipaistmatuks */
.chain-tr.chain-dim td { color: #aeb4be; }
.chain-tr.chain-dim .chain-nm,
.chain-tr.chain-dim .chain-num,
.chain-tr.chain-dim .chain-nic,
.chain-tr.chain-dim .chain-role-badge,
.chain-tr.chain-dim .chain-badge,
.chain-tr.chain-dim .chain-visit-green,
.chain-tr.chain-dim .chain-tog,
.chain-tr.chain-dim .chain-check { opacity: .4; }
