:root {
    --primary: #ff7a18;
    --primary-hover: #ff8f3d;
    --success: #4ade80;
    --danger: #f87171;
    --bg-gradient: radial-gradient(circle at top, #1a1f2b 0%, #050709 60%);
    --card-bg: #0f1218;
    --panel-bg: #141822;
    --text-main: #f7f7fb;
    --text-muted: #9399ad;
    --shadow: 0 25px 60px -30px rgba(0, 0, 0, 0.9);
    --radius: 0;
}

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

html {
    background: var(--bg-gradient);
    min-height: 100%;
    min-width: 100%;
    background-color: #050709;
}

body {
    font-family: 'Nunito', sans-serif;
    background: var(--bg-gradient);
    color: var(--text-main);
    background-color: #050709;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: env(safe-area-inset-top, 12px) env(safe-area-inset-right, 12px) env(safe-area-inset-bottom, 20px) env(safe-area-inset-left, 12px);
    line-height: 1.5;
    font-size: 16px;
}

.app-container {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 8px;
    display: flex;
    flex-direction: column;
}

main {
    width: 100%;
}

.view {
    width: 100%;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.logo {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 0.15em;
}

.header-menu-wrapper {
    position: relative;
}

.icon-button {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.25);
    padding: 0.4rem;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 36px;
    width: 44px;
}

.icon-button .hamburger {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 100%;
    height: 100%;
}

.icon-button .hamburger span {
    display: block;
    height: 3px;
    background: var(--text-main);
    border-radius: 2px;
}

.menu-panel {
    position: absolute;
    top: 120%;
    right: 0;
    background: var(--panel-bg);
    border: 1px solid rgba(255,255,255,0.08);
    min-width: 160px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.menu-item {
    background: transparent;
    border: none;
    color: var(--text-main);
    text-align: left;
    padding: 0.85rem 1.25rem;
    font-size: 1.05rem;
    cursor: pointer;
    font-family: 'Fredoka', sans-serif;
    letter-spacing: 0.08em;
}

.menu-item:hover {
    background: rgba(255,255,255,0.08);
}

.menu-item.active {
    background: rgba(255,255,255,0.12);
    color: var(--primary);
}

.hidden {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-family: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.2s;
    font-size: 1rem;
}

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

.btn-primary {
    background-color: var(--primary);
    color: black;
    box-shadow: 0 4px 18px rgba(255, 122, 24, 0.35);
}

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

.btn-secondary {
    background-color: rgba(255, 255, 255, 0.15);
    color: var(--text-main);
}

.btn-danger {
    background-color: var(--danger);
    color: #140d0d;
}

.btn-success {
    background-color: var(--success);
    color: #041007;
}

.btn-block {
    width: 100%;
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    border: 1px solid rgba(255,255,255,0.05);
}

.login-card {
    max-width: 400px;
    margin: 4rem auto;
    text-align: center;
}

.login-card h1 {
    font-family: 'Fredoka', sans-serif;
    color: var(--primary);
    margin-bottom: 0.5rem;
    letter-spacing: 0.04em;
}

.subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.9rem;
}

.form-group input,
.compact-input,
.form-row input,
.note-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    font-size: 16px;
    transition: border-color 0.2s;
    font-family: inherit;
    background: rgba(255,255,255,0.03);
    color: var(--text-main);
}

.form-group input:focus,
.compact-input:focus,
.form-row input:focus,
.note-input:focus {
    outline: none;
    border-color: var(--primary);
}

.error-message {
    color: var(--danger);
    background: rgba(248, 113, 113, 0.15);
    padding: 0.75rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    color: var(--text-main);
}

.balance-card {
    background: var(--panel-bg);
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    text-align: right;
    border: 1px solid rgba(255,255,255,0.05);
}

.balance-card.full-width {
    width: 100%;
    text-align: left;
    margin-bottom: 1.5rem;
}

.center-balance {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

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

.account-label {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 600;
}

.balance-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-weight: 700;
}

.balance-amount {
    display: block;
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--primary);
    font-family: 'Fredoka', sans-serif;
}

.balance-sats {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.balance-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.1rem;
}

.table-card {
    padding: 0;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.05);
}

.transaction-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.transaction-table th {
    background: rgba(255,255,255,0.03);
    padding: 0.85rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.transaction-table td {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.transaction-table tr:last-child td {
    border-bottom: none;
}

.col-date {
    width: 24%;
}

.col-note {
    width: 46%;
}

.col-amount {
    width: 20%;
}

.amount-credit {
    color: var(--success);
    font-weight: 700;
}

.amount-debit {
    color: var(--text-main);
    font-weight: 600;
}

.amount-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.15rem;
}

.amount-sats {
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

.empty-state {
    padding: 3rem;
    text-align: center;
    color: var(--text-muted);
}

.children-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.admin-child-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    border: 1px solid rgba(255,255,255,0.05);
}

.sats-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
    width: 100%;
}

.sats-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.converter-text {
    margin-top: 0.25rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.price-banner {
    font-size: 0.85rem;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.sats-header h2 {
    margin: 0;
    font-family: 'Fredoka', sans-serif;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}


.converter-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
    align-items: center;
}

.converter-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.converter-field label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.converter-field input {
    font-size: 16px;
}

@media (min-width: 640px) {
    .converter-grid {
        grid-template-columns: minmax(0, 0.8fr) minmax(0, 1fr);
    }
}

.admin-child-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 0.25rem 0;
}

.admin-child-name {
    font-family: 'Fredoka', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.admin-child-balance {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}

.admin-controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.admin-actions,
.control-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.btn-compact {
    width: 42px;
    height: 42px;
    padding: 0;
    border-radius: 6px;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.detail-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5,7,9,0.95);
    z-index: 1000;
    overflow-y: auto;
    padding: calc(env(safe-area-inset-top, 12px) + 1rem) 1rem 1rem;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.drawer-header {
    display: flex;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.btn-icon-text {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.2);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    color: var(--text-main);
    font-weight: 600;
    cursor: pointer;
}

.editor-panel {
    margin-bottom: 1rem;
    background: var(--panel-bg);
    padding: 1rem;
    border: 1px solid rgba(255,255,255,0.05);
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
}

.form-row label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
}

.editor-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.actions-column {
    width: 80px;
}

.actions-cell {
    text-align: right;
    white-space: nowrap;
}

.action-button {
    background: none;
    border: none;
    color: var(--primary);
    font-weight: 600;
    margin-left: 0.5rem;
    cursor: pointer;
}

.action-button.delete {
    color: var(--danger);
}

.detail-balance-card {
    background: var(--panel-bg);
    padding: 1.5rem;
    border-radius: var(--radius);
    text-align: center;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid rgba(255,255,255,0.05);
}

.detail-balance-card .label {
    display: block;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 0.25rem;
    letter-spacing: 0.2em;
}

.detail-balance-card .amount {
    display: block;
    font-size: 2.3rem;
    font-weight: 800;
    color: var(--primary);
    font-family: 'Fredoka', sans-serif;
}

@media (min-width: 768px) {
    .children-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }
    
    .detail-drawer {
        max-width: 640px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: 0;
        top: 5%;
        height: 90%;
        box-shadow: 0 -10px 40px rgba(0,0,0,0.4);
    }

    @keyframes slideUp {
        from { transform: translate(-50%, 100%); }
        to { transform: translate(-50%, 0); }
    }
}

#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 100;
}

.toast {
    background: rgba(0,0,0,0.85);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 4px;
    margin-top: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    animation: slideIn 0.3s ease-out;
}

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

@media (max-width: 640px) {
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
}
