/* =========================================================
   FaceOff Data Tokenization — Dashboard Styles
   #da2b26 Red theme with dark/light mode support
   ========================================================= */

/* ---------- Reset & Variables ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* === DARK THEME (default) === */
:root {
    --bg-primary: #0c0c14;
    --bg-secondary: #12121e;
    --bg-card: rgba(22, 22, 36, 0.65);
    --bg-glass: rgba(26, 26, 42, 0.5);
    --bg-input: rgba(10, 10, 20, 0.5);
    --border-glass: rgba(218, 43, 38, 0.1);
    --border-hover: rgba(218, 43, 38, 0.28);

    --text-primary: #ededed;
    --text-secondary: #a0a0b8;
    --text-muted: #6b6b88;

    /* Brand */
    --accent-brand: #da2b26;
    --accent-brand-light: #f0443f;
    --accent-brand-dim: rgba(218, 43, 38, 0.15);

    /* Supporting palette */
    --accent-orange: #e87030;
    --accent-cyan: #22c5d6;
    --accent-green: #2ec47a;
    --accent-amber: #e8a828;
    --accent-red: #da2b26;
    --accent-blue: #4a8af4;

    --gradient-primary: linear-gradient(135deg, #da2b26 0%, #f0443f 50%, #e05050 100%);
    --gradient-warm: linear-gradient(135deg, #da2b26 0%, #e87030 100%);
    --gradient-green: linear-gradient(135deg, #1fa85c 0%, #2ec47a 100%);
    --gradient-amber: linear-gradient(135deg, #d0900a 0%, #e8a828 100%);

    --top-bar-bg: rgba(12, 12, 20, 0.8);
    --code-block-bg: rgba(10, 10, 20, 0.6);
    --result-token-bg: rgba(218, 43, 38, 0.08);
    --activity-bg: rgba(218, 43, 38, 0.04);
    --activity-hover-bg: rgba(218, 43, 38, 0.08);
    --table-hover-bg: rgba(218, 43, 38, 0.04);
    --strategy-bar-bg: rgba(218, 43, 38, 0.07);
    --builtin-bg: rgba(218, 43, 38, 0.04);
    --code-inline-bg: rgba(218, 43, 38, 0.08);
    --hash-bg: rgba(218, 43, 38, 0.08);
    --scrollbar-thumb: rgba(218, 43, 38, 0.2);
    --scrollbar-thumb-hover: rgba(218, 43, 38, 0.4);
    --td-border: rgba(218, 43, 38, 0.06);

    --sidebar-width: 260px;
    --sidebar-collapsed: 72px;
    --top-bar-height: 64px;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px rgba(218, 43, 38, 0.12);
    --btn-primary-shadow: 0 4px 15px rgba(218, 43, 38, 0.35);
    --btn-primary-hover-shadow: 0 6px 25px rgba(218, 43, 38, 0.55);
    --focus-ring: 0 0 0 3px rgba(218, 43, 38, 0.2);

    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* === LIGHT THEME === */
[data-theme="light"] {
    --bg-primary: #f5f5f7;
    --bg-secondary: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.75);
    --bg-glass: rgba(255, 255, 255, 0.6);
    --bg-input: rgba(245, 245, 248, 0.8);
    --border-glass: rgba(218, 43, 38, 0.12);
    --border-hover: rgba(218, 43, 38, 0.3);

    --text-primary: #1a1a2e;
    --text-secondary: #555570;
    --text-muted: #8888a0;

    --accent-brand: #c42420;
    --accent-brand-light: #da2b26;
    --accent-brand-dim: rgba(218, 43, 38, 0.1);

    --accent-red: #c42420;

    --gradient-primary: linear-gradient(135deg, #c42420 0%, #da2b26 50%, #e04040 100%);

    --top-bar-bg: rgba(255, 255, 255, 0.85);
    --code-block-bg: rgba(240, 240, 245, 0.9);
    --result-token-bg: rgba(218, 43, 38, 0.06);
    --activity-bg: rgba(218, 43, 38, 0.03);
    --activity-hover-bg: rgba(218, 43, 38, 0.06);
    --table-hover-bg: rgba(218, 43, 38, 0.03);
    --strategy-bar-bg: rgba(218, 43, 38, 0.06);
    --builtin-bg: rgba(218, 43, 38, 0.03);
    --code-inline-bg: rgba(218, 43, 38, 0.06);
    --hash-bg: rgba(218, 43, 38, 0.06);
    --scrollbar-thumb: rgba(218, 43, 38, 0.15);
    --scrollbar-thumb-hover: rgba(218, 43, 38, 0.3);
    --td-border: rgba(218, 43, 38, 0.08);

    --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 20px rgba(218, 43, 38, 0.06);
    --btn-primary-shadow: 0 4px 12px rgba(218, 43, 38, 0.2);
    --btn-primary-hover-shadow: 0 6px 20px rgba(218, 43, 38, 0.35);
    --focus-ring: 0 0 0 3px rgba(218, 43, 38, 0.15);
}

[data-theme="light"] .glass {
    backdrop-filter: blur(12px);
}

[data-theme="light"] .sidebar {
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.04);
}

html {
    font-size: 15px;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    transition: background var(--transition), color var(--transition);
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: width var(--transition), background var(--transition);
}

.sidebar-header {
    padding: 20px 18px 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--border-glass);
}

.logo-img {
    width: 140px;
    height: auto;
    flex-shrink: 0;
    object-fit: contain;
}


.nav-links {
    list-style: none;
    padding: 16px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all var(--transition);
    position: relative;
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--accent-brand-dim);
}

.nav-link.active {
    color: var(--accent-brand);
    background: var(--accent-brand-dim);
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background: var(--gradient-primary);
    border-radius: 0 4px 4px 0;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-glass);
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--accent-green);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent-green);
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ---------- Theme Toggle ---------- */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    margin: 0 12px 12px;
    border-radius: var(--radius-sm);
    background: var(--accent-brand-dim);
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.theme-toggle:hover {
    color: var(--text-primary);
    border-color: var(--accent-brand);
}

