:root {
    --rd-primary: #2c3e50;
    --rd-accent: #3498db;
    --rd-accent-dark: #2980b9;
    --rd-warning: #e74c3c;
    --rd-success: #27ae60;
    --rd-light: #ecf0f1;
    --rd-muted: #95a5a6;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f8f9fa;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.3rem;
    letter-spacing: -0.5px;
}

.navbar-brand i {
    color: var(--rd-accent);
}

.hero-section {
    background: linear-gradient(135deg, var(--rd-primary) 0%, #1a252f 100%);
    color: #fff;
    padding: 3rem 0 2rem;
}

.hero-section h1 {
    font-weight: 700;
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.hero-section .lead {
    opacity: 0.85;
}

.stat-card {
    background: rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.15);
}

.stat-card .stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    display: block;
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.7;
    margin-top: 0.25rem;
}

.content-section {
    padding: 1.5rem 0;
}

.filter-bar {
    background: #fff;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-bottom: 1rem;
}

.filter-bar .form-select,
.filter-bar .form-control {
    font-size: 0.875rem;
}

.action-buttons .btn {
    font-size: 0.8rem;
    padding: 0.4rem 0.75rem;
}

/* django-tables2 */
.table {
    font-size: 0.85rem;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.table thead th {
    background: var(--rd-primary);
    color: #fff;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
    padding: 0.6rem 0.5rem;
    white-space: nowrap;
}

.table thead th a {
    color: #fff !important;
    text-decoration: none;
}

.table thead th a:hover {
    color: var(--rd-light) !important;
}

.table tbody td {
    vertical-align: middle;
    padding: 0.45rem 0.5rem;
    border-color: #f0f0f0;
}

.table tbody tr:hover {
    background: #f8f9fa;
}

.table-striped > tbody > tr:nth-of-type(odd) > td {
    background-color: rgba(0,0,0,0.015);
}

/* Pagination */
.pagination {
    gap: 0.25rem;
}

.page-link {
    border-radius: 6px !important;
    font-size: 0.85rem;
    padding: 0.35rem 0.65rem;
}

/* Cards */
.info-card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    transition: box-shadow 0.2s;
}

.info-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

/* Warning banner */
.warning-banner {
    background: linear-gradient(90deg, #fff3cd, #fff8e1);
    border-left: 4px solid #ffc107;
    padding: 0.75rem 1rem;
    border-radius: 0 6px 6px 0;
    font-size: 0.9rem;
    color: #856404;
}

/* Footer */
.site-footer {
    background: var(--rd-primary);
    color: rgba(255,255,255,0.6);
    padding: 1.5rem 0;
    font-size: 0.85rem;
    margin-top: 2rem;
}

.site-footer a {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
}

.site-footer a:hover {
    color: #fff;
}

/* Language flags */
.lang-flag {
    width: 20px;
    height: 15px;
    border-radius: 2px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.lang-flag:hover {
    opacity: 1;
}

/* Inbox badge */
.inbox-badge {
    font-size: 0.75rem;
}

/* Forms */
.form-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: #555;
}

/* Postman overrides */
ul#postman_menu {
    padding: 0.75rem 0;
    list-style: none;
}

ul#postman_menu li {
    display: inline-block;
    padding: 0;
    list-style: none;
}

ul#postman_menu li a {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
}

ul#postman_menu li a:hover {
    background: #e9ecef;
}

/* Submit row */
.submit-row {
    background: transparent;
    border: none;
    padding: 0;
    text-align: left;
}

/* Auto-style Django form widgets */
.card input[type="text"],
.card input[type="password"],
.card input[type="email"],
.card input[type="number"],
.card input[type="url"],
.card input[type="date"],
.card input[type="datetime-local"],
.card textarea,
.card select {
    display: block;
    width: 100%;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.5;
    color: #212529;
    background-color: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.card input:focus,
.card textarea:focus,
.card select:focus {
    border-color: var(--rd-accent);
    box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.25);
    outline: 0;
}

/* Edit form table styling */
.card .table-borderless td,
.card .table-borderless th {
    padding: 0.4rem 0.5rem;
    vertical-align: top;
}

.card .table-borderless th {
    font-weight: 600;
    font-size: 0.85rem;
    color: #555;
    white-space: nowrap;
    width: 1%;
}

/* Styled photo / file input (i18n-friendly, Bootstrap) */
.rd-file-input {
    max-width: 28rem;
}

.rd-file-picker {
    position: relative;
}

/* Hide native file control; custom button + label is the UI */
.rd-file-native,
input.rd-file-native[type="file"] {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
    border: 0 !important;
    opacity: 0 !important;
}

