:root {
    --bg: #0a0a0a;
    --bg-card: #141414;
    --bg-card-hover: #1a1a1a;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.14);
    --text: #e8e8e8;
    --text-soft: #999;
    --text-dim: #666;
    --accent: #6ee7b7;
    --accent-dim: rgba(110, 231, 183, 0.15);
    --red: #f87171;
    --red-dim: rgba(248, 113, 113, 0.12);
    --radius: 16px;
    --radius-sm: 12px;
    --radius-xs: 8px;
    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

html, body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

/* -- Layout shell -- */

.shell {
    max-width: 720px;
    margin: 0 auto;
    padding: 24px 20px 64px;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
}

.back-link {
    color: var(--text-soft);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.15s;
}

.back-link:hover {
    color: var(--text);
}

.reset-btn {
    padding: 6px 14px;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    background: transparent;
    color: var(--text-soft);
    font: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

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

.page-title {
    margin: 0 0 8px;
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.page-subtitle {
    margin: 0 0 32px;
    color: var(--text-soft);
    font-size: 1rem;
    line-height: 1.5;
}

/* -- View toggle pills -- */

.view-toggle {
    display: flex;
    gap: 4px;
    padding: 4px;
    border-radius: 999px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    margin-bottom: 32px;
}

.toggle-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--text-soft);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.toggle-btn:hover {
    color: var(--text);
}

.toggle-btn.active {
    background: var(--accent-dim);
    color: var(--accent);
}

/* -- Cards -- */

.card {
    padding: 24px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-card);
    margin-bottom: 16px;
}

.card-label {
    display: block;
    margin-bottom: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-dim);
}

.card h2 {
    margin: 0 0 4px;
    font-size: 1.2rem;
    font-weight: 700;
}

.card h3 {
    margin: 0 0 4px;
    font-size: 1.05rem;
    font-weight: 600;
}

.card p {
    margin: 0;
    color: var(--text-soft);
    font-size: 0.9rem;
    line-height: 1.55;
}

/* -- Data rows in patient snapshot -- */

.data-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.data-row:last-child {
    border-bottom: none;
}

.data-label {
    color: var(--text-soft);
}

.data-value {
    font-weight: 500;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag {
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    font-size: 0.8rem;
    color: var(--text-soft);
}

/* -- Toggle switches -- */

.consent-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.consent-row:last-child {
    border-bottom: none;
}

.consent-info {
    flex: 1;
    min-width: 0;
}

.consent-title {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 2px;
}

.consent-desc {
    font-size: 0.8rem;
    color: var(--text-dim);
}

/* Toggle switch styling */
.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
    margin-left: 16px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-track {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    cursor: pointer;
    transition: background 0.2s;
}

.toggle-track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-track {
    background: var(--accent);
}

.toggle-switch input:checked + .toggle-track::after {
    transform: translateX(20px);
}

/* -- Action buttons -- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--accent);
    color: #0a0a0a;
}

.btn-primary:hover {
    opacity: 0.9;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-strong);
    color: var(--text);
}

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

.btn-warn {
    background: transparent;
    border: 1px solid var(--border-strong);
    color: var(--text-soft);
}

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

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

/* -- Result cards -- */

.result-card {
    padding: 20px;
    border-radius: var(--radius-sm);
    margin-top: 16px;
}

.result-card.success {
    background: rgba(110, 231, 183, 0.08);
    border: 1px solid rgba(110, 231, 183, 0.2);
}

.result-card.blocked {
    background: var(--red-dim);
    border: 1px solid rgba(248, 113, 113, 0.2);
}

.result-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.result-card.success .result-title {
    color: var(--accent);
}

.result-card.blocked .result-title {
    color: var(--red);
}

.result-detail {
    font-size: 0.85rem;
    color: var(--text-soft);
    margin-bottom: 0;
}

.result-meta {
    margin-top: 10px;
    font-size: 0.78rem;
    color: var(--text-dim);
}

/* -- Hidden fields list -- */

.hidden-list {
    margin-top: 12px;
}

.hidden-list-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    margin-bottom: 8px;
}

.hidden-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-xs);
    background: var(--red-dim);
    color: var(--red);
    font-size: 0.82rem;
    margin-bottom: 6px;
}

.hidden-item:last-child {
    margin-bottom: 0;
}

.hidden-item::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--red);
    opacity: 0.5;
    flex-shrink: 0;
}

/* Visibility rows */
.visibility-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.visibility-row:last-child {
    border-bottom: none;
}

.vis-label {
    font-size: 0.9rem;
    color: var(--text-soft);
}

.vis-status {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 100px;
    letter-spacing: 0.02em;
}

.vis-allowed {
    background: var(--accent-dim);
    color: var(--accent);
}

.vis-sealed {
    background: var(--red-dim);
    color: var(--red);
}

/* -- Access log -- */

.access-log {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.log-entry {
    display: grid;
    grid-template-columns: 1fr 1fr 1.2fr auto;
    gap: 12px;
    align-items: center;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-xs);
    font-size: 0.85rem;
}

.log-entry.granted {
    border-left: 3px solid var(--accent);
}

.log-entry.blocked {
    border-left: 3px solid var(--red);
}

.log-who {
    color: var(--text);
    font-weight: 600;
}

.log-what {
    color: var(--text-soft);
}

.log-when {
    color: var(--text-dim);
    font-family: monospace;
    font-size: 0.8rem;
}

.log-status {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 100px;
}

.log-entry.granted .log-status {
    background: var(--accent-dim);
    color: var(--accent);
}

.log-entry.blocked .log-status {
    background: var(--red-dim);
    color: var(--red);
}

.empty-log {
    color: var(--text-dim);
    font-style: italic;
    font-size: 0.9rem;
}

@media (max-width: 640px) {
    .log-entry {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }
}

/* -- Sub-section headers -- */

.section-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 12px;
}

/* -- Divider -- */

.divider {
    height: 1px;
    background: var(--border);
    margin: 24px 0;
    border: none;
}

/* -- Empty state -- */

.empty-state {
    color: var(--text-dim);
    font-size: 0.85rem;
    font-style: italic;
}

/* -- View transitions -- */

.view-content {
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* -- Responsive -- */

@media (max-width: 540px) {
    .shell {
        padding: 16px 14px 48px;
    }

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

    .toggle-btn {
        font-size: 0.8rem;
        padding: 8px 10px;
    }

    .card {
        padding: 18px;
    }
}
