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

:root {
    --primary:    #1a3a5c;
    --primary-lt: #2c6fad;
    --accent:     #e67e22;
    --success:    #27ae60;
    --danger:     #e74c3c;
    --warning:    #f39c12;
    --bg:         #f0f4f8;
    --card-bg:    #ffffff;
    --border:     #dee2e6;
    --text:       #2d3748;
    --muted:      #718096;
    --radius:     10px;
    --shadow:     0 2px 12px rgba(0,0,0,0.08);
}

html, body {
    width: 100%;
}
body {
    font-family: Calibri, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: 15px;
    line-height: 1.5;
}

/* ───── HEADER ───── */
.site-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-lt) 100%);
    color: #fff;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    width: 100%;
}
.header-inner {
    max-width: none;
    width: 100%;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.header-logo { display: flex; align-items: center; gap: 16px; }
.logo-icon {
    width: 50px; height: 50px;
    background: rgba(255,255,255,0.18);
    border: 2px solid rgba(255,255,255,0.35);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; font-weight: 700; letter-spacing: 1px; color: #fff;
}
.header-logo h1 { font-size: 21px; font-weight: 700; letter-spacing: 0.5px; }
.header-logo p  { font-size: 12px; opacity: 0.8; margin-top: 2px; }
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.header-user {
    font-size: 13px;
    opacity: 0.85;
}
.btn-logout {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 7px;
    padding: 5px 14px;
    font-size: 12px;
    color: #fff;
    text-decoration: none;
    font-family: Calibri, sans-serif;
    font-weight: 600;
    transition: background 0.2s;
}
.btn-logout:hover {
    background: rgba(255,255,255,0.3);
}
.gear-menu-wrap {
    position: relative;
}
.gear-btn {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.gear-btn:hover {
    background: rgba(255,255,255,0.3);
}
.gear-dropdown {
    display: none;
    position: absolute;
    top: 44px;
    right: 0;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    min-width: 200px;
    z-index: 200;
    overflow: hidden;
    border: 1px solid var(--border);
}
.gear-dropdown.show {
    display: block;
}
.gear-item {
    display: block;
    padding: 10px 16px;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    font-family: Calibri, sans-serif;
    transition: background 0.15s;
}
.gear-item:hover {
    background: var(--bg);
}
.gear-item--active {
    background: #edf2f7;
    font-weight: 600;
}
.gear-item--danger {
    color: var(--danger);
}
.gear-item--danger:hover {
    background: #fdeaea;
}
.gear-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}
.header-date-val {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 8px;
    padding: 7px 15px;
    font-size: 13px; font-weight: 600;
}
.page-back {
    margin-top: 16px;
}
.info-table {
    font-size: 14px;
}
.info-table td {
    padding: 4px 12px 4px 0;
}

/* ───── INVESTMENT BAR ───── */
.inv-bar {
    background: #0f2a45;
    border-bottom: 3px solid var(--accent);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 3px 12px rgba(0,0,0,0.25);
    width: 100%;
}
.inv-bar-inner {
    max-width: none;
    width: 100%;
    margin: 0 auto;
    padding: 10px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.inv-selector-group {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}
.inv-bar-label {
    color: rgba(255,255,255,0.6);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    white-space: nowrap;
}
.inv-select-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}
.inv-select {
    background: rgba(255,255,255,0.12);
    border: 1.5px solid rgba(255,255,255,0.25);
    border-radius: 8px;
    color: #fff;
    padding: 8px 36px 8px 14px;
    font-family: Calibri, sans-serif;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23ffffff' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    flex: 1;
    min-width: 200px;
    max-width: 520px;
    transition: border-color 0.2s, background 0.2s;
}
.inv-select:focus { outline: none; border-color: var(--accent); background-color: rgba(255,255,255,0.18); }
.inv-select option { background: #1a3a5c; color: #fff; font-weight: normal; }
.inv-hint { color: rgba(255,255,255,0.5); font-size: 13px; font-style: italic; }
.btn-inv-manage {
    background: rgba(255,255,255,0.1);
    border: 1.5px solid rgba(255,255,255,0.25);
    color: rgba(255,255,255,0.85);
    border-radius: 8px;
    padding: 8px 16px;
    font-family: Calibri, sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s, border-color 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}
.btn-inv-manage:hover { background: rgba(255,255,255,0.2); border-color: var(--accent); color: #fff; }

/* ───── MAIN CONTAINER ───── */
.container {
    max-width: none;
    width: 100%;
    margin: 0 auto;
    padding: 24px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* ───── ALERTS ───── */
.alert {
    padding: 13px 18px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 14px;
}
.alert-success { background: #d4edda; color: #155724; border-left: 4px solid var(--success); }
.alert-error   { background: #f8d7da; color: #721c24; border-left: 4px solid var(--danger); }

/* ───── CARDS ───── */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px 24px;
}
.card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 9px;
}
.icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 27px; height: 27px;
    background: var(--primary);
    color: #fff;
    border-radius: 6px;
    font-size: 13px;
}

/* ───── MANAGE PANEL ───── */
.manage-panel { border-top: 3px solid var(--accent); }
.manage-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.manage-header .card-title { margin-bottom: 0; }
.btn-close-manage {
    background: none; border: none; font-size: 18px; cursor: pointer;
    color: var(--muted); line-height: 1; padding: 4px 8px; border-radius: 6px;
    transition: background 0.15s;
}
.btn-close-manage:hover { background: #f0f0f0; color: var(--danger); }
.manage-body { display: flex; gap: 28px; flex-wrap: wrap; }
.manage-add { flex: 0 0 420px; min-width: 280px; }
.manage-list { flex: 1; min-width: 280px; }
.manage-subtitle {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border);
}

/* ───── INVESTMENT FORM ───── */
.inv-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}
.inv-fg-full { grid-column: 1 / -1; }
.inv-form--edit { background: #f8f9fc; border-radius: 8px; padding: 14px; margin-top: 12px; }
.auto-name-hint {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 7px;
    padding: 9px 13px;
    font-size: 12px;
    color: #166534;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.auto-name-icon { font-size: 14px; }
.name-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fefce8;
    border: 1.5px solid #fde68a;
    border-radius: 7px;
    padding: 9px 14px;
    margin-bottom: 12px;
}
.np-label { font-size: 12px; color: #92400e; font-weight: 600; white-space: nowrap; }
.np-value { font-size: 14px; color: #78350f; font-weight: 700; }
.powiat-info-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 7px;
    padding: 10px 14px;
    font-size: 12px;
    color: #1e40af;
    margin-bottom: 14px;
    line-height: 1.5;
}
.powiat-info-icon { margin-right: 5px; }

/* ───── INVESTMENT LIST ───── */
.inv-list { display: flex; flex-direction: column; gap: 10px; }
.inv-item {
    border: 1.5px solid var(--border);
    border-radius: 9px;
    padding: 12px 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.inv-item:hover { border-color: var(--primary-lt); box-shadow: 0 2px 8px rgba(44,111,173,0.1); }
.inv-item--active { border-color: var(--primary-lt); background: #eff6ff; }
.inv-item-main { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.inv-item-name { font-weight: 700; font-size: 14px; color: var(--primary); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inv-link { color: var(--primary); text-decoration: none; }
.inv-link:hover { text-decoration: underline; color: var(--primary-lt); }
.inv-current-badge {
    background: var(--primary-lt);
    color: #fff;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.inv-item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 12px;
    color: var(--muted);
    margin-top: 5px;
}
.meta-gmina  { color: #166534; font-size: 12px; }
.meta-powiat { color: #1e3a8a; font-size: 12px; font-weight: 600; }
.meta-spolka { color: #27ae60; font-size: 12px; font-weight: 600; }
.meta-docs {
    background: #f0f4f8;
    border-radius: 10px;
    padding: 1px 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
}
.inv-item-actions { display: flex; gap: 7px; align-items: flex-start; flex-shrink: 0; }
.inv-edit-form { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 12px; }

/* ───── NO INVESTMENT STATE ───── */
.no-inv-state {
    text-align: center;
    padding: 64px 24px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.no-inv-icon { font-size: 52px; margin-bottom: 16px; }
.no-inv-state h2 { font-size: 20px; color: var(--primary); margin-bottom: 10px; }
.no-inv-state p { color: var(--muted); font-size: 15px; line-height: 1.7; }

/* ───── INVESTMENT INFO CARD ───── */
.inv-info-card {
    background: linear-gradient(135deg, #0f2a45 0%, #1a3a5c 100%);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    color: #fff;
    padding: 18px 24px;
}
.inv-info-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}
.inv-info-title { display: flex; align-items: flex-start; gap: 14px; }
.inv-info-icon { font-size: 28px; line-height: 1; flex-shrink: 0; }
.inv-info-name { font-size: 20px; font-weight: 700; letter-spacing: 0.3px; line-height: 1.2; }
.inv-info-geo-row {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 8px;
}
.inv-geo-chip {
    background: rgba(255,255,255,0.13);
    border: 1px solid rgba(255,255,255,0.22);
    border-radius: 20px;
    padding: 3px 11px;
    font-size: 12px;
    color: rgba(255,255,255,0.8);
    white-space: nowrap;
}
.inv-geo-chip--city {
    background: rgba(255,255,255,0.2);
    color: #fff;
    font-weight: 600;
    border-color: rgba(255,255,255,0.35);
}
.inv-default-bar {
    display: flex;
    justify-content: flex-end;
    padding-top: 12px;
    margin-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.12);
}
.inv-default-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(255,215,0,0.18);
    border: 1px solid rgba(255,215,0,0.35);
    border-radius: 20px;
    padding: 5px 14px;
    font-size: 13px;
    font-weight: 600;
    color: #ffd700;
}
.btn-outline {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.4);
    color: rgba(255,255,255,0.85);
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-outline:hover {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,215,0,0.6);
    color: #ffd700;
}
.btn-sm { font-size: 13px; }
.inv-info-badges { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.inv-badge-group { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.inv-badge {
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    padding: 6px 14px;
    text-align: center;
    min-width: 110px;
}
.inv-badge--powiat { border-color: var(--accent); background: rgba(230,126,34,0.15); }
.inv-badge--spolka {
    border-color: rgba(46,204,113,0.5);
    background: rgba(46,204,113,0.15);
    margin-bottom: 4px;
}
.form-group--full { grid-column: 1 / -1; }
.inv-badge-label { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: 0.8px; opacity: 0.65; margin-bottom: 2px; }
.inv-badge-val { display: block; font-size: 14px; font-weight: 700; }
.starostwo-hint {
    font-size: 11px;
    color: rgba(255,255,255,0.55);
    display: flex;
    align-items: center;
    gap: 5px;
}
.sh-icon { font-size: 13px; }

/* ───── ADD FORM ───── */
.add-form .form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}
.form-group { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 180px; }
.form-group--sm  { min-width: 120px; flex: 0 0 120px; }
.form-group--btn { flex: 0 0 auto; min-width: auto; }
label { font-size: 13px; font-weight: 600; color: var(--primary); }
.req { color: var(--danger); }

input[type="text"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="email"],
input[type="tel"],
select {
    border: 1.5px solid var(--border);
    border-radius: 7px;
    padding: 8px 12px;
    font-family: Calibri, sans-serif;
    font-size: 14px;
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff;
    width: 100%;
}
input:focus, select:focus {
    outline: none;
    border-color: var(--primary-lt);
    box-shadow: 0 0 0 3px rgba(44,111,173,0.12);
}
input.field-valid, input.field-valid:focus {
    border-color: #22c55e !important;
    box-shadow: 0 0 0 2px rgba(34,197,94,0.15) !important;
}
input.field-invalid, input.field-invalid:focus {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 2px rgba(239,68,68,0.15) !important;
}

/* ───── BUTTONS ───── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: 7px;
    border: none;
    cursor: pointer;
    font-family: Calibri, sans-serif;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
    white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.btn:active { transform: translateY(0); }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-lt); }
.btn-secondary { background: #2c6fad; color: #fff; }
.btn-secondary:hover { background: #1a5a93; }
.btn-accent    { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #d35400; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-outline {
    background: #fff;
    border: 1.5px solid var(--border);
    color: var(--primary);
}
.btn-outline:hover { border-color: var(--primary-lt); background: #f0f4f8; }
.btn-sm { padding: 5px 12px; font-size: 13px; }

/* ───── TABLE ───── */
.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.table-header .card-title { margin-bottom: 0; }
.count-badge {
    background: var(--primary);
    color: #fff;
    border-radius: 20px;
    padding: 3px 12px;
    font-size: 12px;
    font-weight: 700;
}
.table-wrapper {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border);
}
.table-wrap table { width: 100%; border-collapse: collapse; }
.table-wrap th, .table-wrap td { padding: 10px 18px; }
.table-wrap th { text-align: left; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table thead tr { background: var(--primary); color: #fff; }
.data-table th {
    padding: 10px 13px;
    text-align: left;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
.data-table tbody tr { border-bottom: 1px solid var(--border); transition: background 0.15s; }
.data-table tbody tr:nth-child(even) { background: #f8f9fc; }
.data-table tbody tr:hover { background: #e8f0fb; }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table td { padding: 9px 13px; vertical-align: middle; }
.col-lp     { width: 46px; text-align: center; color: var(--muted); font-size: 12px; }
.col-date   { width: 108px; white-space: nowrap; }
.col-sm     { width: 86px; }
.col-status { width: 148px; }
.col-actions { min-width: 56px; text-align: center; white-space: nowrap; }
.scan-actions { display: flex; gap: 4px; align-items: center; justify-content: center; flex-wrap: nowrap; }
.center { text-align: center; }
.doc-name { font-weight: 600; }
.row-overdue { background: #fff5f5 !important; }
.row-overdue:hover { background: #ffe8e8 !important; }
.overdue-tag {
    display: inline-block;
    background: #fee2e2;
    color: #b91c1c;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 10px;
    margin-left: 6px;
    vertical-align: middle;
}
.text-danger { color: var(--danger); font-weight: 700; }

.status-select {
    border-radius: 20px;
    padding: 4px 10px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    border: none;
    width: 100%;
}
.status-w_toku       { background: #dbeafe; color: #1e40af; }
.status-odebrano     { background: #dcfce7; color: #166534; }
.status-uzupelnienie { background: #ffedd5; color: #9a3412; }
.inline-form { display: flex; }

.empty-state {
    text-align: center;
    padding: 42px 20px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.8;
}

/* ───── EXPORT SECTION ───── */
.actions-card .card-title { margin-bottom: 16px; }
.actions-row { display: flex; flex-wrap: wrap; gap: 22px; align-items: flex-start; }
.action-block { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 10px; }
.action-desc { font-size: 13px; color: var(--muted); }
.action-divider { width: 1px; background: var(--border); align-self: stretch; min-height: 60px; }
.email-row { display: flex; gap: 8px; flex-wrap: wrap; }
.email-input { flex: 1; min-width: 200px; }
.smtp-hint { font-size: 11px; color: var(--muted); line-height: 1.4; }

/* ───── FOOTER ───── */
.site-footer {
    background: var(--primary);
    color: rgba(255,255,255,0.55);
    text-align: center;
    padding: 13px;
    font-size: 12px;
    margin-top: auto;
}

/* ───── SPOLKI FORM ───── */
.spolka-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
}
.spolka-fg-full {
    grid-column: 1 / -1;
}
.spolka-inv-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.spolka-inv-label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: var(--primary);
    margin-bottom: 10px;
}
.spolka-inv-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 250px;
    overflow-y: auto;
    padding: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.spolka-inv-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s;
}
.spolka-inv-item:hover {
    background: rgba(26,58,92,0.06);
}
.spolka-inv-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}
.spolka-inv-name {
    font-weight: 600;
    color: var(--text);
}
.spolka-inv-meta {
    font-size: 12px;
    color: var(--muted);
}
.spolka-inv-item--taken {
    opacity: 0.5;
    cursor: not-allowed;
}
.spolka-inv-taken-hint {
    font-size: 11px;
    color: var(--accent);
    font-style: italic;
}
.dane-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 20px;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
}
.dane-bc-item {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}
.dane-bc-item:hover { text-decoration: underline; }
.dane-bc-item--active { font-weight: 700; color: var(--text); pointer-events: none; }
.dane-bc-sep { color: var(--muted); font-size: 16px; }
.dane-btn-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}
.dane-btn-wrap {
    display: flex;
    align-items: stretch;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.dane-btn {
    display: inline-flex;
    align-items: center;
    padding: 10px 18px;
    background: var(--primary);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: background 0.15s;
    white-space: nowrap;
}
.dane-btn:hover { background: var(--primary-lt); }
.dane-btn--sub { background: #2980b9; }
.dane-btn--sub:hover { background: #3498db; }
.dane-btn-del {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    background: var(--danger);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s;
}
.dane-btn-del:hover { background: #c0392b; }
.dane-add-form {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 8px;
}
.dane-add-input {
    flex: 1;
    max-width: 400px;
}
.dane-data-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.dane-data-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.dane-data-label {
    font-weight: 600;
    font-size: 14px;
    color: var(--primary);
    min-width: 160px;
    flex-shrink: 0;
}
.dane-data-input {
    flex: 1;
}
.dane-data-date {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.dane-date-label {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
}
.dane-date-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
}
.dane-date-input {
    width: 150px;
    padding: 4px 8px;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
}
.dane-date-input::-webkit-calendar-picker-indicator {
    cursor: pointer;
}
.dane-date-clear {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 4px;
    line-height: 1;
}
.dane-date-clear:hover {
    color: var(--danger);
}
.dane-data-del {
    flex-shrink: 0;
}
.scan-add-bar {
    padding: 12px 16px 0;
}
.inv-scan-bar {
    padding: 0 24px 12px;
}
.btn-xs {
    padding: 3px 8px;
    font-size: 12px;
}
.btn-scan-doc {
    background: #f0f4f8;
    color: var(--primary);
    border: 1px dashed var(--primary);
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s;
}
.btn-scan-doc:hover {
    background: #e2e8f0;
}
.scan-panel {
    margin: 0 24px 12px;
}
.scan-panel-inner {
    padding: 16px;
    background: #f0f4f8;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}
.scan-panel-title {
    margin: 0 0 6px;
    font-size: 15px;
    color: var(--primary);
}
.scan-panel-desc {
    font-size: 13px;
    color: var(--muted);
    margin: 0 0 12px;
}
.scan-upload-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.scan-full-text {
    margin-top: 10px;
    padding: 10px;
    background: #f8f9fa;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    user-select: text;
    -webkit-user-select: text;
    cursor: text;
    font-size: 12px;
    font-family: monospace;
    white-space: pre-wrap;
    max-height: 300px;
    overflow-y: auto;
    color: var(--text);
}
.scan-suggestion {
    margin-top: 4px;
    padding: 6px 10px;
    background: #e8f4fd;
    border: 1px solid #b8daff;
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--primary);
}
.scan-suggestion a {
    color: var(--primary);
    text-decoration: underline;
    cursor: pointer;
}
.scan-custom-fields {
    margin-top: 8px;
}
.scan-custom-field-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 6px;
    flex-wrap: wrap;
}
.scan-prompt-row {
    display: flex;
    gap: 8px;
    align-items: center;
    width: 100%;
    padding: 6px 0 2px;
}
.scan-prompt-row .scan-cf-prompt {
    flex: 1;
    min-width: 200px;
    font-size: 13px;
    border: 1px dashed #ffc107;
    background: #fffdf0;
}
.scan-custom-field-row .scan-cf-name {
    flex: 1;
    min-width: 120px;
}
.scan-custom-field-row .scan-cf-value {
    flex: 2;
    min-width: 150px;
}
.btn-extract {
    white-space: nowrap;
    flex-shrink: 0;
}
.scan-extra-fields {
    padding: 8px 0;
}
.scan-extra-field {
    padding: 3px 0;
    font-size: 13px;
}
.assign-panel {
    margin-top: 12px;
    padding: 12px 14px;
    border: 2px solid var(--primary);
    border-radius: 8px;
    background: #f0f8ff;
}
.assign-panel-header {
    margin-bottom: 8px;
}
.assign-preview {
    display: inline-block;
    margin-left: 6px;
    font-size: 13px;
    color: #1e40af;
    font-style: italic;
    max-width: 100%;
    word-break: break-word;
}
.assign-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}
.assign-field-btn {
    white-space: nowrap;
}
.scan-form-section {
    margin-bottom: 8px;
}
.ocr-section {
    margin-top: 24px;
    padding: 16px;
    background: #f0f4f8;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}
.ocr-title {
    margin: 0 0 6px;
    font-size: 15px;
    color: var(--primary);
}
.ocr-desc {
    font-size: 13px;
    color: var(--muted);
    margin: 0 0 12px;
}
.ocr-upload-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.ocr-file-input {
    font-size: 13px;
}
.ocr-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    font-size: 13px;
    color: var(--primary);
}
.ocr-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: ocr-spin 0.8s linear infinite;
}
@keyframes ocr-spin {
    to { transform: rotate(360deg); }
}
.ocr-result {
    margin-top: 12px;
    padding: 12px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.ocr-result-fields {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}
.ocr-field {
    flex: 1;
    min-width: 180px;
}
.ocr-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 4px;
}
.ocr-field-input {
    width: 100%;
    padding: 6px 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    background: #f8f9fa;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.ocr-error {
    margin-top: 12px;
    padding: 10px;
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    font-size: 13px;
}
@media (max-width: 600px) {
    .spolka-form-grid {
        grid-template-columns: 1fr;
    }
    .spolka-fg-full {
        grid-column: 1;
    }
    .dane-data-row {
        flex-direction: column;
        align-items: stretch;
    }
    .dane-data-label {
        min-width: auto;
    }
    .dane-add-form {
        flex-direction: column;
        align-items: stretch;
    }
    .dane-add-input {
        max-width: 100%;
    }
}

/* ───── TEMPLATE EDITOR ───── */
.tpl-editor-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
    align-items: start;
}
.tpl-preview-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px;
    background: #f8fafc;
}
.tpl-preview {
    position: relative;
    cursor: crosshair;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}
.tpl-field-marker {
    position: absolute;
    background: rgba(44, 111, 173, 0.18);
    border: 1px solid var(--primary-lt);
    border-radius: 2px;
    padding: 1px 4px;
    color: var(--primary);
    font-weight: 600;
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    height: auto;
    line-height: 1.3;
}
.tpl-fields-panel {
    max-height: 80vh;
    overflow-y: auto;
    padding: 12px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.tpl-field-item {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px;
    margin-bottom: 6px;
}
.tpl-field-item:hover {
    border-color: var(--primary-lt);
}
@media (max-width: 900px) {
    .tpl-editor-layout {
        grid-template-columns: 1fr;
    }
}

/* ───── SETTINGS TABS ───── */
.settings-tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    background: #f8fafc;
}
.settings-tab {
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}
.settings-tab:hover {
    color: var(--primary);
    background: rgba(26,58,92,0.04);
}
.settings-tab--active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: var(--card-bg);
}

/* ───── GANTT CHART ───── */
.gantt-wrapper { padding: 16px; }
.gantt-scroll {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.gantt-table {
    border-collapse: collapse;
    table-layout: fixed;
    width: 100%;
}
.gantt-table th,
.gantt-table td {
    border: 1px solid #e8ecf0;
    padding: 0;
    text-align: center;
    vertical-align: middle;
}
.gantt-label-col {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--card-bg);
    min-width: 180px;
    max-width: 220px;
    padding: 6px 10px !important;
    text-align: left !important;
    font-size: 12px;
    border-right: 2px solid var(--border) !important;
}
.gantt-doc-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
    color: var(--text);
}
.gantt-day-col {
    width: 32px;
    min-width: 32px;
    padding: 4px 2px !important;
    background: var(--card-bg);
}
.gantt-day-name {
    font-size: 9px;
    color: var(--muted);
    text-transform: uppercase;
    font-weight: 600;
    line-height: 1;
}
.gantt-day-num {
    font-size: 11px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
}
.gantt-month {
    font-size: 8px;
    color: var(--primary-lt);
    font-weight: 700;
    text-transform: uppercase;
    line-height: 1;
    margin-top: 1px;
}
.gantt-weekend {
    background: #e8f4fd !important;
}
.gantt-today {
    background: #fff3cd !important;
}
.gantt-cell {
    height: 28px;
    padding: 2px 0 !important;
    position: relative;
}
.gantt-bar {
    height: 18px;
    background: var(--primary-lt);
    margin: 0 -1px;
    position: relative;
}
.gantt-bar--start {
    margin-left: 2px;
    border-radius: 4px 0 0 4px;
}
.gantt-bar--end {
    margin-right: 2px;
    border-radius: 0 4px 4px 0;
}
.gantt-bar--start.gantt-bar--end {
    border-radius: 4px;
    margin: 0 2px;
}
.gantt-bar--done {
    background: var(--success);
}
.gantt-bar--overdue {
    background: var(--danger);
}
.gantt-bar--supplement {
    background: var(--warning);
}
.gantt-legend {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    padding: 12px 0 0;
    font-size: 12px;
    color: var(--muted);
}
.gantt-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}
.gantt-legend-color {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid rgba(0,0,0,0.1);
}
.gantt-legend--active { background: var(--primary-lt); }
.gantt-legend--done { background: var(--success); }
.gantt-legend--supplement { background: var(--warning); }
.gantt-legend--overdue { background: var(--danger); }
.gantt-legend--weekend { background: #e8f4fd; }
.gantt-legend--today { background: #fff3cd; }

/* ───── AUTOCOMPLETE ───── */
.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1.5px solid var(--border);
    border-radius: 0 0 7px 7px;
    max-height: 160px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.ac-item {
    padding: 7px 12px;
    cursor: pointer;
    font-size: 13px;
    font-family: Calibri, sans-serif;
}
.ac-item:hover {
    background: var(--primary);
    color: white;
}
/* ───── NABYWCA FORM ───── */
.nab-fieldset input,
.nab-fieldset select {
    font-family: Calibri, sans-serif;
}

/* ───── RESPONSIVE ───── */
@media (max-width: 768px) {
    .header-inner  { flex-direction: column; gap: 10px; text-align: center; }
    .header-logo   { flex-direction: column; }
    .inv-bar-inner { flex-direction: column; align-items: stretch; gap: 10px; }
    .inv-select    { max-width: 100%; }
    .inv-info-header { flex-direction: column; }
    .inv-info-badges { align-items: flex-start; }
    .inv-badge-group { justify-content: flex-start; }
    .manage-body   { flex-direction: column; }
    .manage-add    { flex: none; }
    .inv-form-grid { grid-template-columns: 1fr; }
    .inv-fg-full   { grid-column: 1; }
    .actions-row   { flex-direction: column; }
    .action-divider { width: 100%; height: 1px; min-height: 0; }
    .form-group    { min-width: 100%; }
    .form-group--sm { flex: 1 1 100%; }
}
