/* ==========================================================================
   Gruvbox Dark Theme - Base Styles
   ========================================================================== */

:root {
    /* Gruvbox Dark Palette */
    --bg-hard: #1d2021;
    --bg: #282828;
    --bg-soft: #32302f;
    --bg1: #3c3836;
    --bg2: #504945;
    --bg3: #665c54;
    --bg4: #7c6f64;

    --fg: #ebdbb2;
    --fg-muted: #a89984;
    --fg-dim: #928374;

    --red: #fb4934;
    --red-dim: #cc241d;
    --green: #b8bb26;
    --green-dim: #98971a;
    --yellow: #fabd2f;
    --yellow-dim: #d79921;
    --blue: #83a598;
    --blue-dim: #458588;
    --purple: #d3869b;
    --purple-dim: #b16286;
    --aqua: #8ec07c;
    --aqua-dim: #689d6a;
    --orange: #fe8019;
    --orange-dim: #d65d0e;

    /* Semantic Colors */
    --color-primary: var(--orange);
    --color-primary-hover: var(--orange-dim);
    --color-success: var(--green);
    --color-success-dim: var(--green-dim);
    --color-warning: var(--yellow);
    --color-warning-dim: var(--yellow-dim);
    --color-error: var(--red);
    --color-error-dim: var(--red-dim);
    --color-info: var(--blue);
    --color-info-dim: var(--blue-dim);

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-size-base: 16px;
    --font-size-sm: 14px;
    --font-size-xs: 12px;
    --font-size-lg: 18px;
    --font-size-xl: 20px;
    --font-size-h1: 28px;
    --font-size-h2: 24px;
    --font-size-h3: 20px;
    --font-size-button: 15px;

    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;

    --line-height-base: 1.5;
    --line-height-heading: 1.3;

    /* Spacing (8px grid) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.3);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
}

/* ==========================================================================
   Reset & Base
   ========================================================================== */

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

html {
    font-size: var(--font-size-base);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-normal);
    line-height: var(--line-height-base);
    background-color: var(--bg-hard);
    color: var(--fg);
}

/* ==========================================================================
   Typography
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
    margin: 0 0 var(--space-4) 0;
    font-weight: var(--font-weight-semibold);
    line-height: var(--line-height-heading);
    color: var(--fg);
}

h1 { font-size: var(--font-size-h1); }
h2 { font-size: var(--font-size-h2); }
h3 { font-size: var(--font-size-h3); }
h4 { font-size: var(--font-size-lg); }

p {
    margin: 0 0 var(--space-4) 0;
}

a {
    color: var(--blue);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--aqua);
}

/* ==========================================================================
   Container
   ========================================================================== */

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: var(--space-6);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 10px 16px;
    font-family: var(--font-family);
    font-size: var(--font-size-button);
    font-weight: var(--font-weight-medium);
    line-height: 1;
    text-decoration: none;
    border: 1px solid var(--bg2);
    border-radius: var(--radius-md);
    background-color: var(--bg1);
    color: var(--fg);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.button:hover {
    background-color: var(--bg2);
    border-color: var(--bg3);
    color: var(--fg);
}

.button:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.button i {
    width: 16px;
    height: 16px;
}

/* Primary Button */
.button-primary {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--bg-hard);
}

.button-primary:hover {
    background-color: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
    color: var(--bg-hard);
}

/* Secondary Button (outlined) */
.button-secondary {
    background-color: transparent;
    border-color: var(--bg3);
    color: var(--fg);
}

.button-secondary:hover {
    background-color: var(--bg1);
    border-color: var(--bg4);
}

/* Danger Button */
.button-danger {
    background-color: var(--color-error);
    border-color: var(--color-error);
    color: var(--bg-hard);
}

.button-danger:hover {
    background-color: var(--color-error-dim);
    border-color: var(--color-error-dim);
    color: var(--bg-hard);
}

/* Success Button */
.button-success {
    background-color: var(--color-success);
    border-color: var(--color-success);
    color: var(--bg-hard);
}

