* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f0f2f5; color: #1a1a2e; line-height: 1.6;
    overflow-x: hidden;
}

/* ===== NAV ===== */
.nav-main {
    display: flex; align-items: center; gap: 1rem;
}
@media (max-width: 768px) {
    .nav-main { width: 100%; }
}
nav {
    background: #1e293b;
    color: white; padding: 0 2rem;
    display: flex; align-items: center; gap: 1rem;
    height: 60px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
    position: sticky; top: 0; z-index: 100;
    max-width: 100vw;
}
.nav-logo {
    display: flex; align-items: center; gap: 0.5rem;
    text-decoration: none !important;
    color: white !important;
    font-size: inherit !important;
}
.nav-logo:hover { opacity: 0.9; }
.nav-logo-badge {
    background: #2563eb;
    padding: 4px 6px;
    border-radius: 8px;
    color: white;
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    line-height: 1;
}
.nav-logo-text {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: white;
}
.nav-logo-accent { color: #3b82f6; }
nav a {
    color: #94a3b8; text-decoration: none; font-size: 0.85rem; font-weight: 500;
    padding: 0.3rem 0.7rem; border-radius: 6px; transition: all 0.15s;
}
nav a:hover { color: white; background: rgba(255,255,255,0.08); }
.nav-collapse {
    display: flex; align-items: center; gap: 1rem; flex: 1;
}
.nav-collapse form {
    display: flex; gap: 0; flex: 1; max-width: 320px;
}
nav form input {
    flex: 1; padding: 0.4rem 0.7rem;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px 0 0 6px;
    background: rgba(255,255,255,0.06);
    color: white; font-size: 0.82rem;
    transition: all 0.2s;
}
nav form input::placeholder { color: #64748b; }
nav form input:focus { outline: none; background: rgba(255,255,255,0.1); border-color: #60a5fa; }
nav form button {
    padding: 0.4rem 0.6rem;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    border-left: none;
    border-radius: 0 6px 6px 0;
    color: #94a3b8; cursor: pointer; font-size: 0.85rem;
    transition: all 0.15s;
    display: flex; align-items: center; justify-content: center;
}
nav form button:hover { color: white; background: rgba(255,255,255,0.15); }
.nav-right {
    display: flex; align-items: center; gap: 0.5rem;
}
.nav-username {
    color: #94a3b8; font-size: 0.8rem;
    display: flex; align-items: center; gap: 0.3rem;
}
.nav-logout-btn {
    background: none; border: 1px solid rgba(255,255,255,0.15);
    color: #94a3b8; cursor: pointer; font-size: 0.78rem;
    padding: 0.25rem 0.6rem; border-radius: 4px; transition: all 0.15s;
}
.nav-logout-btn:hover { color: #fca5a5; border-color: #fca5a5; }

/* ===== HAMBURGER TOGGLE ===== */
.nav-toggle {
    display: none !important;
    background: none; border: none; cursor: pointer;
    padding: 0.4rem; border-radius: 6px;
    margin-left: auto;
    color: #94a3b8;
}
.nav-toggle:hover { color: white; }

/* ===== CONTAINER ===== */
.container { max-width: 1200px; margin: 1.5rem auto; padding: 0 1.5rem; }

/* ===== CARDS ===== */
.card {
    background: white; border-radius: 12px; padding: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    border: 1px solid #e2e8f0;
    transition: box-shadow 0.2s;
}
.card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.card h2 {
    font-size: 0.95rem; color: #0f172a; margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex; align-items: center; gap: 0.5rem;
}

/* ===== STATS GRID ===== */
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem; margin-bottom: 1rem;
}
.stat-box {
    background: white;
    border-radius: 12px; padding: 1.25rem 1.2rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid #e2e8f0;
    display: flex; align-items: center; gap: 1rem;
    transition: all 0.2s;
}
.stat-box:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}
.stat-box .stat-icon {
    width: 48px; height: 48px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 12px; font-size: 1.5rem;
    flex-shrink: 0;
}
.stat-box:nth-child(1) .stat-icon { background: #eff6ff; }
.stat-box:nth-child(2) .stat-icon { background: #fffbeb; }
.stat-box:nth-child(3) .stat-icon { background: #fef2f2; }
.stat-box:nth-child(4) .stat-icon { background: #f5f3ff; }
.stat-box .stat-body { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.stat-box .stat-value { font-size: 1.5rem; font-weight: 700; color: #0f172a; line-height: 1.2; }
.stat-box .stat-label { font-size: 0.75rem; color: #64748b; text-transform: uppercase; letter-spacing: 0.4px; font-weight: 500; }

/* ===== TABLE ===== */
.table-wrap {
    overflow-x: auto;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}
table {
    width: 100%; border-collapse: collapse; min-width: 600px;
}
th {
    background: #f8fafc; padding: 0.7rem 1rem; text-align: left;
    font-size: 0.72rem; font-weight: 700; color: #475569;
    text-transform: uppercase; letter-spacing: 0.5px;
    border-bottom: 1px solid #e2e8f0;
}
td {
    padding: 0.7rem 1rem; border-bottom: 1px solid #f1f5f9;
    font-size: 0.88rem; color: #334155;
}
tr:last-child td { border-bottom: none; }
tr:hover { background: #f8fafc; }
/* Zebra striping */
tbody tr:nth-child(even) { background: #fafbfc; }
tbody tr:nth-child(even):hover { background: #f1f5f9; }
/* ID links */
td a { color: #2563eb; text-decoration: none; font-weight: 500; }
td a:hover { text-decoration: underline; }

/* ===== ENTITY TYPE BADGES ===== */
.type-badge {
    display: inline-block; padding: 0.15rem 0.5rem; border-radius: 4px;
    font-size: 0.72rem; font-weight: 600; letter-spacing: 0.2px;
    white-space: nowrap;
}
.type-individual { background: #eff6ff; color: #2563eb; }
.type-company    { background: #f0fdf4; color: #16a34a; }
.type-vessel     { background: #fef2f2; color: #dc2626; }
.type-aircraft   { background: #f5f3ff; color: #7c3aed; }
.type-unknown    { background: #f1f5f9; color: #64748b; }

/* ===== SOURCE BADGES ===== */
.source-badge {
    display: inline-block; padding: 0.15rem 0.45rem; border-radius: 4px;
    font-size: 0.7rem; font-weight: 700; letter-spacing: 0.3px;
    text-transform: uppercase; white-space: nowrap;
}
.source-OFAC    { background: #eff6ff; color: #2563eb; }
.source-EU      { background: #f0fdf4; color: #16a34a; }
.source-UN      { background: #fef2f2; color: #dc2626; }
.source-AfDB    { background: #f5f3ff; color: #7c3aed; }
.source-CENTIF  { background: #fff7ed; color: #ea580c; }
.source-UA      { background: #fdf2f8; color: #db2777; }
.source-UK      { background: #eff6ff; color: #0369a1; }
.source-CH      { background: #f0fdf4; color: #15803d; }
.source-Unknown { background: #f1f5f9; color: #475569; }
.source-OpenSanctions { background: #fefce8; color: #a16207; }

/* ===== RISK BARS ===== */
.risk-bar { height: 5px; background: #e2e8f0; border-radius: 3px; overflow: hidden; margin-top: 0.25rem; max-width: 120px; }
.risk-fill { height: 100%; border-radius: 3px; transition: width 0.3s; }
.risk-low    { background: #22c55e; }
.risk-medium { background: #eab308; }
.risk-high   { background: #ef4444; }

/* ===== SEARCH RESULT CARD ===== */
.search-header {
    background: linear-gradient(135deg, #eff6ff, #f0fdf4);
    border-radius: 10px; padding: 1rem 1.5rem; margin-bottom: 1.25rem;
    border: 1px solid #bfdbfe;
}
.search-header h2 { border: none; margin-bottom: 0.2rem; }
.search-header .search-meta { font-size: 0.82rem; color: #64748b; }

/* ===== ALERTS ===== */
.alert { padding: 0.85rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.85rem; }
.alert-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

/* ===== TAGS ===== */
.tag {
    display: inline-block; padding: 0.15rem 0.4rem; background: #f1f5f9;
    border-radius: 4px; font-size: 0.78rem; color: #475569; margin: 0.08rem;
}
td.empty { text-align: center; color: #94a3b8; padding: 2rem; font-style: italic; }
td.empty code { background: #f1f5f9; padding: 0.15rem 0.4rem; border-radius: 4px; font-size: 0.82rem; }
.meta-tag { background: #fef9c3 !important; color: #854d0e !important; font-size: 0.72rem !important; border-left: 3px solid #eab308; }

/* ===== FOOTER ===== */
footer { text-align: center; padding: 2rem; color: #94a3b8; font-size: 0.82rem; border-top: 1px solid #e2e8f0; margin-top: 2rem; }

/* ===== PAGINATION ===== */
.pagination {
    display: flex; justify-content: center; align-items: center; gap: 0.5rem;
    margin-top: 1rem; padding-top: 1rem; border-top: 1px solid #e2e8f0; flex-wrap: wrap;
}
.pagination:first-of-type { border-top: none; margin-top: 0; }
.page-btn {
    padding: 0.4rem 0.9rem; border-radius: 7px; font-size: 0.8rem; text-decoration: none;
    color: #1e293b; background: #f8fafc; border: 1px solid #e2e8f0;
    transition: all 0.15s; white-space: nowrap; font-weight: 600;
}
.page-btn:hover { background: #e2e8f0; border-color: #cbd5e1; }
.page-btn.disabled { color: #94a3b8; background: #f8fafc; border-color: #e2e8f0; cursor: default; font-weight: 400; }

/* ===== ENTRY CARDS ===== */
.entry-card {
    background: #fafbfc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 0.6rem 0.8rem;
    transition: all 0.15s;
}
.entry-card:hover {
    background: white;
    border-color: #cbd5e1;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.entry-card-id {
    font-size: 0.75rem; font-weight: 600; color: #2563eb;
    text-decoration: none; font-family: monospace;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    min-width: 0;
}
.entry-card-id:hover { text-decoration: underline; }
.entry-card-name {
    font-size: 0.92rem; font-weight: 500; color: #0f172a;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    min-width: 0;
}

/* ===== ENTITY TYPE BADGES ===== */

/* ===== DATATABLE TOOLBAR ===== */
.datatable-toolbar {
    display: flex; justify-content: space-between; align-items: center;
    gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap;
}
.datatable-search { position: relative; flex: 1; max-width: 280px; }
.datatable-search input {
    width: 100%; padding: 0.5rem 0.75rem 0.5rem 2.2rem;
    border: 1px solid #e2e8f0; border-radius: 8px; font-size: 0.82rem;
    transition: all 0.2s; background: #f8fafc;
}
.datatable-search input:focus { outline: none; border-color: #3b82f6; background: white; box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
.datatable-search .search-icon {
    position: absolute; left: 0.6rem; top: 50%; transform: translateY(-50%);
    width: 16px; height: 16px;
    color: #94a3b8;
    pointer-events: none; line-height: 1;
    display: flex; align-items: center; justify-content: center;
}
.datatable-info { color: #64748b; font-size: 0.82rem; white-space: nowrap; font-weight: 500; }

/* ===== PAGINATION NUMBERS ===== */
.pagination-numbers { display: flex; gap: 0.2rem; align-items: center; flex-wrap: wrap; }
.page-num {
    padding: 0.3rem 0.6rem; border-radius: 4px; font-size: 0.78rem; text-decoration: none;
    color: #1e293b; background: #f8fafc; border: 1px solid #e2e8f0;
    transition: all 0.12s; min-width: 1.8rem; text-align: center;
}
.page-num:hover { background: #e2e8f0; }
.page-num.active { background: #3b82f6; color: white; border-color: #3b82f6; }
.page-ellipsis { padding: 0.3rem 0.2rem; color: #94a3b8; font-size: 0.78rem; }
.no-results { text-align: center; padding: 2rem 1rem; color: #94a3b8; font-size: 0.9rem; }
.no-results strong { color: #475569; }
.row-hidden { display: none !important; }

/* ===== GRAPH BUTTON (detail page) ===== */
.graph-btn {
    display: inline-flex; align-items: center; gap: 0.4rem;
    margin-left: 0.5rem;
    padding: 0.4rem 0.8rem;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border-radius: 6px; text-decoration: none;
    font-size: 0.82rem; font-weight: 600;
    transition: all 0.15s; cursor: pointer; border: none;
}
.graph-btn:hover { transform: scale(1.05); box-shadow: 0 2px 8px rgba(99,102,241,0.3); }
.graph-btn .icon { font-size: 1.2rem; line-height: 1; }

/* ===== DETAIL PAGE TABLE ===== */
table.no-card td { padding: 0.5rem 0.7rem; border-bottom: 1px solid #f1f5f9; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    nav {
        flex-direction: column; padding: 0; gap: 0;
        height: auto; min-height: 52px;
        align-items: stretch;
    }
    .nav-main {
        padding: 0.5rem 0.8rem;
        min-height: 52px;
    }
    nav h1 { font-size: 0.95rem; }
    .nav-toggle { display: flex !important; }
    .nav-inner {
        flex-direction: column !important;
        gap: 0 !important;
        align-items: stretch !important;
    }
    .nav-collapse {
        display: none;
        flex-direction: column; gap: 0.3rem;
        padding: 0 0.8rem 0.6rem;
    }
    .nav-collapse.nav-open { display: flex; }
    nav a {
        font-size: 0.85rem; padding: 0.4rem 0.6rem;
        width: 100%;
    }
    nav form.nav-auth-search {
        max-width: 100%; width: 100%; margin-left: 0;
    }
    nav form.nav-auth-search input {
        font-size: 0.82rem; padding: 0.4rem 0.6rem;
    }
    .nav-right {
        width: 100%; justify-content: flex-start;
        padding: 0.5rem 0.8rem; border-top: 1px solid rgba(255,255,255,0.1);
    }
    .nav-right form {
        width: 100%; display: flex !important;
        align-items: center; justify-content: space-between;
    }
    .nav-username { font-size: 0.82rem; max-width: 200px; overflow: hidden; text-overflow: ellipsis; color: white; }
    .nav-logout-btn { font-size: 0.78rem; padding: 0.35rem 0.8rem; }

    .container { padding: 0 0.6rem; margin: 0.8rem auto; }
    .card { padding: 0.8rem; }
    .card h2 { font-size: 0.85rem; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 0.4rem; }
    .stat-box { padding: 0.6rem 0.8rem; gap: 0.6rem; }
    .stat-box .stat-icon { width: 36px; height: 36px; font-size: 1.1rem; }
    .stat-box .stat-value { font-size: 1.1rem; }
    .stat-box .stat-label { font-size: 0.65rem; letter-spacing: 0.2px; }
    .detail-grid { grid-template-columns: 1fr; }
    .datatable-toolbar { flex-direction: column; align-items: stretch; }
    .datatable-search { max-width: 100%; }
    .entry-card { padding: 0.5rem 0.7rem; }
    .entry-card-id { font-size: 0.7rem; }
    .entry-card-name { font-size: 0.82rem; }
    .entry-card-risk { font-size: 0.78rem; }

    /* Stats tables → stacked cards */
    .table-wrap { overflow: visible; }
    table { min-width: 0; }
    thead { display: none; }
    table:not(.no-card) tbody, table:not(.no-card) tr, table:not(.no-card) td { display: block; }
    table:not(.no-card) tr {
        margin-bottom: 0.4rem; padding: 0.4rem 0.6rem;
        border: 1px solid #e2e8f0; border-radius: 8px;
    }
    table:not(.no-card) tr:hover { background: inherit; }
    table:not(.no-card) td {
        border: none; padding: 0.2rem 0; font-size: 0.8rem;
        display: flex; justify-content: space-between; align-items: center; gap: 0.4rem;
    }
    table:not(.no-card) td:not(:last-child) { border-bottom: 1px solid #f1f5f9; }
    table:not(.no-card) td::before {
        content: attr(data-label);
        font-weight: 600; color: #475569; font-size: 0.65rem;
        text-transform: uppercase; letter-spacing: 0.2px;
    }
    .pagination { gap: 0.3rem; }
    .pagination-numbers { gap: 0.12rem; }
    .page-num { min-width: 1.5rem; padding: 0.2rem 0.3rem; font-size: 0.7rem; }
    .page-btn { font-size: 0.75rem; padding: 0.3rem 0.6rem; }
    .datatable-info { font-size: 0.75rem; }

    footer { font-size: 0.72rem; padding: 1rem; }
}

/* Mobile column labels */
@media (max-width: 768px) {
    #entries-table td:nth-child(1)::before { content: "ID"; }
    #entries-table td:nth-child(2)::before { content: "Name"; }
    #entries-table td:nth-child(3)::before { content: "Source"; }
    #entries-table td:nth-child(4)::before { content: "Type"; }
    #entries-table td:nth-child(5)::before { content: "Risk"; }
}

/* ===== ANTI-FOUC AUTH ===== */
.auth-in  .nav-auth-register  { display: none !important; }
.auth-in  .nav-auth-logout    { display: flex !important; }
.auth-in  .nav-auth-search    { display: flex !important; }
.auth-in  .nav-auth-profile   { display: inline !important; }
.auth-in  .nav-auth-docs      { display: inline !important; }
.auth-in  .nav-auth-dashboard { display: inline !important; }

.auth-out .nav-auth-register  { display: inline !important; }
.auth-out .nav-auth-logout    { display: none !important; }
.auth-out .nav-auth-search    { display: none !important; }
.auth-out .nav-auth-profile   { display: none !important; }
.auth-out .nav-auth-docs      { display: none !important; }
.auth-out .nav-auth-dashboard { display: none !important; }
.auth-page .nav-auth-register,
.auth-page .nav-auth-logout,
.auth-page .nav-auth-profile,
.auth-page .nav-auth-docs,
.auth-page .nav-auth-dashboard { display: none !important; }
