/* KP Horary - Styles (RVA v3 Design) */
/* Light Theme (default) + Dark Theme */

:root {
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* Light theme - RVA v3 style */
    --bg-primary: #f8fafc;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --bg-header: #ffffff;
    --bg-footer: #f9fafb;
    --bg-table-header: #f8fafc;
    --bg-table-row-alt: #fafafa;
    --bg-highlight: #f1f5f9;
    --bg-kp-preview: #f9fafb;

    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --text-header: #111827;
    --text-label: #374151;
    --text-accent: #111827;

    --border-color: #e2e8f0;
    --border-input: #d1d5db;
    --border-focus: #000000;

    --btn-primary-bg: #0f172a;
    --btn-primary-text: #ffffff;
    --btn-primary-hover: #1e293b;
    --btn-small-bg: #f1f5f9;
    --btn-small-text: #374151;

    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-card-hover: 0 4px 12px rgba(0, 0, 0, 0.08);

    --retrograde-color: #dc2626;
    --house-num-color: #111827;
    --sig-color: #059669;

    --radius: 8px;
    --radius-sm: 6px;
    --radius-xl: 12px;
}

html.dark {
    --bg-primary: #000000;
    --bg-card: #0a0a0a;
    --bg-input: #1a1a1a;
    --bg-header: #000000;
    --bg-footer: #000000;
    --bg-table-header: #111111;
    --bg-table-row-alt: #0a0a0a;
    --bg-highlight: #1a1a1a;
    --bg-kp-preview: #111111;

    --text-primary: #f0f0f0;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --text-header: #f0f0f0;
    --text-label: #d4d4d8;
    --text-accent: #f0f0f0;

    --border-color: #262626;
    --border-input: #404040;
    --border-focus: #f0f0f0;

    --btn-primary-bg: #f0f0f0;
    --btn-primary-text: #000000;
    --btn-primary-hover: #d4d4d4;
    --btn-small-bg: #1a1a1a;
    --btn-small-text: #d4d4d8;

    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-card-hover: 0 4px 12px rgba(0, 0, 0, 0.3);

    --retrograde-color: #ef4444;
    --house-num-color: #f0f0f0;
    --sig-color: #10b981;
}

/* Smooth theme transition */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: 14px;
    line-height: 1.5;
}

/* Header - RVA v3 Style */
.header {
    position: sticky;
    top: 0;
    z-index: 50;
    width: 100%;
    background: var(--bg-header);
    color: var(--text-header);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    height: 56px;
    align-items: center;
    padding: 0 16px;
    gap: 8px;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.logo-container img { height: 28px; width: auto; }
.logo-light { display: block; }
.logo-dark { display: none; }
html.dark .logo-light { display: none; }
html.dark .logo-dark { display: block; }

.header-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
}

.header-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.header-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
    white-space: nowrap;
}

.header-spacer { flex: 1; }

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-ok {
    color: var(--sig-color);
    font-size: 0.78rem;
}

.status-error {
    color: var(--retrograde-color);
    font-size: 0.78rem;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--bg-highlight);
    color: var(--text-primary);
    border-color: var(--border-input);
}

.icon-btn svg { width: 18px; height: 18px; }
.sun-icon { display: block; }
.moon-icon { display: none; }
html.dark .sun-icon { display: none; }
html.dark .moon-icon { display: block; }

/* Language Dropdown */
.lang-dropdown {
    position: relative;
}

.lang-btn {
    width: auto;
    padding: 0 10px;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

#lang-label {
    font-size: 0.75rem;
    font-weight: 600;
}

.lang-menu {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 6px;
    width: 150px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    z-index: 100;
    overflow: hidden;
}