.button-success:hover {
    background-color: var(--color-success-dim);
    border-color: var(--color-success-dim);
    color: var(--bg-hard);
}

/* Small Button */
.button-small {
    padding: 6px 10px;
    font-size: var(--font-size-sm);
}

.button-small i {
    width: 14px;
    height: 14px;
}

/* Icon-only button (for tables, trees) */
.button-icon {
    padding: 6px;
}
.button-icon i {
    width: 14px;
    height: 14px;
}

/* Compact icon button (for dense trees) */
.button-icon-sm {
    padding: 4px;
}
.button-icon-sm i {
    width: 12px;
    height: 12px;
}

/* ==========================================================================
   Forms
   ========================================================================== */

label {
    display: block;
    margin-bottom: var(--space-2);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    color: var(--fg);
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="search"],
select,
textarea {
    display: block;
    width: 100%;
    padding: 10px 14px;
    font-family: var(--font-family);
    font-size: 15px;
    line-height: var(--line-height-base);
    color: var(--fg);
    background-color: var(--bg-soft);
    border: 1px solid var(--bg2);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input::placeholder,
textarea::placeholder {
    color: var(--fg-dim);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(254, 128, 25, 0.2);
}

input:disabled,
select:disabled,
textarea:disabled {
    background-color: var(--bg-hard);
    color: var(--fg-dim);
    border-color: var(--bg2);
    cursor: not-allowed;
    opacity: 0.6;
}

input:disabled::placeholder {
    color: var(--bg3);
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a89984' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-4) center;
    padding-right: var(--space-10);
}

/* Error state */
.error-input {
    border-color: var(--color-error) !important;
}

.error-message {
    color: var(--color-error);
    font-size: var(--font-size-sm);
    margin-top: var(--space-2);
}

.has-error label {
    color: var(--color-error);
}

/* Checkbox */
input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--color-primary);
    cursor: pointer;
}

/* ==========================================================================
   Navbar
   ========================================================================== */

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background-color: var(--bg);
    border-bottom: 1px solid var(--bg1);
}

.navbar .logo {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    color: var(--fg);
}

.navbar-logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    text-decoration: none;
}

.navbar-logo .logo-icon {
    width: 32px;
    height: 32px;
}

.navbar-logo .logo-text {
    font-size: 18px;
    font-weight: var(--font-weight-bold);
    color: var(--fg);
}

