:root {
    --bg-dark: #f8f7fa;
    --bg-gray: #7e7e7e;
    --bg-card: #ffffff;
    --bg-hover: #f3f2f7;
    --text-primary: #222;
    --text-secondary: #b9b9c3;
    --text-heading: #3f4751;
    --primary: #678C1C;
    --primary-hover: #577618;
    --success: #28c76f;
    --warning: #ff9f43;
    --danger: #ea5455;
    --border: #ebe9f1;
    --shadow: 0 4px 24px 0 rgba(34, 41, 47, 0.1);
    --sidebar-width: 260px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.5;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-heading);
    font-weight: 500;
    font-size: 20px;
}
h3,h4 {margin-bottom:10px;}

.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}
.app-brand .app-brand-text {
  margin-inline-start: 0.75rem;
  opacity: 1;
  transition: opacity 0.3s ease-in-out;
  color: var(--bs-primary) !important;
  font-family: 'Nunito', sans-serif;
  font-size: 28px;
  font-weight: 800 !important;
}
/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-card);
    border-right: none;
    box-shadow: 0 0 15px 0 rgba(34, 41, 47, 0.05);
    display: flex;
    flex-direction: column;
    z-index: 10;
    transition: width 0.3s ease;
}

.sidebar.collapsed {
    width: 65px;
}
.sidebar.collapsed .logo {
    justify-content: center !important;
    padding: 13px 0;
}
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .user-info {
    display: none !important;
}
.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 10px 0;
    margin: 0 10px 5px 10px;
}
.sidebar.collapsed .nav-item iconify-icon {
    margin-right: 0 !important;
}
.sidebar.collapsed .user-profile {
    align-items: center;
}
.sidebar.collapsed #logout-btn {
    padding: 0.486rem;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
}
.sidebar.collapsed .logout-icon {
    display: block !important;
}

.logo {
    padding: 13px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
}

.logo h2 {
    color: var(--primary);
    font-size: 1.5rem;
    font-weight: 600;
}

.main-nav {
    flex: 1;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
}

.nav-item {
    margin: 0 15px 5px 15px;
    padding: 10px 15px;
    border-radius: 6px;
    color: var(--text-heading);
    text-decoration: none;
    transition: all 0.2s ease-in-out;
    display: flex;
    align-items: center;
}

.nav-item:hover {
    background-color: var(--bg-hover);
}

.nav-item.active {
    background-color: var(--bg-gray);
    color: white;
    box-shadow: 0 2px 8px 0 rgba(136, 136, 136, 0.4);
    transform: none;
}

.user-profile {
    padding: 20px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.top-header {
    padding: 18px 30px;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
}

.content-area {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
}

/* Auth Overlay */
.auth-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--bg-dark);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.auth-card {
    background-color: var(--bg-card);
    padding: 40px;
    border-radius: 8px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow);
}

.auth-card h2 {
    margin-bottom: 20px;
    text-align: center;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 2px;
    color: var(--text-primary);
    font-size: 0.85rem;
}

.form-group input, .form-group select, .form-group textarea, #cl-audience, #cc-rec-mode, #tr-filter,#b-card-transport,
.form-control,#set-wipe-phrase,#am-pts-client,#qs-client,#am-idx-dir,
.am-grp,.am-band,.am-dir,.am-topgrp,#cc-tm-mode,
.am-client,.am-range,#am-s3r-mode,#am-s3r-status,#am-acc-level {
    width: 100%;
    padding: 0.571rem 1rem;
    background-color: #fff;
    border: 1px solid #d8d6de;
    color: var(--text-primary);
    border-radius: 0.357rem;
    font-family: inherit;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