html.dark .lang-menu {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.lang-menu a {
    display: block;
    padding: 8px 14px;
    font-size: 0.78rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: background 0.15s;
}

.lang-menu a:hover {
    background: var(--bg-highlight);
}

.lang-menu a.active {
    font-weight: 700;
    color: var(--sig-color);
}

/* User Avatar */
.user-avatar {
    border-radius: 50%;
}

/* Sun/Moon icons for theme toggle */
.sun-icon {
    display: block;
}

.moon-icon {
    display: none;
}

html.dark .sun-icon {
    display: none;
}

html.dark .moon-icon {
    display: block;
}

/* Logo switching for dark/light mode */
.logo-light {
    display: block;
}

.logo-dark {
    display: none;
}

html.dark .logo-light {
    display: none;
}

html.dark .logo-dark {
    display: block;
}

/* Main */
.app-main {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 24px 16px;
    box-sizing: border-box;
}

/* Input Section */
.input-section {
    margin-bottom: 24px;
}

.input-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 12px 16px;
    box-shadow: var(--shadow-card);
}

/* Settings Panel */
.settings-panel {
    margin-top: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 24px;
    color: var(--text-primary);
    box-shadow: var(--shadow-card);
}

.settings-section {
    margin-bottom: 4px;
}

.settings-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 14px;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.settings-grid-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.settings-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.settings-group label {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: none;
}

.settings-input {
    height: 44px;
    padding: 8px 14px;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: var(--font-family);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.settings-input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.08);
}

html.dark .settings-input:focus {
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
}

.settings-input::placeholder {
    color: var(--text-muted);
}

.settings-divider {
    height: 1px;
    background: var(--border-color);
    margin: 20px 0;
}

.settings-info {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 4px;
    display: inline-block;
    margin-right: 12px;
}

/* Gear icon active state */
#settings-btn.active {
    background: var(--bg-highlight);
    color: var(--text-primary);
    border-color: var(--border-input);
}

#settings-btn svg {
    transition: transform 0.3s ease;
}

#settings-btn.active svg {
    transform: rotate(90deg);
}

/* Primary Row - Inline like rva-v3 */
.form-row-primary {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
}

.form-row-primary .input-field {
    height: 44px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
}

/* Name & Question fields */
.name-field {
    width: 120px;
    flex-shrink: 0;
}

.question-field {
    width: 160px;
    flex-shrink: 1;
    min-width: 100px;
}

/* KP Number inline */
.kp-inline {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.kp-inline .input-field {
    width: 90px;
    text-align: center;
    font-weight: 600;
}

.kp-range-inline {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 400;
    white-space: nowrap;
}

/* Time inline */
.time-inline-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

/* Timezone select in primary row */
.tz-select {
    flex-shrink: 0;
    min-width: 90px;
}

/* Location inline with pin icon */
.location-inline {
    flex: 1;
    min-width: 0;
}

.location-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.location-pin-icon {
    position: absolute;
    left: 10px;
    color: var(--text-muted);
    flex-shrink: 0;
    z-index: 1;
    pointer-events: none;
}

.location-input {
    padding-left: 32px !important;
    width: 100%;
}

.location-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-input);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    max-height: 220px;
    overflow-y: auto;
    z-index: 50;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.location-dropdown.active {
    display: block;
}

.loc-item {
    padding: 8px 12px;
    font-size: 0.8rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    transition: background 0.15s;
    line-height: 1.4;
}

.loc-item:last-child {
    border-bottom: none;
}

.loc-item:hover {
    background: var(--bg-highlight);
}

.loc-empty {
    color: var(--text-muted);
    cursor: default;
    font-style: italic;
}

.loc-empty:hover {
    background: none;
}

/* KP Preview */
.kp-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    margin-top: 6px;
    font-size: 0.78rem;
    flex-wrap: wrap;
    color: var(--text-secondary);
}

.preview-sign {
    font-weight: 600;
    color: var(--text-primary);
}

.preview-star {
    font-weight: 500;
}

.preview-sub {
    font-weight: 500;
}

.preview-deg {
    color: var(--text-muted);
    font-family: monospace;
    font-size: 0.75rem;
}

.preview-sep {
    color: var(--border-color);
}

.preview-hint {
    color: var(--text-muted);
    font-style: italic;
}