.rd-file-thumb {
    display: inline-block;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #dee2e6;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    line-height: 0;
}

.rd-file-thumb img {
    display: block;
    max-width: 180px;
    max-height: 120px;
    width: auto;
    height: auto;
    object-fit: cover;
}

.rd-file-picker .btn {
    font-size: 0.8rem;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.rd-file-picker .form-control {
    font-size: 0.8rem;
    background: #fff;
}

.rd-file-picker .input-group {
    flex-wrap: nowrap;
}

/* Caliber form: multicolumn checkbox list */
#id_df,
.diameter-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(82px, 1fr));
    gap: 0.2rem 0.45rem;
    max-height: 16rem;
    overflow-y: auto;
    padding: 0.45rem 0.5rem;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: #fff;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

#id_df > div,
.diameter-columns > div {
    margin: 0;
}

#id_df label,
.diameter-columns label {
    display: grid;
    grid-template-columns: 14px 1fr;
    align-items: center;
    column-gap: 0.22rem;
    margin: 0;
    font-size: 0.82rem;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
}

#id_df input[type="checkbox"],
.diameter-columns input[type="checkbox"] {
    margin: 0;
    width: 14px;
    height: 14px;
}

@media (max-width: 768px) {
    #id_df,
    .diameter-columns {
        grid-template-columns: repeat(auto-fit, minmax(74px, 1fr));
    }
}

/* Dark mode */
[data-bs-theme="dark"] {
    --rd-primary: #1a1d23;
    --rd-accent: #5dade2;
}

[data-bs-theme="dark"] body {
    background: #1a1d23;
    color: #dee2e6;
}

[data-bs-theme="dark"] .navbar {
    background: #12151a !important;
}

[data-bs-theme="dark"] .hero-section {
    background: linear-gradient(135deg, #12151a 0%, #1a1d23 100%);
}

[data-bs-theme="dark"] .filter-bar {
    background: #212529;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

[data-bs-theme="dark"] .table {
    background: #212529;
    color: #dee2e6;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

[data-bs-theme="dark"] .table thead th {
    background: #12151a;
}

[data-bs-theme="dark"] .table tbody td {
    border-color: #2c3034;
}

[data-bs-theme="dark"] .table tbody tr:hover {
    background: #2c3034;
}

[data-bs-theme="dark"] .info-card {
    background: #212529;
    color: #dee2e6;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

[data-bs-theme="dark"] .info-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

[data-bs-theme="dark"] .warning-banner {
    background: linear-gradient(90deg, #332701, #3d2e05);
    color: #ffc107;
    border-left-color: #ffc107;
}

[data-bs-theme="dark"] .site-footer {
    background: #12151a;
}

[data-bs-theme="dark"] .card input[type="text"],
[data-bs-theme="dark"] .card input[type="password"],
[data-bs-theme="dark"] .card input[type="email"],
[data-bs-theme="dark"] .card input[type="number"],
[data-bs-theme="dark"] .card textarea,
[data-bs-theme="dark"] .card select {
    background-color: #2c3034;
    border-color: #495057;
    color: #dee2e6;
}

[data-bs-theme="dark"] .form-label {
    color: #adb5bd;
}

[data-bs-theme="dark"] .card .table-borderless th {
    color: #adb5bd;
}

[data-bs-theme="dark"] .rd-file-thumb {
    border-color: #495057;
}

[data-bs-theme="dark"] .rd-file-picker .form-control {
    background: #2c3034;
    border-color: #495057;
    color: #dee2e6;
}

[data-bs-theme="dark"] #id_df,
[data-bs-theme="dark"] .diameter-columns {
    background: #2c3034;
    border-color: #495057;
}

[data-bs-theme="dark"] .list-group-item {
    background: transparent;
    border-color: #2c3034;
    color: #dee2e6;
}

[data-bs-theme="dark"] .form-select,
[data-bs-theme="dark"] .form-control {
    background-color: #2c3034;
    border-color: #495057;
    color: #dee2e6;
}

/* Dark mode toggle button */
.theme-toggle {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 1.1rem;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

.theme-toggle:hover {
    color: #fff;
}

/* Breadcrumbs */
.breadcrumb {
    font-size: 0.8rem;
    padding: 0.5rem 0;
    margin-bottom: 0;
    background: transparent;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "›";
}

/* Responsive */
@media (max-width: 768px) {
    .hero-section {
        padding: 2rem 0 1.5rem;
    }
    .hero-section h1 {
        font-size: 1.5rem;
    }
    .stat-card .stat-value {
        font-size: 1.8rem;
    }
    .table {
        font-size: 0.78rem;
    }
}
