:root {
    --bf-red:        #e60000;
    --bf-dark-red:   #c30000;
    --bf-dark:       #111418;
    --bf-dark-grey:  #212529;
    --bf-mid-grey:   #343a40;
    --bf-light-grey: #adb5bd;
    --bf-white:      #ffffff;
    --bf-border:     #e4e8ed;
    --sidebar-width: 240px;
    --header-height: 68px;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ── Base ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    background-color: #f5f6f8;
    color: var(--bf-dark-grey);
    margin: 0;
    padding: var(--header-height) 0 0 var(--sidebar-width);
    min-height: 100vh;
}

body.auth-page {
    background: linear-gradient(135deg, #0d0e11 0%, #1a1d23 50%, #111418 100%);
    min-height: 100vh;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Top header bar ───────────────────────────────────────────────────────── */
.top-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bf-dark);
    border-bottom: 1px solid rgba(255,255,255,0.07);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    z-index: 1030;
}

.top-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-brand {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.header-brand img { height: 30px; width: auto; }

.top-header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-username {
    color: rgba(255,255,255,0.6);
    font-size: 0.825rem;
}

.header-staff-badge {
    background: var(--bf-red);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    padding: 2px 8px;
    border-radius: 20px;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height));
    background: var(--bf-dark);
    display: flex;
    flex-direction: column;
    z-index: 1025;
    overflow-y: auto;
    overflow-x: hidden;
    border-right: 1px solid rgba(255,255,255,0.06);
}

.slash-wrap {
    display: flex;
    align-items: center;
    margin-left: 8px;
}

.slash {
    color: rgba(255,255,255,0.3);
    font-size: 20px;
    font-weight: 200;
    margin-right: 4px;
    line-height: 1;
}

.devword {
    color: rgba(255,255,255,0.7);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* Nav */
.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0;
    overflow-y: auto;
}

.sidebar-menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sidebar-section-label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.25);
    padding: 1.1rem 1rem 0.35rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 1rem;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all 0.18s ease;
}

.sidebar-link i {
    width: 16px;
    text-align: center;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.sidebar-link:hover {
    color: #fff;
    background: rgba(255,255,255,0.06);
    border-left-color: rgba(255,255,255,0.15);
}

.sidebar-link.active {
    color: #fff;
    background: rgba(230,0,0,0.12);
    border-left-color: var(--bf-red);
}

/* User section */
.sidebar-user {
    border-top: 1px solid rgba(255,255,255,0.07);
    padding: 0.85rem 1rem;
    flex-shrink: 0;
}

.sidebar-user-info {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 0.65rem;
}

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    background: rgba(255,255,255,0.08);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.5);
    font-size: 0.8rem;
    flex-shrink: 0;
}

.sidebar-user-name {
    font-size: 0.825rem;
    font-weight: 600;
    color: rgba(255,255,255,0.85);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.35);
}

.sidebar-user-actions {
    display: flex;
    gap: 0.25rem;
}

.sidebar-user-link {
    flex: 1;
    text-align: center;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.5);
    text-decoration: none;
    transition: all 0.18s ease;
    background: rgba(255,255,255,0.04);
}

.sidebar-user-link:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.sidebar-user-link.active {
    background: rgba(230,0,0,0.15);
    color: var(--bf-red);
}

.text-danger-soft { color: rgba(220,53,69,0.8) !important; }
.text-danger-soft:hover { color: #dc3545 !important; background: rgba(220,53,69,0.1) !important; }

/* ── Mobile sidebar toggle ────────────────────────────────────────────────── */
.sidebar-toggle-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 1.1rem;
    padding: 6px 8px;
    cursor: pointer;
    border-radius: 6px;
    line-height: 1;
    flex-shrink: 0;
}