.navbar-links {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.navbar .nav-links {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.navbar .nav-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    font-size: 14px;
    color: var(--fg-muted);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.navbar .nav-link:hover {
    background-color: var(--bg1);
    color: var(--fg);
}

.navbar .nav-link i {
    width: 16px;
    height: 16px;
}

.navbar .logout-button {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    font-family: var(--font-family);
    font-size: 14px;
    font-weight: var(--font-weight-medium);
    color: var(--color-error);
    background: transparent;
    border: 1px solid var(--color-error);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.navbar .logout-button:hover {
    background-color: var(--color-error);
    color: var(--bg-hard);
}

.navbar .logout-button i {
    width: 16px;
    height: 16px;
}

/* ==========================================================================
   Alerts
   ========================================================================== */

.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    margin-bottom: var(--space-5);
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
}

.alert i {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 2px;
}

.alert-success {
    background-color: rgba(184, 187, 38, 0.15);
    border: 1px solid var(--color-success);
    color: var(--color-success);
}

.alert-error {
    background-color: rgba(251, 73, 52, 0.15);
    border: 1px solid var(--color-error);
    color: var(--color-error);
}

.alert-warning {
    background-color: rgba(250, 189, 47, 0.15);
    border: 1px solid var(--color-warning);
    color: var(--color-warning);
}

.alert-info {
    background-color: rgba(131, 165, 152, 0.15);
    border: 1px solid var(--color-info);
    color: var(--color-info);
}

/* ==========================================================================
   Toast
   ========================================================================== */

.toast-container {
    position: fixed;
    top: var(--space-6);
    right: var(--space-6);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    min-width: 300px;
    max-width: 450px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease-out;
}

.toast i {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.toast-message {
    flex: 1;
    font-size: var(--font-size-base);
}

.toast-close {
    flex-shrink: 0;
    padding: 0;
    background: none;
    border: none;
    color: inherit;
    opacity: 0.7;
    cursor: pointer;
    transition: opacity var(--transition-fast);
}

.toast-close:hover {
    opacity: 1;
}

.toast-close i {
    width: 18px;
    height: 18px;
}

.toast-success {
    background-color: var(--bg);
    border: 1px solid var(--color-success);
    color: var(--color-success);
}

.toast-error {
    background-color: var(--bg);
    border: 1px solid var(--color-error);
    color: var(--color-error);
}

.toast-warning {
    background-color: var(--bg);
    border: 1px solid var(--color-warning);
    color: var(--color-warning);
}

.toast-info {
    background-color: var(--bg);
    border: 1px solid var(--color-info);
    color: var(--color-info);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateX(20px);
    }
}

/* ==========================================================================
   Loading States
   ========================================================================== */

.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-block;
}

.htmx-request button[type="submit"] {
    pointer-events: none;
    opacity: 0.7;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

.spinner-small {
    width: 14px;
    height: 14px;
    border-width: 1.5px;
}

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

/* ==========================================================================
   Utilities
   ========================================================================== */

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

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

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

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

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

.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

/* ==========================================================================
   Login Page Specific
   ========================================================================== */

.login-container {
    max-width: 400px;
    margin: var(--space-12) auto;
    padding: var(--space-5);
}

.login-form {
    background-color: var(--bg);
    padding: var(--space-8);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.login-form h2 {
    text-align: center;
    margin-bottom: var(--space-6);
}

.login-form .form-group {
    margin-bottom: var(--space-5);
}

.login-form .button-primary {
    width: 100%;
    padding: var(--space-4);
    margin-top: var(--space-4);
}

.login-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.login-logo {
    width: 64px;
    height: 64px;
}

/* ==========================================================================
   Modal Dialog
   ========================================================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: var(--space-4);
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background-color: var(--bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 450px;
    width: 100%;
    animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

.modal-header h3 {
    margin: 0;
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--fg);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--fg-muted);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color var(--transition-fast);
}

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

.modal-body {
    padding: var(--space-6);
}

.modal-body p {
    margin: 0;
    color: var(--fg-muted);
    line-height: var(--line-height-base);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--bg1);
}

/* ==========================================================================
   Unit Type Badges
   ========================================================================== */

.unit-type {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.unit-type-currency       { background: rgba(184, 187, 38, 0.15);  color: var(--green); }
.unit-type-stock          { background: rgba(131, 165, 152, 0.15); color: var(--blue); }
.unit-type-crypto         { background: rgba(254, 128, 25, 0.15);  color: var(--orange); }
.unit-type-precious_metal { background: rgba(250, 189, 47, 0.15);  color: var(--yellow); }
.unit-type-realty         { background: rgba(211, 134, 155, 0.15); color: var(--purple); }
.unit-type-vehicle        { background: rgba(142, 192, 124, 0.15); color: var(--aqua); }
.unit-type-art            { background: rgba(251, 73, 52, 0.15);   color: var(--red); }
.unit-type-other          { background: rgba(168, 153, 132, 0.15); color: var(--fg-muted); }

/* ==========================================================================
   Units Tables (shared between user and admin pages)
   ========================================================================== */

.units-section {
    margin-bottom: var(--space-8);
}
.units-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-4);
}
.units-section-header h2 {
    margin: 0;
    font-size: var(--font-size-h3);
    color: var(--fg);
}
.units-table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--bg);
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--bg1);
}
.units-table th {
    background-color: var(--bg-soft);
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-sm);
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 10px 16px;
    text-align: left;
}
.units-table td {
    padding: 8px 16px;
    border-bottom: 1px solid var(--bg1);
}
.units-table tr:last-child td {
    border-bottom: none;
}
.units-table tbody tr:hover {
    background-color: var(--bg-soft);
}
.unit-code {
    font-family: monospace;
    font-weight: 600;
    color: var(--aqua);
}
.rate-value {
    font-family: monospace;
    color: var(--fg);
    text-align: right;
}
.rate-na {
    color: var(--fg-dim);
    font-style: italic;
    text-align: right;
}
.rate-clickable {
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 3px;
}
.rate-clickable:hover {
    color: var(--yellow);
}
.rate-set-link {
    cursor: pointer;
    color: var(--blue);
    font-size: var(--font-size-sm);
}
.rate-set-link:hover {
    text-decoration: underline;
}
.rate-edit-form {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: flex-end;
}
.rate-input {
    width: 120px;
    padding: 4px 8px;
    font-family: monospace;
    font-size: var(--font-size-sm);
    text-align: right;
    background: var(--bg);
    color: var(--fg);
    border: 1px solid var(--bg2);
    border-radius: var(--radius-sm);
}
.rate-input:focus {
    outline: none;
    border-color: var(--yellow);
}
.units-table .col-rate,
.units-table .col-actions {
    text-align: right;
}
.units-table .col-actions {
    width: auto;
    white-space: nowrap;
}
.row-actions {
    display: inline-flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s;
}
.units-table tbody tr:hover .row-actions {
    opacity: 1;
}
.empty-state {
    text-align: center;
    padding: var(--space-12) var(--space-6);
    color: var(--fg-dim);
}
.empty-state i {
    width: 48px;
    height: 48px;
    margin-bottom: var(--space-4);
    color: var(--fg-dim);
}
.empty-state p {
    margin-bottom: var(--space-4);
}

