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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Verdana, Arial, sans-serif;
    background: linear-gradient(135deg, #f5f5f5 0%, #ffffff 100%);
    color: #333;
    min-height: 100vh;
}

.container {
    width: 100%;
    margin: 0;
    padding: 20px 30px;
}

/* Header Styles */
header {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: white;
    padding: 40px 30px;
    margin: -20px -30px 40px -30px;
    border-bottom: 4px solid #667eea;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    width: calc(100% + 60px);
}

h1 {
    font-size: 2.2em;
    margin-bottom: 10px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 1em;
    color: #d0d0d0;
    margin-bottom: 20px;
}

.stats {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
    margin-top: 25px;
}

.stat-box {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.stat-number {
    font-size: 1.8em;
    font-weight: bold;
    color: #667eea;
}

.stat-label {
    font-size: 0.95em;
    color: #b0b0b0;
}

/* Table Controls */
.table-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    background: white;
    padding: 15px 20px;
    padding-left: 25px;
    padding-right: 25px;
    border-radius: 4px;
    border: 1px solid #ddd;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-group label {
    font-weight: 500;
    color: #555;
    font-size: 0.95em;
}

.dt-length select,
.dt-search input {
    padding: 8px 12px;
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    color: #333;
    font-size: 0.95em;
    font-family: inherit;
    transition: all 0.2s ease;
}

.dt-length select:hover,
.dt-search input:hover {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.dt-length select:focus,
.dt-search input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.dt-search input::placeholder {
    color: #999;
}

/* Table Wrapper */
.table-wrapper {
    background: white;
    border-radius: 4px;
    overflow: visible;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    border: 2px solid #ccc;
    margin-bottom: 20px;
    position: relative;
}

.dt-scroll {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1200px;
    border: 1px solid #ccc;
}

thead {
    background: #f8f9fa;
    border-bottom: 2px solid #ddd;
}

th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: #333;
    font-size: 0.9em;
    white-space: nowrap;
    user-select: none;
    border-right: 1px solid #eee;
    cursor: pointer;
    position: relative;
    transition: background-color 0.2s ease;
    height: 40px;
    vertical-align: middle;
}

th:hover {
    background: #f0f0f0;
}

th.sortable::after {
    content: ' ⇅';
    opacity: 0.4;
    font-size: 0.85em;
}

th.sort-asc::after {
    content: ' ▲';
    opacity: 1;
}

th.sort-desc::after {
    content: ' ▼';
    opacity: 1;
}

th:last-child {
    border-right: none;
}

tbody tr {
    border-bottom: 1px solid #eee;
    transition: background-color 0.15s ease;
}

tbody tr:hover {
    background: #f8f9fa;
}

tbody tr:last-child {
    border-bottom: none;
}

td {
    padding: 10px 12px;
    color: #333;
    font-size: 0.9em;
    border-right: 1px solid #eee;
    height: 40px;
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

td:last-child {
    border-right: none;
}

td a {
    color: #0645ad;
    text-decoration: none;
    transition: color 0.2s;
    cursor: pointer;
}

td a:hover {
    color: #3366cc;
    text-decoration: underline;
}

img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

/* Data Table Layout */
.dt-container {
    margin: 0;
    padding: 0 20px;
}

.dt-layout-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    padding: 0;
    background: transparent;
    border: none;
    margin: 0;
    justify-content: space-between;
    align-items: center;
    overflow-x: show;
}

.dt-layout-row:first-of-type {
    margin-bottom: 20px;
    padding: 15px 5px;
}

.dt-layout-row:last-of-type {
    margin-top: 20px;
    padding: 15px 5px;
}

.dt-layout-cell {
    flex: 1;
    min-width: 150px;
}

.dt-layout-cell.dt-layout-full {
    flex-basis: 100%;
}

.dt-layout-cell.dt-layout-start {
    flex-grow: 0;
}

.dt-layout-cell.dt-layout-end {
    flex-grow: 0;
    text-align: right;
    /* default: no large padding here, specific rows get their own spacing */
    padding-right: 0;
}

/* Top row (controls) - give space for the search box at the right */
.dt-layout-row:first-of-type .dt-layout-cell.dt-layout-end {
    padding-right: 340px;
}