.sidebar-toggle-btn:hover { color: #fff; background: rgba(255,255,255,0.08); }

/* ── Sidebar overlay (mobile) ─────────────────────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 1020;
}

/* ── Modals ───────────────────────────────────────────────────────────────── */
.modal-dialog {
    margin-top: calc(var(--header-height) + 2rem);
}

/* ── Breadcrumb ───────────────────────────────────────────────────────────── */
.breadcrumb {
    background: #e4e8ed;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    margin: 0;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    width: 100%;
}
.breadcrumb-item a {
    color: #495057;
    text-decoration: none;
    transition: color 0.15s;
}
.breadcrumb-item a:hover {
    color: #111418;
}
.breadcrumb-item.active {
    color: #343a40;
}
.breadcrumb-item + .breadcrumb-item::before {
    content: "›";
    color: #adb5bd;
}

.sidebar-overlay.active { display: block; }

/* ── Auth card ────────────────────────────────────────────────────────────── */
.auth-card {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 440px;
    backdrop-filter: blur(10px);
}

.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2rem;
}

.auth-logo img {
    height: 34px;
    filter: brightness(0) invert(1);
}

.auth-card h1 {
    color: #fff;
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 0.25rem;
}

.auth-card .subtitle {
    color: rgba(255,255,255,0.45);
    text-align: center;
    font-size: 0.875rem;
    margin-bottom: 2rem;
}

