:root {
    --primary: #8b5cf6;
    /* Violet */
    --primary-glow: rgba(139, 92, 246, 0.5);
    --secondary: #ec4899;
    /* Pink */
    --bg-dark: #0f172a;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

body {
    font-family: 'Inter', sans-serif;
    background: radial-gradient(circle at top left, #1e1b4b, #0f172a, #000000);
    color: var(--text-main);
    min-height: 100vh;
    margin: 0;
    display: flex;
    justify-content: center;
    padding: 2rem;
    box-sizing: border-box;
}

.container {
    width: 100%;
    max-width: 600px;
    /* Narrower for focused flow */
}

header {
    text-align: center;
    margin-bottom: 2rem;
    animation: fadeInDown 0.8s ease-out;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin: 0;
    background: linear-gradient(to right, #c084fc, #f472b6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 20px rgba(192, 132, 252, 0.3);
}

.subtitle {
    color: var(--text-muted);
    font-size: 1rem;
    margin-top: 0.5rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* Glass Card */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}

.input-group {
    padding: 1.5rem;
}

.input-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-main);
    text-align: center;
}

input[type="text"] {
    width: 100%;
    padding: 1rem 1.5rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 0.75rem;
    font-size: 1.25rem;
    color: white;
    text-align: center;
    letter-spacing: 0.1em;
    outline: none;
    transition: all 0.3s;
    box-sizing: border-box;
    /* Clean font inherited */
}

input[type="text"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
    background: rgba(0, 0, 0, 0.5);
}


/* Name Search & Results */
.actions {
    margin-top: 1rem;
    display: flex;
    justify-content: center;
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
    padding: 0.5rem 1.5rem;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--primary);
    color: white;
    box-shadow: 0 0 10px var(--primary-glow);
}

.name-results {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.result-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    padding: 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.result-item:hover {
    background: rgba(139, 92, 246, 0.2);
    border-color: var(--primary);
}

.result-item strong {
    display: block;
    color: var(--text-main);
    font-size: 1.05rem;
}

.result-item small {
    display: block;
    color: var(--primary);
    margin-top: 0.2rem;
}

.result-item .address {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
}


/* TABS CONTAINER */
.tabs-container {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0;
    /* Connected to card below visually */
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.tab-btn {
    flex: 1;
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid var(--glass-border);
    border-bottom: none;
    border-top-left-radius: 0.75rem;
    border-top-right-radius: 0.75rem;
    padding: 0.8rem 0.5rem;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn:hover {
    background: rgba(30, 41, 59, 0.8);
    color: white;
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 -4px 15px var(--primary-glow);
    border-color: var(--primary);
    position: relative;
    z-index: 10;
}

/* RESULT CARD */
.result-card {
    border-top-left-radius: 0;
    /* Connect to tabs */
    border-top-right-radius: 0;
    /* Connect to tabs */
    padding: 1.5rem;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: -1px;
    /* Overlap border */
}

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

.result-label {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-muted);
    letter-spacing: 0.1em;
}

.text-preview {
    font-family: 'Times New Roman', Times, serif;
    /* REQUESTED FONT */
    font-size: 11pt;
    line-height: 1.4;
    color: #000;
    background: #fff;
    padding: 1.5rem;
    border-radius: 4px;
    white-space: pre-wrap;
    flex: 1;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* LINKS */
.or-links {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 1rem;
}

.link-group {
    display: flex;
    gap: 2px;
    /* Connect them visually */
}

.link-btn {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(236, 72, 153, 0.3);
    color: #f472b6;
    padding: 0.6rem 1rem;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

/* First button in group (Label) */
.link-group .link-btn:first-child {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
    border-right: none;
}

/* Second button in group (Download Icon) */
.link-group .link-btn:last-child {
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
    padding-left: 0.8rem;
    padding-right: 0.8rem;
    border-left: 1px solid rgba(236, 72, 153, 0.3);
}

.link-btn:hover {
    border-color: #ec4899;
    background: rgba(236, 72, 153, 0.1);
    box-shadow: 0 0 15px rgba(236, 72, 153, 0.2);
    transform: translateY(-2px);
    color: #fff;
    z-index: 10;
}

.spin {
    animation: spin 1s linear infinite;
}

.copy-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
}

.copy-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.error {
    color: #ef4444;
    font-size: 0.875rem;
    margin-top: 1rem;
    text-align: center;
    display: block;
    animation: shake 0.4s;
}

/* Loading */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 2rem 0;
    color: var(--text-muted);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 0.5rem;
}

.hidden {
    display: none !important;
}

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

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-4px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(4px, 0, 0);
    }
}

/* STRUCTURE TREE */
.structure-section {
    margin-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 1rem;
}

.full-width {
    width: 100%;
    margin-bottom: 1rem;
}

.structure-tree {
    background: rgba(0, 0, 0, 0.2);
    padding: 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    overflow-x: auto;
}

.tree-list,
.tree-children {
    list-style: none;
    padding-left: 1.5rem;
    position: relative;
}

.tree-list {
    padding-left: 0;
}

/* Connecting lines */
.tree-children::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0.5rem;
    width: 1px;
    background: rgba(255, 255, 255, 0.2);
}

.tree-node {
    margin: 0.5rem 0;
    position: relative;
}