/* ==========================================================================
   Counterparty Tree
   ========================================================================== */

.tree-indent {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.tree-icon {
    width: 16px;
    height: 16px;
    color: var(--fg-dim);
    flex-shrink: 0;
}

/* ==========================================================================
   Filter Tabs
   ========================================================================== */

.filter-tabs {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}
.filter-tab {
    padding: 6px 16px;
    border: 1px solid var(--bg2);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--fg-muted);
    cursor: pointer;
    font-size: var(--font-size-sm);
    transition: var(--transition-fast);
}
.filter-tab:hover {
    background: var(--bg1);
    color: var(--fg);
}
.filter-tab.active {
    background: var(--bg2);
    color: var(--fg);
    border-color: var(--fg-dim);
}

/* ==========================================================================
   Counterparty Create Form
   ========================================================================== */

.counterparty-create-form {
    margin-top: var(--space-6);
    padding: var(--space-4);
    background: var(--bg-soft);
    border-radius: var(--radius-md);
    border: 1px solid var(--bg1);
}
.counterparty-create-form h3 {
    margin: 0 0 var(--space-3) 0;
    font-size: var(--font-size-base);
    color: var(--fg-muted);
}
.inline-create-form .form-row {
    display: flex;
    gap: var(--space-3);
    align-items: flex-start;
}
.inline-create-form .form-group {
    flex: 1;
    margin-bottom: 0;
}
.inline-create-form select,
.inline-create-form input[type="text"] {
    width: 100%;
}

/* Inline edit inputs in table rows */
.inline-edit-input,
.inline-edit-select {
    width: 100%;
    padding: 6px 10px;
    background: var(--bg);
    border: 1px solid var(--bg2);
    border-radius: var(--radius-sm);
    color: var(--fg);
    font-size: var(--font-size-sm);
}
.inline-edit-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a89984' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 28px;
}
.inline-edit-input:focus,
.inline-edit-select:focus {
    border-color: var(--blue);
    outline: none;
}

/* ==========================================================================
   Tree Component (shared between locations, counterparties)
   ========================================================================== */