.theme-toggle svg {
    flex-shrink: 0;
}

/* ---------- Main Content ---------- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition);
}

.top-bar {
    height: var(--top-bar-height);
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-glass);
    background: var(--top-bar-bg);
    backdrop-filter: blur(16px);
    position: sticky;
    top: 0;
    z-index: 50;
    transition: background var(--transition);
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-xs);
    transition: all var(--transition);
}

.menu-toggle:hover {
    background: var(--bg-glass);
    color: var(--text-primary);
}

.page-title {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.encryption-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-green);
    background: rgba(46, 196, 122, 0.1);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid rgba(46, 196, 122, 0.2);
}

.content-area {
    flex: 1;
    padding: 28px 32px;
}

/* ---------- Glass Card ---------- */
.glass {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
}

.glass:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
}

/* ---------- Dashboard Grid ---------- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 18px;
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    filter: blur(40px);
    opacity: 0.15;
    pointer-events: none;
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.red {
    background: var(--accent-brand-dim);
    color: var(--accent-brand);
}

.stat-icon.orange {
    background: rgba(232, 112, 48, 0.15);
    color: var(--accent-orange);
}

.stat-icon.green {
    background: rgba(46, 196, 122, 0.15);
    color: var(--accent-green);
}

.stat-icon.amber {
    background: rgba(232, 168, 40, 0.15);
    color: var(--accent-amber);
}

.stat-card::after {
    background: var(--accent-brand);
}

.stat-card:nth-child(2)::after {
    background: var(--accent-orange);
}

.stat-card:nth-child(3)::after {
    background: var(--accent-green);
}

.stat-value {
    display: block;
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 4px;
}

/* ---------- Panels ---------- */
.dashboard-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.panel {
    padding: 24px;
}

.panel-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 16px;
    letter-spacing: -0.01em;
}

