:root {
    /* Color Palette - Security Themed */
    --bg-main: #0B1120;
    --bg-panel: rgba(15, 23, 42, 0.7);
    --border-color: rgba(148, 163, 184, 0.15);

    --primary: #38BDF8;
    /* Light Blue */
    --primary-hover: #0284C7;

    --success: #34D399;
    /* Emerald */
    --success-bg: rgba(52, 211, 153, 0.15);

    --warning: #FBBF24;
    /* Amber */
    --warning-bg: rgba(251, 191, 36, 0.15);

    --danger: #F87171;
    /* Red */
    --danger-bg: rgba(248, 113, 113, 0.15);

    --text-main: #F8FAFC;
    --text-muted: #94A3B8;

    --font-sans: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --radius: 12px;
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow: hidden;
    /* App layout handles scrolling */
    background-image:
        radial-gradient(circle at top right, rgba(56, 189, 248, 0.05), transparent 40%),
        radial-gradient(circle at bottom left, rgba(52, 211, 153, 0.05), transparent 40%);
}

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

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

.mb-4 {
    margin-bottom: 1rem;
}

.mt-4 {
    margin-top: 1rem;
}

.w-full {
    width: 100%;
}

.justify-center {
    justify-content: center;
}

.hidden {
    display: none !important;
}

/* Glass Panels */
.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.glass-input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    outline: none;
    transition: all 0.2s;
}

.glass-input:focus {
    border-color: var(--primary);
    background: rgba(0, 0, 0, 0.3);
}

textarea.glass-input {
    resize: vertical;
    width: 100%;
    font-family: var(--font-mono);
}

select.glass-input {
    width: 100%;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
}

/* Base Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    font-family: var(--font-sans);
}

.btn-sm {
    padding: 0.5rem 0.875rem;
    font-size: 0.85rem;
}

.btn-primary {
    background: var(--primary);
    color: #000;
}

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

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Layout */
.app-layout {
    display: flex;
    height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
}

/* Sidebar */
.sidebar {
    width: 260px;
    border-radius: 0;
    border-top: none;
    border-bottom: none;
    border-left: none;
    display: flex;
    flex-direction: column;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.brand h1 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.success-glow {
    filter: drop-shadow(0 0 4px var(--success));
}

.nav-menu {
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    width: 100%;
}

.nav-item:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.03);
}

.nav-item.active {
    color: var(--primary);
    background: rgba(56, 189, 248, 0.1);
    border-right: 3px solid var(--primary);
}

.history-section {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
}

.history-section h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.history-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.history-item {
    font-size: 0.85rem;
    color: var(--text-main);
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    justify-content: space-between;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.history-item .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 0.3rem;
}

.dot-success {
    background: var(--success);
    box-shadow: 0 0 5px var(--success);
}

.dot-warning {
    background: var(--warning);
    box-shadow: 0 0 5px var(--warning);
}

.dot-danger {
    background: var(--danger);
    box-shadow: 0 0 5px var(--danger);
}

/* Main Content area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Search Header */
.search-header {
    padding: 1.5rem;
    border-radius: 0;
    border-top: none;
    border-left: none;
    border-right: none;
    z-index: 10;
}

.search-bar {
    display: flex;
    max-width: 800px;
    margin: 0 auto;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    padding: 0.25rem 0.25rem 0.25rem 1.5rem;
    align-items: center;
    transition: border-color 0.2s;
}

.search-bar:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.1);
}

.protocol-prefix {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.95rem;
    user-select: none;
}

#domain-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 1rem;
    padding: 0.75rem 0.5rem;
    outline: none;
}

.search-bar .btn {
    border-radius: 26px;
    padding: 0.75rem 1.5rem;
}

/* Scrollable Container */
.scroll-container {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    position: relative;
}

/* Dashboard States */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    gap: 1rem;
}

.empty-state h2 {
    font-size: 1.5rem;
    font-weight: 500;
}

.empty-state p {
    color: var(--text-muted);
}

/* Spinner */
.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 1rem;
}

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

/* Dashboard Content */
.dashboard-scroll {
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.dashboard-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.scanned-domain {
    font-size: 1.75rem;
    font-weight: 600;
    font-family: var(--font-mono);
}

.card {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.card-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Grids */
.grid-top {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1.5rem;
}

.grid-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

/* Grade Display */
.grade-display {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex: 1;
}

.grade-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 700;
    font-family: var(--font-mono);
    border: 4px solid var(--success);
    color: var(--success);
    box-shadow: 0 0 20px rgba(52, 211, 153, 0.2);
}

.grade-A {
    border-color: var(--success);
    color: var(--success);
    box-shadow: 0 0 20px rgba(52, 211, 153, 0.2);
}

.grade-B {
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.2);
}

.grade-C {
    border-color: var(--warning);
    color: var(--warning);
    box-shadow: 0 0 20px rgba(251, 191, 36, 0.2);
}

.grade-F {
    border-color: var(--danger);
    color: var(--danger);
    box-shadow: 0 0 20px rgba(248, 113, 113, 0.2);
}

.grade-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    display: inline-block;
}

.status-secure {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(52, 211, 153, 0.3);
}

.status-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.status-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(248, 113, 113, 0.3);
}

.protocol-ver {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* Expiry Countdown */
.expiry-card {
    position: relative;
    justify-content: center;
}

.countdown {
    font-size: 3.5rem;
    font-weight: 700;
    line-height: 1;
    color: var(--text-main);
    font-family: var(--font-mono);
}

.countdown-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.timeline {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.timeline-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.progress-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--success);
    border-radius: 3px;
    transition: width 1s ease-out;
}

/* Details Key Value Strings */
.key-value-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.kv-row {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.kv-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.kv-key {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.kv-val {
    color: var(--text-main);
    font-weight: 500;
    font-size: 0.85rem;
    text-align: right;
    max-width: 60%;
    word-break: break-all;
}

/* Chain Viz */
.chain-viz {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-left: 10px;
    border-left: 2px solid var(--border-color);
    margin-left: 10px;
}

.chain-node {
    position: relative;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.chain-node::before {
    content: '';
    position: absolute;
    left: -18px;
    top: 50%;
    width: 16px;
    height: 2px;
    background: var(--border-color);
}

.chain-node::after {
    content: '';
    position: absolute;
    left: -22px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 5px var(--success);
}

.chain-name {
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.25rem;
}

.chain-type {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal {
    width: 100%;
    max-width: 500px;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.25rem;
}

.close-modal {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

.close-modal:hover {
    color: var(--text-main);
}

.modal-body {
    padding: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 900px) {

    .grid-top,
    .grid-details {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
    }
}