.btn-small {
    padding: 6px 10px;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
    background: var(--btn-small-bg);
    color: var(--btn-small-text);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-family);
    white-space: nowrap;
    height: 44px;
}

.btn-small:hover {
    background: var(--bg-highlight);
}

/* Timezone & Ayanamsa Info */
.tz-info {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 2px;
    margin-right: 12px;
}

.settings-panel .tz-info {
    color: var(--text-muted);
}

.tz-auto {
    color: var(--sig-color);
}

.tz-estimated {
    color: #d97706;
}

/* Input field base */
.input-field {
    height: 40px;
    padding: 8px 12px;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: var(--font-family);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-field:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.08);
}

html.dark .input-field:focus {
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
}

/* Submit Button */
.btn-primary {
    height: 44px;
    padding: 0 28px;
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    border: 1px solid var(--btn-primary-bg);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-family);
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-primary:hover:not(:disabled) {
    background: var(--btn-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================== */
/* RESULTS SECTION - RVA V3 Style */
/* ============================== */

.results-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 16px 20px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
    transition: box-shadow 0.2s;
    margin-top: 10px;
}

.card-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ============== */
/* PANCHANG - Word-based layout */
/* ============== */

.panchang-bar {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
    font-size: 0.82rem;
    color: var(--text-primary);
    overflow-x: auto;
}

.panchang-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 16px;
    white-space: nowrap;
    flex-shrink: 0;
    border-right: 1px solid var(--border-color);
}

.panchang-item:last-child {
    border-right: none;
}

.pan-icon {
    color: var(--text-muted);
    flex-shrink: 0;
}

.pan-label {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.72rem;
}

.pan-value {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.82rem;
}

.pan-sunrise {
    color: #f59e0b;
}

.pan-sunset {
    color: #ef4444;
}

.panchang-divider {
    display: none;
}

[data-theme="dark"] .pan-sunrise,
html.dark .pan-sunrise {
    color: #fbbf24;
}

[data-theme="dark"] .pan-sunset,
html.dark .pan-sunset {
    color: #f87171;
}

/* ============== */
/* SECTION HEADER */
/* ============== */

.section-header {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    padding: 14px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: var(--shadow-card);
    margin: 0;
    margin-top: 10px;
    border-bottom: none;
}

/* Connect section header to its content cards below */
.section-header+.two-col-layout {
    margin-top: -11px;
}

.section-header+.two-col-layout>.result-card {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

/* Significators (second two-col-layout, not connected to section-header) */
.two-col-layout+.two-col-layout {
    margin-top: 10px;
}

/* Dasha section spacing */
.dasha-section {
    margin-top: 10px;
}

/* Aspects section spacing */
.aspects-header-card {
    margin-top: 10px;
}

/* ============== */
/* TWO COLUMN LAYOUT */
/* ============== */

.two-col-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ============== */
/* CHARTS ROW */
/* ============== */

.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr 280px;
    gap: 16px;
    margin-top: 10px;
}

/* Chart */
.chart-card {
    display: flex;
    flex-direction: column;
    padding: 10px 6px;
    background: transparent;
    border: none;
    box-shadow: none;
}

.chart-container {
    width: 100%;
    margin: 0 auto;
    aspect-ratio: 1;
}

/* Ruling Planets Card */
.rp-card {
    min-width: 260px;
    max-width: 320px;
}

.rp-location {
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.rp-daylord {
    font-size: 0.72rem;
    color: var(--text-secondary);
    text-align: center;
    padding: 4px 0;
}

.rp-casting-title {
    margin-top: 10px;
}

.rp-casting-fields {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
}

.rp-field {
    height: 30px;
    font-size: 0.72rem;
    padding: 4px 8px;
}

.casting-place-wrapper {
    flex: 1;
    position: relative;
}

.casting-loc-dropdown {
    min-width: 200px;
    max-width: 350px;
    right: 0;
}

/* ============== */
/* TABLES - RVA V3 STYLE */
/* ============== */

.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}

.data-table thead {
    background: var(--bg-table-header);
    position: sticky;
    top: 0;
}