/* Bottom row (info + paging) - ensure pagination sits to the right in a single line */
.dt-layout-row:last-of-type .dt-layout-cell.dt-layout-end {
    padding-right: 0;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
}

/* Modals */
.modal { display: none; position: fixed; z-index: 1200; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.6); }
.modal[aria-hidden="false"] { display: block; }
.modal .modal-content { background: #fff; margin: 6% auto; padding: 18px; border-radius: 8px; width: 90%; max-width: 760px; box-shadow: 0 6px 30px rgba(11,22,44,0.5); }
.modal .modal-content.small { max-width: 420px; }
.modal .modal-content.image-modal { padding: 12px; text-align: center; width: 70vw; max-width: 70vw; max-height: 80vh; overflow: auto; }
.modal .image-close { background: transparent; border: 0; font-size: 28px; line-height: 1; position: absolute; right: 14px; top: 10px; cursor: pointer; }
.modal img { max-width: 100%; max-height: 70vh; height: auto; border-radius: 6px; }
.image-caption { margin-top: 8px; font-size: 0.95rem; color: #333; }

.loading-state { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; background:rgba(255,255,255,0.9); font-weight:600; color:#444; z-index:500; }
.hidden { display: none !important; }
.is-loading { opacity: 0.5; pointer-events: none; }

/* Column settings list */
#columnCheckboxes { display:flex; flex-wrap:wrap; gap:8px; }
#columnCheckboxes label { display:flex; align-items:center; gap:8px; padding:6px 8px; border-radius:6px; background:#f7f8fa; }

/* small control button */
.dt-button { background:#667eea; color:#fff; border:0; padding:6px 10px; border-radius:6px; cursor:pointer; margin-left:0; }
.dt-button:hover { background:#5566d6; }

/* Ensure the control button sits nicely left of the search input */
.dt-search .dt-button { margin-right: 8px; }
.dt-length {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dt-search {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 10px;
}

.dt-search input {
    width: 200px;
}

.dt-info {
    color: #666;
    font-size: 0.9em;
}

.dt-paging {
    display: flex;
    gap: 5px;
    justify-content: flex-end;
    padding-right: 5px;
}

.dt-paging-button {
    padding: 6px 10px;
    background: #f8f9fa;
    border: 1px solid #ccc;
    color: #333;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.2s ease;
    min-width: 32px;
    text-align: center;
}

/* Prevent pagination buttons from stacking vertically */
.dt-paging,
.dt-paging nav {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: nowrap;
}

.dt-paging-button {
    white-space: nowrap;
}

.dt-paging-button:hover:not(.disabled) {
    background: white;
    border-color: #667eea;
    color: #667eea;
}

.dt-paging-button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f5f5f5;
}

.dt-paging-button.current {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 40px;
    padding: 30px 20px;
    color: #666;
    font-size: 0.9em;
    border-top: 1px solid #eee;
}

/* Scrollbar Styling */
.table-wrapper::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}

.table-wrapper::-webkit-scrollbar-track {
    background: #f5f5f5;
}

.table-wrapper::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.table-wrapper::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Responsive Design */
@media (max-width: 768px) {
    h1 {
        font-size: 1.6em;
    }

    .subtitle {
        font-size: 0.95em;
    }

    .stats {
        gap: 20px;
    }

    .table-controls {
        flex-direction: column;
        align-items: flex-start;
    }

    .control-group {
        width: 100%;
    }

    .dt-search input {
        width: 100%;
    }

    th, td {
        padding: 10px 12px;
        font-size: 0.9em;
    }

    .dt-layout-row {
        flex-direction: column;
        gap: 10px;
    }

    .dt-layout-cell {
        width: 100%;
    }

    .dt-layout-cell.dt-layout-end {
        text-align: left;
    }

    .dt-paging {
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .dt-info {
        margin-bottom: 10px;
    }
}

@media (max-width: 480px) {
    header {
        padding: 20px 15px;
    }

    h1 {
        font-size: 1.3em;
    }

    .subtitle {
        font-size: 0.9em;
    }

    .stats {
        flex-direction: column;
        gap: 15px;
    }

    th, td {
        padding: 8px 10px;
        font-size: 0.85em;
    }

    .dt-paging-button {
        padding: 5px 8px;
        font-size: 0.85em;
        min-width: 28px;
    }
}
