/* === RESET & BASE === */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    background: #f5f7fa;
}

/* === HEADER === */
.header {
    background: #2c3e50;
    color: white;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header h1 {
    font-size: 20px;
    font-weight: 500;
}

.header-subtitle {
    font-size: 12px;
    opacity: 0.8;
}

.header-org {
    font-size: 14px;
    opacity: 0.9;
}

/* === CONTAINER === */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* === TOOLBAR === */
.toolbar {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 250px;
}

.search-box input {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.search-box input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.filters select {
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    min-width: 150px;
}

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.btn-outline {
    background: transparent;
    border: 1px solid #3498db;
    color: #3498db;
}

.btn-outline:hover {
    background: #3498db;
    color: white;
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-success {
    background: #27ae60;
    color: white;
}

.btn-success:hover {
    background: #219a52;
}

/* === TABLE === */
.cards-table-wrapper {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    overflow: hidden;
}

.cards-table {
    width: 100%;
    border-collapse: collapse;
}

.cards-table th,
.cards-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.cards-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #555;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cards-table tr:hover {
    background: #f8f9fa;
}

.cards-table a {
    color: #3498db;
    text-decoration: none;
}

.cards-table a:hover {
    text-decoration: underline;
}

.cards-table .actions {
    display: flex;
    gap: 8px;
}

.empty-state {
    text-align: center;
    color: #888;
    padding: 40px !important;
}

/* === STATUS BADGES === */
.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
}

.status-draft {
    background: #ffeaa7;
    color: #856404;
}

.status-active {
    background: #d4edda;
    color: #155724;
}

.status-discharged {
    background: #cce5ff;
    color: #004085;
}

/* === PAGINATION === */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
}

.pagination-info {
    color: #666;
    font-size: 13px;
}

/* === MODAL === */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 8px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #888;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
}

/* === FORMS === */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
    font-size: 13px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.form-group textarea {
    min-height: 80px;
    resize: vertical;
}

.form-row {
    display: flex;
    gap: 15px;
}

.form-row .form-group {
    flex: 1;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

/* === CARD FORM PAGE === */
.card-form-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.card-form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.card-form-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.card-number {
    color: #888;
    font-size: 14px;
}

/* === SECTIONS / TABS === */
.sections-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
}

.section-tab {
    padding: 8px 16px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    color: #666;
    transition: all 0.2s;
}

.section-tab:hover {
    background: #e9ecef;
}

.section-tab.active {
    background: #3498db;
    color: white;
}

/* === SECTION CONTENT === */
.section-content {
    display: none;
    padding: 20px;
}

.section-content.active {
    display: block;
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #3498db;
    color: #2c3e50;
}

.subsection-title {
    font-size: 14px;
    font-weight: 600;
    margin: 20px 0 15px;
    color: #555;
}

/* === CHECKBOX === */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.checkbox-item label {
    font-size: 14px;
    cursor: pointer;
}

/* === OPERATIONS TABLE === */
.dynamic-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 15px;
}

.dynamic-table th,
.dynamic-table td {
    padding: 10px;
    border: 1px solid #ddd;
    text-align: left;
}

.dynamic-table th {
    background: #f8f9fa;
    font-weight: 500;
    font-size: 12px;
}

.dynamic-table input,
.dynamic-table select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.add-row-btn {
    margin-top: 10px;
}

/* === SAVE BAR === */
.save-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    padding: 15px 30px;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
}

.save-bar .save-status {
    color: #888;
    font-size: 13px;
}

.save-bar .save-status.saved {
    color: #27ae60;
}

.save-bar .save-status.saving {
    color: #f39c12;
}

/* === AUTOCOMPLETE === */
.autocomplete-wrapper {
    position: relative;
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: none;
}

.autocomplete-dropdown.active {
    display: block;
}

.autocomplete-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}

.autocomplete-item:hover {
    background: #f8f9fa;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item .code {
    font-weight: 600;
    color: #3498db;
}

.autocomplete-item .name {
    font-size: 13px;
    color: #666;
}

/* === PRINT STYLES === */
@media print {
    body {
        background: white;
        font-size: 11pt;
    }

    .header,
    .toolbar,
    .save-bar,
    .sections-nav,
    .no-print {
        display: none !important;
    }

    .container {
        max-width: 100%;
        padding: 0;
    }

    .card-form-container {
        box-shadow: none;
        border: none;
    }

    .section-content {
        display: block !important;
        page-break-inside: avoid;
    }

    .section-content.empty {
        display: none !important;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        border: none;
        padding: 0;
        background: transparent;
    }

    .print-header {
        display: block !important;
        text-align: center;
        margin-bottom: 20px;
    }

    .print-header .org-name {
        font-size: 12pt;
        margin-bottom: 5px;
    }

    .print-header .form-title {
        font-size: 14pt;
        font-weight: bold;
        margin-bottom: 10px;
    }

    .print-header .form-number {
        font-size: 10pt;
        color: #666;
    }

    .print-table {
        width: 100%;
        border-collapse: collapse;
    }

    .print-table td {
        padding: 3px 5px;
        vertical-align: top;
    }

    .print-table .label {
        font-size: 9pt;
        color: #666;
    }

    .print-table .value {
        font-size: 11pt;
        border-bottom: 1px solid #333;
    }
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }

    .toolbar {
        flex-direction: column;
    }

    .search-box {
        width: 100%;
    }

    .form-row {
        flex-direction: column;
    }

    .cards-table {
        font-size: 12px;
    }

    .cards-table .actions {
        flex-direction: column;
    }

    .sections-nav {
        overflow-x: auto;
        flex-wrap: nowrap;
    }
}