.data-table th {
    padding: 8px 8px;
    text-align: left;
    font-weight: 600;
    font-size: 0.7rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table td {
    padding: 7px 8px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table tbody tr:hover {
    background: var(--bg-highlight);
    transition: background 0.15s;
}

.highlight-row {
    background: var(--bg-highlight) !important;
    font-weight: 600;
}

.degree-cell {
    font-family: 'SF Mono', 'Courier New', monospace;
    font-size: 0.72rem;
    letter-spacing: 0.01em;
}

.house-num {
    font-weight: 700;
    color: var(--house-num-color);
    text-align: center;
}

.planet-cell {
    font-weight: 600;
}

.retrograde {
    color: var(--retrograde-color) !important;
}

/* KP Lord column colors (matching RVA v3) */
td.lord-sign,
th.lord-sign {
    color: #2563eb;
    font-weight: 600;
}

td.lord-star,
th.lord-star {
    color: #7c3aed;
    font-weight: 600;
}

td.lord-sub,
th.lord-sub {
    color: #ea580c;
    font-weight: 600;
}

td.lord-ss,
th.lord-ss {
    color: #db2777;
    font-weight: 600;
}

td.lord-sss,
th.lord-sss {
    color: #0d9488;
    font-weight: 600;
}

html.dark td.lord-sign,
html.dark th.lord-sign {
    color: #60a5fa;
}

html.dark td.lord-star,
html.dark th.lord-star {
    color: #a78bfa;
}

html.dark td.lord-sub,
html.dark th.lord-sub {
    color: #fb923c;
}

html.dark td.lord-ss,
html.dark th.lord-ss {
    color: #f472b6;
}

html.dark td.lord-sss,
html.dark th.lord-sss {
    color: #2dd4bf;
}

/* Lord cell hover - interactive */
td[data-planet] {
    cursor: pointer;
    border-radius: 3px;
    transition: background 0.15s, transform 0.15s;
}

td[data-planet]:hover {
    background: rgba(0, 0, 0, 0.06);
    transform: scale(1.08);
}

html.dark td[data-planet]:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Highlight matched lord cells across tables */
td[data-planet].lord-highlight {
    background: rgba(37, 99, 235, 0.12);
    box-shadow: inset 0 0 0 1.5px rgba(37, 99, 235, 0.35);
    border-radius: 3px;
}

html.dark td[data-planet].lord-highlight {
    background: rgba(96, 165, 250, 0.15);
    box-shadow: inset 0 0 0 1.5px rgba(96, 165, 250, 0.35);
}

/* Significator legend */
.sig-legend {
    font-size: 0.7rem;
    color: var(--text-secondary);
    padding: 8px 6px 0;
    line-height: 1.5;
}

.sig-list {
    font-weight: 500;
    color: var(--sig-color);
}

.rp-value {
    font-weight: 600;
    color: var(--text-primary);
}

/* ============================================ */
/* ASPECTS ANALYSIS - Header with tabs (RVA V3) */
/* ============================================ */

.aspects-header-card {
    padding: 12px 20px !important;
}

.aspects-header {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.aspects-main-title {
    border-bottom: none !important;
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
    font-size: 1.1rem !important;
    font-weight: 700 !important;
    color: var(--text-primary) !important;
    white-space: nowrap;
}

.aspects-tabs {
    display: flex;
    gap: 6px;
}

.aspects-tab {
    padding: 6px 16px;
    font-size: 0.78rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    background: var(--btn-small-bg);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-family);
    white-space: nowrap;
}

.aspects-tab:hover {
    background: var(--bg-highlight);
    color: var(--text-primary);
}

.aspects-tab.active {
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
}

.aspects-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.btn-aspects-filter {
    padding: 5px 12px;
    font-size: 0.72rem;
    font-weight: 500;
    border: 1px solid var(--retrograde-color);
    border-radius: var(--radius);
    background: transparent;
    color: var(--retrograde-color);
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-family);
    white-space: nowrap;
}

.btn-aspects-filter:hover {
    background: rgba(220, 38, 38, 0.08);
}

.btn-aspects-filter.active {
    background: var(--retrograde-color);
    color: #fff;
}

.btn-aspects-recalc {
    padding: 5px 12px;
    font-size: 0.72rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius);
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-family);
    white-space: nowrap;
}