.tree-children .tree-node::before {
    content: '';
    position: absolute;
    left: -1rem;
    top: 0.8rem;
    width: 1rem;
    height: 1px;
    background: rgba(255, 255, 255, 0.2);
}

.node-content {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem;
    border-radius: 4px;
    display: inline-block;
    border: 1px solid transparent;
}

.node-content.person {
    border-color: rgba(139, 92, 246, 0.3);
    /* Purple border for people */
}

.node-content.management {
    border-color: rgba(56, 189, 248, 0.3);
    /* Blue border for management */
    background: rgba(56, 189, 248, 0.05);
}

.node-leaf .node-content {
    /* Different style for leaves */
}

.share-badge {
    background: var(--secondary);
    color: white;
    font-size: 0.75rem;
    padding: 0.1rem 0.4rem;
    border-radius: 99px;
    margin-left: 0.5rem;
}

/* --- APP TABS --- */
.app-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 2rem;
    justify-content: center;
}

.app-tab-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    padding: 1rem 2rem;
    border-radius: 99px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 600;
    transition: all 0.3s;
}

.app-tab-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.app-tab-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 0 15px var(--primary-glow);
    border-color: var(--primary);
}

.app-view.hidden {
    display: none !important;
}

/* Modify container to be wider when PoA is active */
body:has(#view-poa:not(.hidden)) .container {
    max-width: 1200px;
}

/* --- BHK STYLES --- */

.bhk-app-container {
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --secondary: #ec4899;
    --background: transparent;
    --surface: rgba(30, 41, 59, 0.4);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    --success: #10b981;
    --error: #ef4444;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: var(--glass-bg);
    padding: 2rem;
    border-radius: 1rem;
    width: 90%;
    max-width: 450px;
    border: 1px solid var(--glass-border);
    animation: fadeInDown 0.3s ease-out;
    box-shadow: var(--shadow);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--text-main);
}

.close-modal {
    cursor: pointer;
    font-size: 1.8rem;
    color: var(--text-muted);
    line-height: 1;
    transition: color 0.2s;
}

.close-modal:hover {
    color: white;
}

.poa-opt-btn {
    width: 100%;
    padding: 1rem;
    margin-bottom: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: white;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 1.05rem;
    font-weight: 500;
    transition: all 0.2s;
    text-align: center;
}

.poa-opt-btn:last-child {
    margin-bottom: 0;
}

.poa-opt-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
    transform: translateY(-2px);
}

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

.bhk-body-override {
    font-family: 'Inter', sans-serif;
    background-color: var(--background);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
}

/* Layout */
.bhk-app-container {
    display: grid;
    grid-template-columns: 320px 1fr;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(10px);
    border-right: 1px solid var(--border);
    color: #f1f5f9;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    z-index: 10;
}

.sidebar-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #ffffff;
    margin-bottom: 0.5rem;
}

.sidebar-header p {
    font-size: 0.875rem;
    color: #94a3b8;
}

.main-controls {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    flex-grow: 1;
}

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

.control-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #cbd5e1;
}

.select-styled {
    appearance: none;
    background-color: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    cursor: pointer;
    width: 100%;
    transition: all 0.2s ease;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.2rem;
}

.select-styled:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 0.875rem 1rem;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
}

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

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    background-color: #94a3b8;
    cursor: not-allowed;
    transform: none;
}

/* Main Content */
.main-content {
    padding: 2rem 3rem;
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.page-header {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.page-header h2 {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Forms and Cards */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 2rem;
    border: 1px solid var(--border);
    animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.card-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

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

.form-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

.form-input,
.form-select {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text-main);
    transition: all 0.2s ease;
    background-color: var(--surface);
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1rem;
    padding-right: 2.5rem;
}

/* Scraper specific */
.ico-group {
    display: flex;
    gap: 0.5rem;
}

.ico-group input {
    flex-grow: 1;
}

.btn-secondary {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid var(--border);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

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

/* PO Result Box */
.po-result {
    background-color: rgba(0, 0, 0, 0.2);
    border: 1px dashed rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-top: 1rem;
    font-size: 0.9rem;
    display: none;
}

.po-result.active {
    display: block;
    animation: slideUp 0.3s ease-out;
}

.po-result strong {
    color: var(--primary);
    display: block;
    margin-bottom: 0.25rem;
}

/* Loading Overlay */
.loader-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    z-index: 5;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.loader-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.hidden {
    display: none !important;
}

/* Person Checkbox list */
.person-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    cursor: pointer;
}

/* Dropdown results */
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    max-height: 250px;
    overflow-y: auto;
    z-index: 50;
    display: none;
    flex-direction: column;
}

.search-results.active {
    display: flex;
}

.search-result-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.search-result-item strong {
    display: block;
    color: var(--text-main);
    margin-bottom: 0.2rem;
    font-size: 0.95rem;
}

.search-result-item small {
    color: var(--text-muted);
    display: block;
}

/* Number Selectors */
.section-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

/* Toasts */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 50;
}

.toast {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-left: 4px solid var(--primary);
    color: var(--text-main);
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transform: translateX(120%);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.show {
    transform: translateX(0);
}

.toast.error {
    border-left-color: var(--error);
}

.toast.success {
    border-left-color: var(--success);
}