.auth-card .form-label {
    color: rgba(255,255,255,0.7);
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.auth-card .form-control {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    color: #fff;
    border-radius: 8px;
    padding: 0.6rem 0.9rem;
}

.auth-card .form-control:focus {
    background: rgba(255,255,255,0.09);
    border-color: var(--bf-red);
    color: #fff;
    box-shadow: 0 0 0 3px rgba(230,0,0,0.15);
}

.auth-card .form-control::placeholder { color: rgba(255,255,255,0.25); }
.auth-card a { color: var(--bf-red); text-decoration: none; }
.auth-card a:hover { text-decoration: underline; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn-primary {
    background-color: var(--bf-red) !important;
    border-color: var(--bf-red) !important;
    border-radius: 50px !important;
    font-weight: 600;
    letter-spacing: 0.03em;
    white-space: nowrap;
    transition: all 0.25s ease;
}

.btn-primary:hover {
    background-color: var(--bf-dark-red) !important;
    border-color: var(--bf-dark-red) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(230,0,0,0.35);
}

.btn-danger {
    background-color: var(--bf-red) !important;
    border-color: var(--bf-red) !important;
    border-radius: 50px !important;
    font-weight: 600;
    letter-spacing: 0.03em;
    white-space: nowrap;
    transition: all 0.25s ease;
}

.btn-danger:hover {
    background-color: var(--bf-dark-red) !important;
    border-color: var(--bf-dark-red) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(230,0,0,0.35);
}

.btn-sm { border-radius: 50px !important; }
.btn-outline-danger { border-radius: 50px !important; }
.btn-outline-secondary { border-radius: 50px !important; }

/* ── Page content ─────────────────────────────────────────────────────────── */
.page-content {
    padding: 1.75rem;
}

/* ── Stat cards ───────────────────────────────────────────────────────────── */
.stat-card {
    background: #fff;
    border: 1px solid var(--bf-border);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.stat-icon-red   { background: rgba(230,0,0,0.1);    color: var(--bf-red); }
.stat-icon-blue  { background: rgba(13,110,253,0.1);  color: #0d6efd; }
.stat-icon-green { background: rgba(25,135,84,0.1);   color: #198754; }
.stat-icon-grey  { background: rgba(108,117,125,0.1); color: #6c757d; }

.stat-card .stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1;
    color: var(--bf-dark-grey);
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: #6c757d;
    margin-top: 2px;
}

/* ── Module cards ─────────────────────────────────────────────────────────── */
.module-card {
    background: #fff;
    border: 1px solid var(--bf-border);
    border-top: 3px solid var(--bf-border);
    border-radius: 12px;
    padding: 1.75rem;
    transition: all 0.25s ease;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
    height: 100%;
}

.module-card:hover {
    border-top-color: var(--bf-red);
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
    transform: translateY(-3px);
    color: inherit;
    text-decoration: none;
}

.module-card.module-enabled { border-top-color: var(--bf-red); }

.module-card.module-disabled {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
    filter: grayscale(20%);
}

.module-icon {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, rgba(230,0,0,0.1), rgba(230,0,0,0.05));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: var(--bf-red);
    margin-bottom: 1rem;
}

.module-card.module-disabled .module-icon { background: rgba(0,0,0,0.05); color: #aaa; }
.module-card h4 { font-size: 1.05rem; font-weight: 700; margin-bottom: 0.4rem; }
.module-card .module-stats { font-size: 0.85rem; color: #6c757d; margin-bottom: 0.75rem; }

.module-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 3px 10px;
    border-radius: 20px;
}

.badge-active      { background: rgba(46,166,74,0.12);  color: #1a7a30; }
.badge-coming-soon { background: rgba(0,0,0,0.07);       color: #888; }
.badge-no-access   { background: rgba(230,0,0,0.08);     color: var(--bf-red); }

/* ── Content cards ────────────────────────────────────────────────────────── */
.content-card {
    background: #fff;
    border: 1px solid var(--bf-border);
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    overflow: hidden;
}

.content-card .card-header {
    background: #fff;
    border-bottom: 1px solid var(--bf-border);
    padding: 1rem 1.25rem;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--bf-dark-grey);
}

.content-card .card-body { padding: 1.25rem; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table { font-size: 0.875rem; }

.table thead th {
    background: #f8f9fa;
    border-bottom: 2px solid var(--bf-border);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6c757d;
    padding: 0.75rem 1rem;
    white-space: nowrap;
}

.table tbody td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    border-color: var(--bf-border);
}

.table tbody tr:hover { background-color: #fafbfc; }

/* ── DNS record type badges ───────────────────────────────────────────────── */
.record-type {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    padding: 2px 8px;
    border-radius: 4px;
    min-width: 42px;
    text-align: center;
}

.rt-A     { background: rgba(230,0,0,0.1);    color: var(--bf-red); }
.rt-AAAA  { background: rgba(13,110,253,0.1);  color: #0d6efd; }
.rt-CNAME { background: rgba(25,135,84,0.1);   color: #198754; }
.rt-MX    { background: rgba(255,193,7,0.15);  color: #856404; }
.rt-TXT   { background: rgba(108,117,125,0.1); color: #495057; }
.rt-SRV   { background: rgba(111,66,193,0.1);  color: #6f42c1; }
.rt-NS    { background: rgba(32,32,32,0.08);   color: #212529; }
.rt-PTR   { background: rgba(13,202,240,0.1);  color: #0dcaf0; }

.status-active    { background: rgba(25,135,84,0.1);   color: #198754; }
.status-suspended { background: rgba(220,53,69,0.1);   color: #dc3545; }
.status-pending   { background: rgba(255,193,7,0.15);  color: #856404; }

/* ── Flash alerts ─────────────────────────────────────────────────────────── */
.alert-flash {
    border-radius: 10px;
    border: none;
    font-size: 0.875rem;
    padding: 0.85rem 1.1rem;
}

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-control:focus, .form-select:focus {
    border-color: var(--bf-red);
    box-shadow: 0 0 0 3px rgba(230,0,0,0.12);
}

.form-label { font-size: 0.85rem; font-weight: 600; color: var(--bf-dark-grey); }

.form-check-input:checked { background-color: var(--bf-red); border-color: var(--bf-red); }
.form-check-input:focus   { box-shadow: 0 0 0 3px rgba(230,0,0,0.15); border-color: var(--bf-red); }

/* ── Misc ─────────────────────────────────────────────────────────────────── */
.lock-icon  { color: #adb5bd; font-size: 0.75rem; }
.empty-state { text-align: center; padding: 3rem 1rem; color: #adb5bd; }
.empty-state i { font-size: 2.5rem; margin-bottom: 1rem; display: block; opacity: 0.4; }

/* ── Tuning DB cards ──────────────────────────────────────────────────────── */
.tdb-card {
    border: 1px solid var(--bf-border);
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
    height: 100%;
    display: flex;
    flex-direction: column;
}
.tdb-card:hover { border-color: var(--bf-red); box-shadow: 0 2px 12px rgba(230,0,0,0.09); }
.tdb-card-link {
    display: block;
    padding: 0.85rem 1rem 0.75rem;
    text-decoration: none;
    color: inherit;
    flex: 1;
}
.tdb-card-link:hover { background: rgba(230,0,0,0.03); }
.tdb-card-name { font-weight: 700; font-size: 0.875rem; color: #212529; line-height: 1.3; margin-bottom: 0.25rem; }
.tdb-card-meta { font-size: 0.72rem; color: #6c757d; }
.tdb-card-footer {
    display: flex;
    gap: 0.35rem;
    justify-content: flex-end;
    padding: 0.4rem 0.6rem;
    border-top: 1px solid #f0f2f5;
    background: #fafbfc;
}
.tdb-card-footer .btn { border-radius: 6px !important; }

.ecu-brand-card .tdb-card-link { cursor: default; }
.ecu-brand-card .tdb-card-link:hover { background: none; }
.ecu-brand-body { padding: 0.85rem 1rem 0.75rem; }
.ecu-brand-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem 0.6rem; margin-top: 0.5rem; }
.ecu-stat { display: flex; justify-content: space-between; align-items: center; padding: 0.25rem 0.5rem; background: #f5f6f8; border-radius: 6px; }
.ecu-stat-total { grid-column: 1 / -1; background: rgba(230,0,0,0.07); }
.ecu-stat-label { font-size: 0.7rem; font-weight: 600; color: #6c757d; text-transform: uppercase; letter-spacing: 0.04em; }
.ecu-stat-val { font-size: 0.85rem; font-weight: 700; color: #212529; }
.ecu-stat-total .ecu-stat-label { color: var(--bf-red); }
.ecu-stat-total .ecu-stat-val { color: var(--bf-red); }

/* ── Collapsible sidebar groups ───────────────────────────────────────────── */
.sidebar-collapse-header {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 1rem;
    color: rgba(255,255,255,0.6);
    font-size: 0.875rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all 0.18s ease;
    background: none;
    border-top: none;
    border-right: none;
    border-bottom: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
}

.sidebar-collapse-header i:first-child {
    width: 16px;
    text-align: center;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.sidebar-collapse-header:hover {
    color: #fff;
    background: rgba(255,255,255,0.06);
    border-left-color: rgba(255,255,255,0.15);
}

.sidebar-collapse-header.open {
    color: rgba(255,255,255,0.85);
}

.collapse-arrow {
    font-size: 0.7rem;
    transition: transform 0.2s ease;
    opacity: 0.5;
}

.sidebar-collapse-header.open .collapse-arrow {
    transform: rotate(90deg);
    opacity: 0.75;
}

.sidebar-submenu {
    display: none;
    list-style: none;
    margin: 0;
    padding: 0;
    background: rgba(0,0,0,0.12);
    border-left: 3px solid rgba(255,255,255,0.06);
    margin-left: 1rem;
}

.sidebar-submenu.open {
    display: block;
}

.sidebar-submenu .sidebar-link {
    font-size: 0.835rem;
    padding: 0.45rem 1rem 0.45rem 1.5rem;
    border-left: none;
}

.sidebar-submenu .sidebar-link:hover {
    border-left: none;
    background: rgba(255,255,255,0.05);
}

.sidebar-submenu .sidebar-link.active {
    background: rgba(230,0,0,0.15);
    color: #fff;
    border-left: none;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 991px) {
    body {
        padding-left: 0;
        padding-top: var(--header-height);
    }

    .sidebar {
        top: var(--header-height);
        height: calc(100vh - var(--header-height));
        transform: translateX(calc(-1 * var(--sidebar-width)));
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
    }

    .sidebar.sidebar-open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.4);
    }

    .auth-card { margin: 1rem; padding: 1.75rem; }
}

@media (min-width: 992px) {
    .sidebar-overlay  { display: none !important; }
    .sidebar-toggle-btn { display: none !important; }
}

@media (max-width: 575px) {
    .container-fluid { padding-left: 1rem !important; padding-right: 1rem !important; }
    .stat-card { padding: 1rem; }
    .module-card { padding: 1.25rem; }
    .table thead th, .table tbody td { padding: 0.6rem 0.75rem; }
}