.btn-aspects-recalc:hover {
    opacity: 0.85;
}

/* Aspects grid table cells */
.aspects-grid-table {
    table-layout: fixed;
}

.aspects-grid-table th {
    text-align: center;
    min-width: 70px;
}

.aspects-grid-table th:first-child {
    min-width: 50px;
    text-align: left;
}

.aspect-grid-cell {
    text-align: center;
    font-size: 0.7rem;
    padding: 4px 3px !important;
    vertical-align: middle;
    line-height: 1.3;
}

.aspect-red {
    color: var(--retrograde-color);
    font-weight: 600;
}

.aspect-black {
    color: var(--text-primary);
}

.aspect-deg {
    color: var(--text-muted);
    font-size: 0.6rem;
    margin-top: 1px;
}

.aspect-dash {
    color: var(--border-color);
}

/* Aspects table (Western list) */
.aspect-cell {
    font-weight: 600;
}

.aspect-hard {
    color: var(--retrograde-color);
}

.aspect-soft {
    color: var(--sig-color);
}

.aspect-applying {
    color: var(--text-primary);
    font-weight: 600;
}

.aspect-separating {
    color: var(--text-muted);
}

/* ================================== */
/* VIMSHOTTARI DASHA TREE (RVA V3)    */
/* ================================== */

.dasha-section {
    padding: 16px 20px !important;
}

.dasha-layout {
    display: flex;
    gap: 0;
    min-height: 300px;
}

.dasha-tree-wrapper {
    flex: 1;
    min-width: 0;
    border-right: 1px solid var(--border-color);
    max-height: 480px;
    overflow-y: auto;
}

.dasha-breadcrumb-wrapper {
    flex: 1;
    min-width: 0;
    padding: 16px 24px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 12px;
}

.dasha-tree {
    font-size: 0.84rem;
}

.dasha-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    cursor: default;
    transition: background 0.15s;
}

.dasha-row:hover {
    background: var(--bg-highlight);
}

.dasha-row-expanded {
    background: var(--bg-table-row-alt);
}

.dasha-row-leaf {
    background: var(--bg-highlight);
}

.dasha-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    cursor: pointer;
    flex-shrink: 0;
    user-select: none;
    background: var(--bg-card);
    transition: all 0.15s;
    line-height: 1;
}