#cl-audience,#tr-filter,#b-card-transport, #cc-rec-mode,#set-wipe-phrase {width: 25%;}
#am-pts-client,#qs-client,#am-idx-dir,
.am-grp,.am-band,.am-dir,.am-topgrp {width: 130px;}
#am-s3r-mode,#am-s3r-status,#am-acc-level,.am-client {width: 130px;}
.am-range {width: 120px;}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus, .form-control:focus,
.am-grp:focus,.am-band:focus,.am-dir:focus,.am-topgrp:focus,#am-idx-dir:focus,#am-pts-client:focus,#qs-client:focus,
.am-client:focus,.am-range:focus,#am-s3r-mode:focus,#am-s3r-status:focus,#am-acc-level:focus,
#cc-tm-mode:focus {
    outline: none;
    border: 2px solid var(--primary);
    padding: calc(0.571rem - 1px) calc(1rem - 1px);
    box-shadow: 0 3px 10px 0 rgba(103, 140, 28, 0.1);
}

/* Однакова ширина полів фільтра у звітах — як у селектів .am-grp (130px).
   Клас вішається і на input дати: flatpickr копіює className на свій altInput,
   тож видиме поле теж отримує цю ширину (inline-style він не переносить). */
/* селектор з елементом — інакше правило .form-group input {width:100%} вище
   перебиває його за специфічністю і поле лишається розтягнутим */
.form-group input.flt-w130, input.flt-w130 {
    width: 130px;
    min-width: 130px;
    flex: 0 0 auto;
}

/* Autocomplete (location pickers) */
.ac-wrap { position: relative; }
.ac-list {
    position: absolute;
    z-index: 50;
    left: 0; right: 0;
    top: calc(100% + 2px);
    background: #fff;
    border: 1px solid #d8d6de;
    border-radius: 0.357rem;
    box-shadow: 0 6px 18px rgba(0,0,0,0.12);
    max-height: 240px;
    overflow-y: auto;
    display: none;
}
.ac-list.open { display: block; }
/* Варіант для вузьких полів (фільтри міст у звітах): список не прив'язаний до
   ширини input — розтягується під найдовше значення, щоб «Городище-Пустоварівське
   — Київська обл.» не переносилось на другий рядок. */