.tree-item {
    margin-bottom: 2px;
}
.tree-item-content {
    display: flex;
    align-items: center;
    border-radius: 4px;
    transition: background-color 0.15s;
}
.tree-item-content:hover {
    background-color: var(--bg1);
}
.tree-item-content.selected {
    background-color: var(--bg2);
}
.tree-row-content {
    flex: 1;
    display: flex;
    align-items: center;
    padding: 6px 8px;
    cursor: pointer;
    min-width: 0;
}
.tree-actions {
    display: flex;
    gap: 2px;
    margin-left: auto;
    padding-right: 4px;
    opacity: 0;
    transition: opacity 0.15s;
    align-items: center;
}
.tree-item-content:hover .tree-actions {
    opacity: 1;
}
.tree-toggle, .tree-leaf {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 6px;
    color: var(--fg-dim);
}
.tree-toggle {
    cursor: pointer;
}
.tree-toggle:hover {
    color: var(--fg);
}
.tree-leaf {
    cursor: default;
    opacity: 0.5;
}
.tree-name {
    flex: 1;
    font-size: 14px;
}
.tree-children {
    margin-left: 0;
}

/* Tree Action Icons (transparent, no background) */
.tree-action-icon {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--fg-dim);
    transition: color 150ms ease;
    display: inline-flex;
    align-items: center;
    line-height: 1;
    text-decoration: none;
}
.tree-action-icon:hover {
    color: var(--green);
}
.tree-action-icon.danger:hover,
.tree-action-icon.cancel:hover {
    color: var(--orange);
}
.tree-action-icon.confirm:hover {
    color: var(--green);
}
.tree-action-icon i {
    width: 14px;
    height: 14px;
}

/* Inline place creation form */
.inline-place-form {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}
.inline-place-input {
    flex: 1;
    height: 28px;
    padding: 4px 8px;
    font-size: 14px;
}
.add-root-place-btn {
    display: flex;
    align-items: center;
    margin-top: 8px;
    padding: 6px 8px;
}

/* Ownership actions in table */
.ownership-actions {
    white-space: nowrap;
    text-align: right;
    opacity: 0;
    transition: opacity 0.15s;
}
.ownerships-table tr:hover .ownership-actions {
    opacity: 1;
}

/* Ownership add button */
.ownership-add-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    padding: 8px;
    background: none;
    border: none;
    color: var(--fg-dim);
    cursor: pointer;
    font-size: 14px;
    transition: color var(--transition-fast);
}
.ownership-add-btn:hover {
    color: var(--fg);
}
.ownership-add-btn i {
    width: 16px;
    height: 16px;
}

/* Ownership inline add row */
.ownership-add-row td {
    padding: 6px 8px !important;
}
.ownership-add-row .inline-edit-input {
    height: 32px;
}
.ownership-add-actions {
    display: flex;
    gap: 2px;
    align-items: center;
    justify-content: flex-end;
}

/* Searchable Dropdown */
.searchable-dropdown {
    position: relative;
}
.searchable-dropdown .dropdown-input {
    width: 100%;
}
.dropdown-list {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    min-width: 200px;
    background: var(--bg);
    border: 1px solid var(--bg2);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    max-height: 200px;
    overflow-y: auto;
    z-index: 500;
    margin-top: 2px;
}
.dropdown-list.open {
    display: block;
}
.dropdown-item {
    padding: 8px 10px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color var(--transition-fast);
}
.dropdown-item:hover,
.dropdown-item.highlighted {
    background-color: var(--bg1);
}
.dropdown-item.selected {
    background-color: var(--bg2);
    color: var(--fg);
}
.dropdown-group-label {
    padding: 6px 10px;
    font-size: 12px;
    color: var(--fg-dim);
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ==========================================================================
   Split-View Panels (shared between locations, counterparties)
   ========================================================================== */

.ownerships-panel {
    height: 100%;
}
.ownerships-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--bg2);
}
.ownerships-header h3 {
    margin: 0;
    font-size: 18px;
}
.ownerships-count {
    color: var(--fg-dim);
    font-size: 14px;
}
.ownerships-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--fg-dim);
}
.ownerships-empty .empty-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}
.ownerships-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--fg-dim);
}
.ownerships-placeholder .placeholder-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