.dasha-toggle:hover {
    background: var(--bg-highlight);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.dasha-toggle-leaf {
    opacity: 0.4;
    cursor: default;
}

.dasha-toggle-leaf:hover {
    background: var(--bg-card);
    color: var(--text-secondary);
    border-color: var(--border-color);
}

.dasha-label {
    font-weight: 500;
    white-space: nowrap;
}

/* Dasha Breadcrumb */
.dasha-bc-item {
    font-size: 0.84rem;
    font-weight: 500;
    text-align: center;
    padding: 4px 0;
}

@media (max-width: 768px) {
    .dasha-layout {
        flex-direction: column;
    }

    .dasha-tree-wrapper {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        max-height: 360px;
    }

    .dasha-breadcrumb-wrapper {
        padding: 12px;
    }
}

/* Ruling planets table */
.ruling-table td:first-child {
    color: var(--text-secondary);
    font-size: 0.78rem;
}

/* Move House Badge */
.move-house-badge {
    display: inline-block;
    padding: 2px 8px;
    background: var(--retrograde-color);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 10px;
    letter-spacing: 0.03em;
}

/* Footer */
.app-footer {
    background: var(--bg-footer);
    color: var(--text-muted);
    text-align: center;
    padding: 12px;
    font-size: 0.7rem;
    border-top: 1px solid var(--border-color);
}

/* ============== */
/* RESPONSIVE     */
/* ============== */

/* Prevent input overflow in grid */
.input-field,
select.input-field {
    min-width: 0;
    max-width: 100%;
}

@media (max-width: 768px) {
    .header-container {
        height: 56px;
        padding: 0 12px;
    }

    .header-left {
        gap: 12px;
    }

    .app-subtitle {
        display: none;
    }

    .header-right {
        gap: 8px;
    }

    .status-ok,
    .status-error {
        font-size: 0.68rem;
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .app-main {
        padding: 12px 10px;
    }

    .input-card {
        padding: 12px;
    }

    .form-row-primary {
        flex-wrap: wrap;
        gap: 8px;
    }

    .form-row-primary .input-field {
        height: 40px;
    }

    .kp-inline .input-field {
        width: 80px;
    }

    .location-inline {
        flex-basis: 100%;
    }

    .btn-primary {
        width: 100%;
        height: 42px;
    }

    .btn-small {
        height: 40px;
    }

    .settings-panel {
        padding: 16px;
    }

    .settings-grid-3 {
        grid-template-columns: 1fr 1fr;
    }

    .results-section {
        gap: 12px;
    }

    .charts-row {
        grid-template-columns: 1fr;
        gap: 12px;
        margin-left: -10px;
        margin-right: -10px;
    }

    .chart-card {
        padding: 6px 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
        box-shadow: none;
    }

    .chart-card .card-title {
        padding: 0 10px 6px;
    }

    .chart-container {
        max-width: 100%;
        margin: 0;
    }

    .rp-card {
        max-width: 100%;
    }

    .two-col-layout {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .result-card {
        padding: 12px 14px;
    }

    .data-table {
        font-size: 0.73rem;
    }

    .data-table th {
        padding: 8px 6px;
        font-size: 0.65rem;
    }

    .data-table td {
        padding: 7px 6px;
    }

    .degree-cell {
        font-size: 0.68rem;
    }

    .chart-container {
        max-width: 100%;
    }

    .card-title {
        font-size: 0.78rem;
        margin-bottom: 8px;
    }

    .section-header {
        font-size: 0.95rem;
        padding: 12px 14px;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    }

    .section-header+.two-col-layout {
        margin-top: -7px;
    }

    /* Panchang responsive */
    .panchang-item {
        padding: 10px 12px;
    }

    /* Aspects responsive */
    .aspects-header {
        gap: 8px;
    }

    .aspects-tabs {
        flex-wrap: wrap;
        gap: 4px;
    }

    .aspects-tab {
        padding: 5px 12px;
        font-size: 0.7rem;
    }

    .aspects-actions {
        margin-left: 0;
    }

    .aspects-grid-table th {
        min-width: 55px;
        font-size: 0.58rem;
    }

    .aspect-grid-cell {
        font-size: 0.62rem;
    }

    .aspect-deg {
        font-size: 0.52rem;
    }
}

@media (max-width: 480px) {
    .header-container {
        height: 48px;
        padding: 0 8px;
    }

    .app-title {
        font-size: 1rem;
    }

    .status-ok,
    .status-error {
        max-width: 90px;
        font-size: 0.62rem;
    }

    .app-main {
        padding: 8px;
    }

    .input-card {
        padding: 10px;
    }

    .form-row-primary {
        gap: 6px;
    }

    .kp-inline .input-field {
        width: 70px;
    }

    .kp-preview {
        font-size: 0.72rem;
        padding: 4px 10px;
        gap: 4px;
    }

    .settings-panel {
        padding: 12px;
    }

    .settings-grid,
    .settings-grid-3 {
        grid-template-columns: 1fr;
    }

    .settings-input {
        height: 38px;
        font-size: 0.8rem;
    }

    .results-section {
        gap: 10px;
    }

    .result-card {
        padding: 12px;
        border-radius: 10px;
    }

    .data-table {
        font-size: 0.72rem;
    }

    .data-table th {
        padding: 8px 6px;
        font-size: 0.64rem;
    }

    .data-table td {
        padding: 7px 6px;
    }

    .degree-cell {
        font-size: 0.66rem;
    }

    .chart-card {
        padding: 4px 0;
        border-radius: 0;
        border: none;
        box-shadow: none;
        margin-top: 0;
    }

    .chart-card .card-title {
        padding: 0 8px 6px;
        font-size: 0.75rem;
    }

    .chart-container {
        max-width: 100%;
        width: 100%;
        margin: 0;
    }

    .charts-row {
        grid-template-columns: 1fr;
        gap: 8px;
        margin-left: -8px;
        margin-right: -8px;
    }

    .rp-card {
        max-width: 100%;
    }

    .two-col-layout {
        gap: 10px;
    }

    .card-title {
        font-size: 0.72rem;
        margin-bottom: 8px;
    }

    .section-header {
        font-size: 0.88rem;
        padding: 10px 12px;
        border-radius: 10px 10px 0 0;
    }

    .section-header+.two-col-layout {
        margin-top: -5px;
    }

    .section-header+.two-col-layout>.result-card {
        border-radius: 10px;
        border-top-left-radius: 0;
        border-top-right-radius: 0;
    }

    .btn-primary {
        font-size: 0.85rem;
    }

    .sig-list {
        font-size: 0.62rem;
    }

    .app-footer {
        font-size: 0.6rem;
        padding: 8px;
    }

    /* Panchang responsive - small */
    .panchang-bar {
        border-radius: 10px;
        font-size: 0.75rem;
    }

    .panchang-item {
        padding: 8px 10px;
        gap: 4px;
    }

    .pan-label {
        font-size: 0.65rem;
    }

    .pan-value {
        font-size: 0.72rem;
    }

    /* Aspects responsive - small screens */
    .aspects-header-card {
        padding: 10px 12px !important;
    }

    .aspects-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .aspects-main-title {
        font-size: 0.88rem !important;
    }

    .aspects-tabs {
        width: 100%;
    }

    .aspects-tab {
        flex: 1;
        text-align: center;
        padding: 6px 8px;
        font-size: 0.68rem;
    }

    .aspects-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .aspects-grid-table th {
        min-width: 46px;
        font-size: 0.52rem;
        padding: 4px 2px;
    }

    .aspect-grid-cell {
        font-size: 0.58rem;
        padding: 2px 1px !important;
    }

    .aspect-deg {
        font-size: 0.5rem;
    }

    /* Dasha responsive - small screens */
    .dasha-tree {
        font-size: 0.76rem;
    }

    .dasha-bc-item {
        font-size: 0.76rem;
    }

    .dasha-row {
        padding: 6px 8px;
    }

    .dasha-toggle {
        width: 20px;
        height: 20px;
        font-size: 0.78rem;
    }
}

/* ============== */
/* CHART TOOLTIP  */
/* ============== */

.chart-tooltip {
    position: fixed;
    z-index: 10000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    font-family: var(--font-family);
    line-height: 1.4;
    white-space: nowrap;
    background: #1f2937;
    color: #ffffff;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.chart-tooltip.visible {
    opacity: 1;
}

html.dark .chart-tooltip {
    background: #f3f4f6;
    color: #111827;
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ==================== PWA INSTALL BANNER ==================== */

.pwa-install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: 12px 16px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    animation: pwaSlideUp 0.3s ease;
}

@keyframes pwaSlideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

.pwa-install-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.pwa-install-text {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}

.pwa-install-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.pwa-install-btn {
    height: 36px;
    padding: 0 20px;
    font-size: 0.8rem;
    cursor: pointer;
}

.pwa-dismiss-btn {
    height: 36px;
    padding: 0 12px;
    font-size: 0.75rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.pwa-dismiss-btn:hover {
    background: var(--bg-primary);
    border-color: var(--text-muted);
}

@media (max-width: 480px) {
    .pwa-install-content {
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }

    .pwa-install-text {
        font-size: 0.78rem;
    }
}