.ac-list.ac-list-fit {
    right: auto;
    min-width: 100%;
    width: max-content;
    max-width: 460px;
}
.ac-list-fit .ac-item {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ac-item { padding: 0.5rem 0.85rem; cursor: pointer; font-size: 0.9rem; }
.ac-item:hover, .ac-item.active { background: var(--bg-hover); }
.ac-item small { color: var(--text-secondary); }
.ac-empty { padding: 0.5rem 0.85rem; color: var(--text-secondary); font-size: 0.85rem; }

/* Mode toggle + divider */
.mode-divider {
    border: none;
    border-top: 2px dashed var(--border);
    margin: 28px 0;
}
.mode-toggle { display: flex; gap: 22px; margin-bottom: 18px; flex-wrap: wrap; }

/* currency segmented switch (Mode B result) */
.cur-seg { display: inline-flex; border: 1px solid #d8d6de; border-radius: 0.357rem; overflow: hidden; }
.cur-seg-btn {
    border: none; background: #fff; color: var(--text-secondary);
    padding: 5px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
    border-left: 1px solid #d8d6de; transition: background .12s, color .12s;
}
.cur-seg-btn:first-child { border-left: none; }
.cur-seg-btn:hover { background: #f3f2f7; }
.cur-seg-btn.active { background: var(--primary); color: #fff; }
.mode-toggle label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; font-size: 1.05rem; }
.mode-toggle input[type="radio"] {
    appearance: none; -webkit-appearance: none;
    width: 22px; height: 22px; border: 2px solid #d8d6de; border-radius: 50%;
    margin: 0; position: relative; cursor: pointer; transition: all 0.2s ease-in-out; background: #fff;
}
.mode-toggle input[type="radio"]:hover { border-color: var(--primary); box-shadow: 0 0 6px rgba(103, 140, 28, 0.2); }
.mode-toggle input[type="radio"]:checked { border-color: var(--primary); }
.mode-toggle input[type="radio"]:checked::after {
    content: ''; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 12px; height: 12px; background: var(--primary); border-radius: 50%;
}


.btn {
    padding: 0.586rem 1.5rem;
    border: none;
    border-radius: 0.358rem;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease-in-out;
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 2px 4px 0 rgba(103, 140, 28, 0.4);
    font-family: 'Inter', sans-serif;
    text-transform: uppercase;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 8px 0 rgba(103, 140, 28, 0.4);
    text-transform: uppercase;
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--primary);
    font-family: 'Inter', sans-serif;
}

.btn-outline:hover {
    background-color: rgba(103, 140, 28, 0.05);
}

.btn-sm {
    padding: 0.606rem 1rem;
    font-size: 0.857rem;
}

.w-100 {
    width: 100%;
}

.error-msg {
    color: var(--danger);
    font-size: 0.857rem;
    margin-bottom: 15px;
    text-align: center;
}

/* Cards & Utilities */
.card {
    background-color: var(--bg-card);
    border-radius: 6px;
    padding: 1.5rem;
    border: none;
    box-shadow: 0px 0px 2px rgba(145, 158, 171, 0.2), 0px 12px 24px -4px rgba(145, 158, 171, 0.12);
    margin-bottom: 2rem;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

/* Tables — Vuexy style (зебра-роздільники, hover, заголовки) */
.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
}
.table thead th {
    text-align: left;
    padding: 0.72rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    background: var(--bg-hover);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table thead th:first-child { border-top-left-radius: 6px; }
.table thead th:last-child  { border-top-right-radius: 6px; }
.table tbody td {
    padding: 0.72rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table tbody tr { transition: background-color 0.15s ease-in-out; }
.table tbody tr:hover { background: var(--bg-hover); }
.table tbody tr:last-child td { border-bottom: none; }

/* Icon-only action buttons */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    margin-right: 6px;
    border: 1px solid var(--border);
    border-radius: 0.357rem;
    background: #fff;
    color: var(--text-heading);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    transition: all 0.15s ease-in-out;
    vertical-align: middle;
}
.icon-btn:last-child { margin-right: 0; }
.icon-btn:hover { background: var(--bg-hover); transform: translateY(-1px); }
.icon-btn.primary { color: var(--primary); }
.icon-btn.primary:hover { background: rgba(103, 140, 28, 0.08); border-color: var(--primary); }
.icon-btn.danger { color: var(--danger); }
.icon-btn.danger:hover { background: rgba(234, 84, 85, 0.08); border-color: var(--danger); }
.icon-btn.warn { color: var(--warning); }
.icon-btn.warn:hover { background: rgba(255, 159, 67, 0.08); border-color: var(--warning); }
.icon-btn.success { color: var(--success); }
.icon-btn.success:hover { background: rgba(40, 199, 111, 0.08); border-color: var(--success); }
.icon-btn iconify-icon { display: block; }

/* «Скинути фільтри» — голий хрестик поруч із кнопками, без рамки й фону */
.flt-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 2px;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.15rem;
    line-height: 1;
    transition: color 0.15s ease-in-out;
}
.flt-clear:hover { color: var(--danger); }

/* Info toggle button (instructions hidden behind it) */
.info-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border: none;
    color: var(--warning); background: transparent;
    cursor: pointer; font-size: 24px; line-height: 1;
    transition: all 0.15s ease-in-out; vertical-align: middle;
}
.info-btn:hover { opacity: 0.7; }
.help-box {
    background: #eef6ff;
    padding: 12px 14px;
    border-radius: 6px;
    margin-bottom: 14px;
    font-size: 13px;
    line-height: 1.55;
    border-left: 3px solid var(--primary);
}

/* Flatpickr — підганяємо акцент під тему */
.flatpickr-day.selected,
.flatpickr-day.selected:hover,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
    background: var(--primary);
    border-color: var(--primary);
}
.flatpickr-day.today { border-color: var(--primary); }
.flatpickr-day:hover { background: var(--bg-hover); }
.flatpickr-months .flatpickr-month,
.flatpickr-current-month .flatpickr-monthDropdown-months { color: var(--text-heading); }

/* Spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