/* ==========================================================================
   Transaction type pills (shared between dashboard, locations)
   ========================================================================== */

.tx-type-pill {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}
.tx-type-pill.tx-type-income {
    background: color-mix(in srgb, var(--color-success) 15%, transparent);
    color: var(--color-success);
}
.tx-type-pill.tx-type-expense {
    background: color-mix(in srgb, var(--color-error) 15%, transparent);
    color: var(--color-error);
}
.tx-type-pill.tx-type-transfer {
    background: color-mix(in srgb, var(--color-info) 15%, transparent);
    color: var(--color-info);
}
.tx-type-pill.tx-type-dividend {
    background: color-mix(in srgb, var(--color-warning) 15%, transparent);
    color: var(--color-warning);
}
.tx-type-pill.tx-type-planned {
    background: color-mix(in srgb, var(--fg3) 15%, transparent);
    color: var(--fg3);
    font-style: italic;
}
.tx-planned {
    opacity: 0.65;
    font-style: italic;
}

/* ==========================================================================
   Ownership transactions accordion
   ========================================================================== */

.ownership-row-clickable {
    cursor: pointer;
}
.ownership-row-clickable:hover {
    background: var(--bg1);
}
.ownership-row-active {
    background: var(--bg1);
}

.ownership-chevron {
    display: inline-flex;
    align-items: center;
    margin-right: 4px;
    transition: transform 0.2s ease;
}
.ownership-chevron i {
    width: 14px;
    height: 14px;
}
.ownership-chevron.expanded {
    transform: rotate(90deg);
}

.ownership-tx-panel {
    border: none;
}
.ownership-tx-panel > td {
    padding: 0 !important;
    border: none;
}
.ownership-tx-wrapper {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.3s ease-in-out;
}
.ownership-tx-panel.expanded .ownership-tx-wrapper {
    grid-template-rows: 1fr;
}
.ownership-tx-content {
    overflow: hidden;
    min-height: 0;
}

.ownership-tx-list {
    display: grid;
    grid-template-columns: auto auto 1fr auto auto auto;
    gap: 0;
    font-size: 13px;
    margin: 4px 0;
    background: var(--bg);
}
.otx-row {
    display: contents;
}
.otx-row > div {
    padding: 4px 6px;
    border-bottom: 1px solid color-mix(in srgb, var(--bg2) 50%, transparent);
    white-space: nowrap;
}
.otx-date {
    color: var(--fg-muted);
}
.otx-type {
}
.otx-direction {
    min-width: 0;
    color: var(--fg);
    overflow: hidden;
    text-overflow: ellipsis;
}
.otx-balance-before,
.otx-balance-after {
    text-align: right;
    font-family: var(--font-mono);
    color: var(--fg-muted);
}
.otx-change {
    text-align: right;
    font-family: var(--font-mono);
    font-weight: 500;
}
.otx-change-positive { color: var(--color-success); }
.otx-change-negative { color: var(--color-error); }
.otx-change-zero { color: var(--fg-dim); }

.ownership-tx-pagination {
    display: flex;
    gap: 4px;
    justify-content: center;
    padding: 8px 0;
}
.ownership-tx-pagination a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 6px;
    border-radius: 4px;
    font-size: 13px;
    color: var(--fg-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.ownership-tx-pagination a:hover {
    background: var(--bg2);
    color: var(--fg);
}
.ownership-tx-pagination a.active {
    background: var(--color-primary);
    color: var(--bg);
}
.ownership-tx-pagination a.disabled {
    opacity: 0.3;
    pointer-events: none;
}

.ownership-tx-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 0;
    color: var(--fg-dim);
    font-size: 14px;
}
.ownership-tx-empty-icon {
    width: 32px;
    height: 32px;
    margin-bottom: 8px;
    opacity: 0.4;
}