.panel-desc {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 16px;
    line-height: 1.5;
}

.full-width {
    grid-column: 1 / -1;
}

.chart-placeholder {
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ---------- Strategy Chart ---------- */
.strategy-bars {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.strategy-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.strategy-label {
    width: 130px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.strategy-bar-bg {
    flex: 1;
    height: 28px;
    background: var(--strategy-bar-bg);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.strategy-bar {
    height: 100%;
    border-radius: 6px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    padding-left: 10px;
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
}

.strategy-bar.bar-random {
    background: var(--gradient-primary);
}

.strategy-bar.bar-deterministic {
    background: var(--gradient-warm);
}

.strategy-bar.bar-format_preserving {
    background: var(--gradient-green);
}

.strategy-bar.bar-encrypt_only {
    background: var(--gradient-amber);
}

.strategy-bar.bar-unknown {
    background: linear-gradient(135deg, #6b7280, #9ca3af);
}

.strategy-count {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-primary);
    min-width: 30px;
    text-align: right;
}

/* ---------- Activity List ---------- */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 320px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-xs);
    background: var(--activity-bg);
    border: 1px solid transparent;
    transition: all var(--transition);
}

.activity-item:hover {
    border-color: var(--border-hover);
    background: var(--activity-hover-bg);
}

.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.activity-dot.dot-tokenize {
    background: var(--accent-brand);
}

.activity-dot.dot-detokenize {
    background: var(--accent-cyan);
}

.activity-dot.dot-shred {
    background: var(--accent-red);
}

.activity-dot.dot-system {
    background: var(--accent-green);
}

.activity-text {
    flex: 1;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.activity-text strong {
    color: var(--text-primary);
}

.activity-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* ---------- Flow Diagram ---------- */
.flow-diagram {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px 0;
    overflow-x: auto;
}

.flow-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.flow-step span {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.flow-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.flow-icon:hover {
    transform: translateY(-4px);
}

.flow-icon.ingestion {
    background: var(--accent-brand-dim);
    color: var(--accent-brand);
}

.flow-icon.gateway {
    background: rgba(232, 112, 48, 0.15);
    color: var(--accent-orange);
}

.flow-icon.policy {
    background: rgba(232, 168, 40, 0.15);
    color: var(--accent-amber);
}

.flow-icon.tokenize {
    background: var(--accent-brand-dim);
    color: var(--accent-brand-light);
}

.flow-icon.vault {
    background: rgba(46, 196, 122, 0.15);
    color: var(--accent-green);
}

.flow-icon.audit {
    background: rgba(34, 197, 214, 0.15);
    color: var(--accent-cyan);
}

.flow-arrow {
    font-size: 1.3rem;
    color: var(--text-muted);
    font-weight: 300;
    animation: arrowPulse 2s infinite;
}

@keyframes arrowPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

/* ---------- Inputs & Forms ---------- */
.input-field {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    transition: all var(--transition);
    outline: none;
}

.input-field:focus {
    border-color: var(--accent-brand);
    box-shadow: var(--focus-ring);
}

.input-field::placeholder {
    color: var(--text-muted);
}

select.input-field {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b6b88'%3E%3Cpath d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--btn-primary-shadow);
}

.btn-primary:hover {
    box-shadow: var(--btn-primary-hover-shadow);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--bg-glass);
    color: var(--text-primary);
    border: 1px solid var(--border-glass);
}

.btn-secondary:hover {
    border-color: var(--accent-brand);
}

.btn-danger {
    background: rgba(218, 43, 38, 0.12);
    color: var(--accent-red);
    border: 1px solid rgba(218, 43, 38, 0.2);
}

.btn-danger:hover {
    background: rgba(218, 43, 38, 0.22);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.78rem;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 0.95rem;
    width: 100%;
    justify-content: center;
}

.btn-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xs);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    transition: all var(--transition);
}

.btn-icon:hover {
    color: var(--accent-red);
    border-color: var(--accent-red);
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ---------- Tokenize Layout ---------- */
.tokenize-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.field-inputs {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1.5fr 32px;
    gap: 8px;
    align-items: center;
    animation: slideIn 0.2s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
}

.field-actions {
    margin-bottom: 20px;
}

.options-section {
    margin-bottom: 20px;
}

.section-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.options-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.option-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* ---------- Results ---------- */
.results-area {
    min-height: 200px;
}

.results-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.result-card {
    padding: 16px;
    animation: slideIn 0.3s ease;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.result-field {
    font-weight: 700;
    font-size: 0.95rem;
}

.result-action {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.action-tokenize {
    background: var(--accent-brand-dim);
    color: var(--accent-brand);
}

.action-mask {
    background: rgba(232, 168, 40, 0.15);
    color: var(--accent-amber);
}

.action-pass {
    background: rgba(107, 114, 128, 0.15);
    color: var(--text-muted);
}

.action-encrypt {
    background: rgba(46, 196, 122, 0.15);
    color: var(--accent-green);
}

.result-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.result-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.82rem;
}

.result-label {
    min-width: 80px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
}

.result-token {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    background: var(--result-token-bg);
    padding: 4px 8px;
    border-radius: 4px;
    color: var(--accent-brand-light);
    word-break: break-all;
}

/* ---------- Badges ---------- */
.badge {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-random {
    background: var(--accent-brand-dim);
    color: var(--accent-brand);
}

.badge-deterministic {
    background: rgba(232, 112, 48, 0.15);
    color: var(--accent-orange);
}

.badge-format_preserving {
    background: rgba(46, 196, 122, 0.15);
    color: var(--accent-green);
}

.sensitivity-high {
    background: rgba(218, 43, 38, 0.15);
    color: var(--accent-red);
}

.sensitivity-medium {
    background: rgba(232, 168, 40, 0.15);
    color: var(--accent-amber);
}

.sensitivity-low {
    background: rgba(34, 197, 214, 0.15);
    color: var(--accent-cyan);
}

.sensitivity-none {
    background: rgba(107, 114, 128, 0.1);
    color: var(--text-muted);
}

/* ---------- Audit ---------- */
.audit-layout {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.integrity-banner {
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.integrity-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.integrity-info strong {
    display: block;
    font-size: 0.85rem;
}

.integrity-info span {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.integrity-valid {
    border-color: rgba(46, 196, 122, 0.3);
}

.integrity-valid svg {
    color: var(--accent-green);
}

.integrity-valid span {
    color: var(--accent-green);
}

.integrity-broken {
    border-color: rgba(218, 43, 38, 0.3);
    background: rgba(218, 43, 38, 0.05);
}

.integrity-broken svg {
    color: var(--accent-red);
}

.integrity-broken strong,
.integrity-broken span {
    color: var(--accent-red);
}

.filters-panel {
    padding: 16px 20px;
}

.filters-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.filter-label {
    flex: 1;
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.data-table th {
    text-align: left;
    padding: 12px 14px;
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-glass);
}

.data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--td-border);
    color: var(--text-secondary);
}

.data-table tr:hover td {
    background: var(--table-hover-bg);
}

.mono {
    font-family: var(--font-mono);
    font-size: 0.78rem;
}

.loading-row,
.empty-row,
.error-row {
    text-align: center;
    padding: 40px !important;
    color: var(--text-muted);
}

.error-row {
    color: var(--accent-red);
}

.action-badge {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
}

.action-detok {
    background: rgba(34, 197, 214, 0.15);
    color: var(--accent-cyan);
}

.action-shred {
    background: rgba(218, 43, 38, 0.15);
    color: var(--accent-red);
}

.action-system {
    background: rgba(46, 196, 122, 0.15);
    color: var(--accent-green);
}

.action-error {
    background: rgba(218, 43, 38, 0.15);
    color: var(--accent-red);
}

.hash-badge {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    background: var(--hash-bg);
    padding: 3px 8px;
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
}

.hash-badge:hover {
    color: var(--accent-brand-light);
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px;
}

.page-info {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ---------- Detokenize ---------- */
.detok-textarea {
    width: 100%;
    min-height: 120px;
    resize: vertical;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.6;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xs);
    padding: 12px 14px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.detok-textarea:focus {
    outline: none;
    border-color: var(--accent-brand);
    box-shadow: var(--focus-ring);
}

.detok-textarea::placeholder {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.78rem;
}

.detok-plaintext {
    background: rgba(46, 196, 122, 0.1);
    border: 1px solid rgba(46, 196, 122, 0.2);
    color: var(--accent-green);
    padding: 4px 10px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    user-select: all;
    cursor: text;
}

.error-text {
    color: var(--accent-red);
    font-size: 0.82rem;
}

/* ---------- Policies ---------- */
.policies-layout {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.policy-form {
    padding: 0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.form-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 600;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.policies-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.policy-card {
    padding: 16px;
}

.policy-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.policy-name {
    font-weight: 700;
    font-size: 0.95rem;
}

.policy-badges {
    display: flex;
    gap: 6px;
}

.policy-details {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.policy-details code {
    font-family: var(--font-mono);
    background: var(--code-inline-bg);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.75rem;
}

.action-encrypt_only {
    background: rgba(46, 196, 122, 0.15);
    color: var(--accent-green);
}

.action-passthrough {
    background: rgba(107, 114, 128, 0.15);
    color: var(--text-muted);
}

.builtin-section {
    margin-top: 8px;
}

.builtin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 10px;
}

.builtin-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-xs);
    background: var(--builtin-bg);
    border: 1px solid var(--border-glass);
    font-size: 0.8rem;
    overflow: hidden;
}

.builtin-name {
    font-weight: 700;
    min-width: 70px;
    flex-shrink: 0;
}

.builtin-card code {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.builtin-card .badge {
    flex-shrink: 0;
    white-space: nowrap;
}

/* ---------- API Docs ---------- */
.api-docs-layout {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.auth-methods {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.auth-method h3 {
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.auth-method .hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 6px;
}

.code-block {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    background: var(--code-block-bg);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xs);
    padding: 14px 18px;
    color: var(--accent-brand-light);
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    word-break: break-word;
    line-height: 1.6;
    max-width: 100%;
}

.endpoint-card {
    padding: 20px;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    margin-bottom: 16px;
    transition: all var(--transition);
    overflow: hidden;
}

.endpoint-card:hover {
    border-color: var(--border-hover);
}

.endpoint-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.method-badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 800;
    font-family: var(--font-mono);
    text-transform: uppercase;
}

.method-badge.post {
    background: var(--accent-brand-dim);
    color: var(--accent-brand);
}

.method-badge.get {
    background: rgba(46, 196, 122, 0.15);
    color: var(--accent-green);
}

.method-badge.delete {
    background: rgba(218, 43, 38, 0.15);
    color: var(--accent-red);
}

.endpoint-path {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--text-primary);
    word-break: break-all;
    min-width: 0;
}

.endpoint-card p {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.5;
}

.endpoint-details h4 {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin: 12px 0 6px;
    letter-spacing: 0.04em;
}

/* ---------- Empty / Error States ---------- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    gap: 16px;
}

.empty-state p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.error-msg {
    background: rgba(218, 43, 38, 0.08);
    border: 1px solid rgba(218, 43, 38, 0.2);
    border-radius: var(--radius-xs);
    padding: 14px 18px;
    color: var(--accent-red);
    font-size: 0.85rem;
}

/* ---------- Responsive ---------- */

/* -- Sidebar overlay backdrop (used on tablet/mobile) -- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    backdrop-filter: blur(2px);
}

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

/* === Large tablets / small desktops ( ≤ 1200px ) === */
@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-panels {
        grid-template-columns: 1fr;
    }

    .builtin-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    }
}

/* === Tablets ( ≤ 1024px ) === */
@media (max-width: 1024px) {
    .tokenize-layout {
        grid-template-columns: 1fr;
    }

    .auth-methods {
        grid-template-columns: 1fr;
    }

    .form-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }

    .flow-diagram {
        gap: 6px;
        padding: 16px 0;
    }

    .flow-icon {
        width: 48px;
        height: 48px;
    }

    .flow-step span {
        font-size: 0.7rem;
    }

    .stat-card {
        padding: 18px;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .stat-icon {
        width: 44px;
        height: 44px;
    }

    .panel {
        padding: 20px;
    }

    .content-area {
        padding: 24px;
    }

    .strategy-label {
        width: 110px;
        font-size: 0.75rem;
    }
}

/* === Tablet portrait / large phones ( ≤ 768px ) === */
@media (max-width: 768px) {

    /* Sidebar: off-screen, revealed as overlay */
    .sidebar {
        width: var(--sidebar-width);
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
    }

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

    .main-content {
        margin-left: 0;
    }

    .menu-toggle {
        display: flex;
    }

    /* Top bar */
    .top-bar {
        padding: 0 16px;
        height: 56px;
    }

    .page-title {
        font-size: 1.1rem;
    }

    .encryption-badge span {
        display: none;
        /* Show just icon */
    }

    /* Content */
    .content-area {
        padding: 16px 14px;
    }

    /* Dashboard */
    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .stat-card {
        padding: 14px;
        gap: 12px;
    }

    .stat-icon {
        width: 40px;
        height: 40px;
    }

    .stat-value {
        font-size: 1.3rem;
    }

    .stat-label {
        font-size: 0.72rem;
    }

    .panel {
        padding: 16px;
    }

    .panel-title {
        font-size: 0.95rem;
        margin-bottom: 12px;
    }

    /* Flow diagram: horizontally scrollable */
    .flow-diagram {
        justify-content: flex-start;
        overflow-x: auto;
        padding: 12px 8px;
        -webkit-overflow-scrolling: touch;
    }

    .flow-icon {
        width: 44px;
        height: 44px;
        flex-shrink: 0;
    }

    .flow-step {
        flex-shrink: 0;
    }

    .flow-step span {
        font-size: 0.65rem;
    }

    .flow-arrow {
        font-size: 1rem;
        flex-shrink: 0;
    }

    /* Strategy chart */
    .strategy-label {
        width: 90px;
        font-size: 0.7rem;
    }

    .strategy-bar-bg {
        height: 24px;
    }

    /* Activity list */
    .activity-list {
        max-height: 260px;
    }

    .activity-item {
        padding: 8px 10px;
    }

    .activity-time {
        font-size: 0.65rem;
    }

    /* Tokenize */
    .field-row {
        grid-template-columns: 1fr 1.5fr 28px;
        gap: 6px;
    }

    .options-row {
        grid-template-columns: 1fr;
    }

    /* Audit */
    .audit-layout {
        gap: 14px;
    }

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

    .filters-row .btn {
        width: 100%;
        justify-content: center;
    }

    .filters-panel {
        padding: 14px 16px;
    }

    .data-table {
        font-size: 0.75rem;
    }

    .data-table th,
    .data-table td {
        padding: 8px 10px;
        white-space: nowrap;
    }

    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        position: relative;
    }

    .data-table {
        min-width: 650px;
    }

    .action-badge {
        font-size: 0.62rem;
        padding: 2px 8px;
    }

    .hash-badge {
        font-size: 0.65rem;
        padding: 2px 6px;
    }

    .pagination {
        flex-wrap: wrap;
        gap: 8px;
    }

    /* Integrity banner */
    .integrity-banner {
        flex-direction: column;
        gap: 12px;
        padding: 14px 16px;
        text-align: center;
    }

    .integrity-info {
        flex-direction: column;
        gap: 8px;
    }

    .integrity-info svg {
        margin: 0 auto;
    }

    /* API docs */
    .api-docs-layout {
        gap: 16px;
    }

    .code-block {
        font-size: 0.7rem;
        padding: 10px 12px;
        max-width: calc(100vw - 60px);
    }

    .endpoint-card {
        padding: 14px;
        margin-bottom: 12px;
    }

    .endpoint-header {
        flex-wrap: wrap;
        gap: 8px;
    }

    .endpoint-path {
        font-size: 0.8rem;
    }

    .endpoint-card p {
        font-size: 0.78rem;
        margin-bottom: 8px;
    }

    .endpoint-details h4 {
        font-size: 0.72rem;
        margin: 8px 0 4px;
    }

    .auth-method h3 {
        font-size: 0.82rem;
    }

    .auth-method .hint {
        font-size: 0.72rem;
    }

    .auth-method .hint code {
        font-size: 0.68rem;
        word-break: break-all;
    }

    /* Policies */
    .form-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .builtin-grid {
        grid-template-columns: 1fr;
    }

    .policy-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .policy-details {
        flex-direction: column;
        gap: 8px;
    }

    /* Theme toggle */
    .theme-toggle {
        margin: 0 12px 8px;
        padding: 8px 12px;
    }

    /* Buttons */
    .btn-lg {
        padding: 12px 20px;
        font-size: 0.9rem;
    }

    /* Results */
    .result-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .result-label {
        min-width: unset;
    }
}

/* === Phones ( ≤ 480px ) === */
@media (max-width: 480px) {

    /* Dashboard */
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .stat-card {
        padding: 12px;
    }

    .stat-value {
        font-size: 1.2rem;
    }

    /* Top bar */
    .top-bar {
        height: 50px;
        padding: 0 12px;
    }

    .page-title {
        font-size: 1rem;
    }

    /* Content */
    .content-area {
        padding: 12px 10px;
    }

    .panel {
        padding: 14px 12px;
        border-radius: var(--radius-sm);
    }

    /* Flow shrinks further */
    .flow-icon {
        width: 36px;
        height: 36px;
    }

    .flow-step span {
        font-size: 0.6rem;
    }

    .flow-arrow {
        font-size: 0.85rem;
    }

    /* Strategy chart stacks */
    .strategy-row {
        flex-wrap: wrap;
        gap: 4px;
    }

    .strategy-label {
        width: 100%;
        font-size: 0.72rem;
    }

    .strategy-bar-bg {
        height: 20px;
    }

    /* Tokenize: field names full-width */
    .field-row {
        grid-template-columns: 1fr 28px;
        gap: 4px;
    }

    .field-row .field-name {
        grid-column: 1 / -1;
    }

    /* Policies */
    .form-grid {
        grid-template-columns: 1fr;
    }

    .policy-badges {
        flex-wrap: wrap;
    }

    /* API docs */
    .endpoint-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .auth-methods {
        gap: 10px;
    }

    .code-block {
        font-size: 0.68rem;
        padding: 8px 10px;
    }

    /* Audit table tighter */
    .data-table {
        min-width: 600px;
    }

    .data-table th,
    .data-table td {
        padding: 6px 8px;
        font-size: 0.7rem;
    }

    /* Pagination */
    .pagination {
        flex-wrap: wrap;
        gap: 8px;
        padding: 12px 8px;
    }

    .page-info {
        font-size: 0.72rem;
    }

    /* Activity */
    .activity-item {
        gap: 8px;
        padding: 6px 8px;
    }

    .activity-text {
        font-size: 0.72rem;
    }

    /* Results stacked */
    .result-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .result-token {
        font-size: 0.7rem;
    }

    /* Sidebar */
    .sidebar-header {
        padding: 16px 14px 14px;
    }

    .logo-img {
        width: 110px;
    }

    /* Buttons bigger touch target */
    .btn {
        padding: 10px 16px;
    }

    .btn-icon {
        width: 36px;
        height: 36px;
    }

    /* Filters */
    .filter-label {
        font-size: 0.72rem;
    }

    /* Builtin cards */
    .builtin-card {
        padding: 8px 10px;
        font-size: 0.75rem;
    }
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}