:root {
    --bg-deep: #020617;
    --bg-elevated: #0f172a;
    --bg-card: #111827;
    --bg-input: #1e293b;
    --fg-primary: #f8fafc;
    --fg-secondary: #cbd5e1;
    --fg-muted: #94a3b8;
    --accent-cyan: #06b6d4;
    --accent-cyan-glow: rgba(6, 182, 212, 0.25);
    --accent-emerald: #10b981;
    --accent-emerald-glow: rgba(16, 185, 129, 0.2);
    --accent-amber: #f59e0b;
    --accent-amber-glow: rgba(245, 158, 11, 0.2);
    --accent-red: #ef4444;
    --border-color: #1e293b;
    --border-light: #334155;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-card: 0 4px 24px rgba(0,0,0,0.3), 0 1px 4px rgba(0,0,0,0.2);
    --transition: 200ms ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-deep);
    color: var(--fg-primary);
    min-height: 100vh;
    background-image:
        radial-gradient(ellipse at 20% 0%, rgba(6,182,212,0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(16,185,129,0.04) 0%, transparent 50%);
}

.app-wrapper {
    max-width: 1000px;
    margin: 0 auto;
    padding: 32px 24px 60px;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding: 20px 24px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
}

.app-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.app-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    flex-shrink: 0;
}

.app-header-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--accent-amber), #ea580c);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #fff;
    box-shadow: 0 4px 16px var(--accent-amber-glow);
}

.app-header h1 {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--fg-primary), var(--fg-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.app-header p {
    font-size: 13px;
    color: var(--fg-muted);
    margin-top: 2px;
}

.header-link {
    color: var(--fg-muted);
    text-decoration: none;
    font-size: 13px;
    transition: color var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.header-link:hover { color: var(--accent-cyan); }

/* Filter Bar */
.filter-bar {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-card);
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.filter-bar-icon {
    color: var(--accent-amber);
    font-size: 18px;
    margin-right: 4px;
}

.filter-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.filter-select {
    padding: 8px 32px 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--fg-primary);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    color-scheme: dark;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
    outline: none;
    transition: border-color var(--transition);
}

.filter-select:focus {
    border-color: var(--accent-amber);
    box-shadow: 0 0 0 3px var(--accent-amber-glow);
}

.filter-select option {
    background: var(--bg-input);
    color: var(--fg-primary);
}

.filter-count {
    background: rgba(245, 158, 11, 0.12);
    color: var(--accent-amber);
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    margin-left: auto;
}

/* Tips */
.filter-tips-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.tips-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(236, 72, 153, 0.12);
    border: 1px solid rgba(236, 72, 153, 0.25);
    color: #ec4899;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.tips-btn:hover {
    background: rgba(236, 72, 153, 0.25);
    border-color: #ec4899;
    box-shadow: 0 0 12px rgba(236, 72, 153, 0.3);
    transform: scale(1.08);
}

.tips-btn:active { transform: scale(0.95); }

.tips-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(2px);
    z-index: 100;
}
.tips-backdrop.active { display: block; }

.tips-popover {
    display: none;
    position: absolute;
    top: 42px;
    right: 0;
    min-width: 600px;
    width: 600px;
    max-width: calc(100vw - 48px);
    resize: horizontal;
    overflow: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.3);
    z-index: 200;
    animation: tipsEnter 250ms ease;
}
.tips-popover.active { display: block; }

.tips-popover::before {
    content: '';
    position: absolute;
    top: -8px;
    right: 14px;
    width: 14px;
    height: 14px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-light);
    border-left: 1px solid var(--border-light);
    transform: rotate(45deg);
}

.tips-popover-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
}

.tips-popover-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--fg-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.tips-popover-title i { color: #ec4899; font-size: 15px; }

.tips-popover-close {
    width: 28px;
    height: 28px;
    border: none;
    background: var(--bg-input);
    color: var(--fg-muted);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}
.tips-popover-close:hover { background: var(--accent-red); color: #fff; }

.tips-popover-body {
    padding: 18px;
    font-size: 12px;
    color: var(--fg-secondary);
    line-height: 1.6;
    max-height: 400px;
    overflow-y: auto;
}
.tips-popover-body p { margin-bottom: 10px; }
.tips-popover-body p:last-child { margin-bottom: 0; }

.tips-placeholder {
    font-size: 12px;
    color: var(--fg-muted);
    line-height: 1.6;
    font-style: italic;
}

@keyframes tipsEnter {
    from { opacity: 0; transform: translateY(-8px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    height: 42px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-amber {
    background: linear-gradient(135deg, var(--accent-amber), #d97706);
    color: #fff;
    box-shadow: 0 2px 12px var(--accent-amber-glow);
}
.btn-amber:hover { box-shadow: 0 4px 20px var(--accent-amber-glow); }

.btn-ghost {
    background: var(--bg-input);
    color: var(--fg-secondary);
    border: 1px solid var(--border-color);
}
.btn-ghost:hover { background: var(--border-color); color: var(--fg-primary); }

.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 6px; }

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Data Card */
.data-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    transition: border-color var(--transition);
}
.data-card:hover { border-color: var(--border-light); }

.data-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: linear-gradient(135deg, rgba(245,158,11,0.08) 0%, var(--bg-elevated) 60%);
    border-bottom: 1px solid var(--border-color);
    border-top: 2px solid rgba(245,158,11,0.25);
}

.data-card-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    color: var(--fg-primary);
}

.data-card-title i {
    color: var(--accent-amber);
    font-size: 20px;
}

.data-card-count {
    background: rgba(245,158,11,0.12);
    color: var(--accent-amber);
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    margin-left: 8px;
}

.data-card-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-size-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    display: flex;
    align-items: center;
    gap: 4px;
}

.page-size-select {
    padding: 6px 28px 6px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--fg-primary);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    color-scheme: dark;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
    outline: none;
    transition: border-color var(--transition);
}

.page-size-select:focus {
    border-color: var(--accent-amber);
    box-shadow: 0 0 0 3px var(--accent-amber-glow);
}

/* Data Table */
.data-table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background: var(--bg-elevated);
    padding: 10px 16px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--fg-muted);
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    position: sticky;
    top: 0;
}

.data-table td {
    padding: 10px 16px;
    font-size: 13px;
    color: var(--fg-secondary);
    vertical-align: middle;
    border-bottom: 1px solid rgba(30,41,59,0.5);
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: rgba(245,158,11,0.04); }
.data-table tbody tr:nth-child(even) td { background: rgba(15,23,42,0.3); }
.data-table tbody tr:nth-child(even):hover td { background: rgba(245,158,11,0.06); }

.cell-number {
    font-weight: 700;
    color: var(--accent-amber);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.cell-money {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

.cell-money.negative { color: var(--accent-red); }
.cell-money.positive { color: var(--accent-emerald); }
.cell-money.zero { color: var(--fg-muted); }

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

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

.data-table th.cell-right { text-align: right; }
.data-table th.cell-center { text-align: center; }

/* Pagination — override ASP.NET GridView pager */
.data-table tr.pagination-bar {
    border-top: 1px solid var(--border-color);
}

.data-table tr.pagination-bar td {
    padding: 16px 24px;
    border-bottom: none;
}

.data-table tr.pagination-bar td table {
    border-collapse: collapse;
    margin: 0 auto;
}

.data-table tr.pagination-bar td table tr td {
    padding: 3px;
    background: transparent;
    border: none;
}

.data-table tr.pagination-bar td table tr td a,
.data-table tr.pagination-bar td table tr td span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 10px;
    border-radius: 10px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: var(--fg-secondary);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    text-decoration: none;
    transition: all var(--transition);
    cursor: pointer;
}

.data-table tr.pagination-bar td table tr td a:hover {
    background: rgba(245, 158, 11, 0.15);
    border-color: var(--accent-amber);
    color: var(--accent-amber);
}

.data-table tr.pagination-bar td table tr td span {
    background: linear-gradient(135deg, var(--accent-amber), #d97706);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 2px 12px var(--accent-amber-glow);
    cursor: default;
}

/* Empty state */
.empty-state {
    padding: 40px 24px;
    text-align: center;
    color: var(--fg-muted);
}
.empty-state i { font-size: 36px; margin-bottom: 12px; color: var(--border-light); display: block; }
.empty-state p { font-size: 14px; }

/* Action buttons */
.cell-actions {
    white-space: nowrap;
    text-align: center;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}

.btn-edit {
    background: rgba(245, 158, 11, 0.12);
    color: var(--accent-amber);
}
.btn-edit:hover {
    background: var(--accent-amber);
    color: #fff;
    box-shadow: 0 2px 12px var(--accent-amber-glow);
}

.btn-delete {
    background: rgba(239, 68, 68, 0.12);
    color: var(--accent-red);
    margin-left: 6px;
}
.btn-delete:hover {
    background: var(--accent-red);
    color: #fff;
    box-shadow: 0 2px 12px var(--accent-red-glow);
}

/* Additional buttons */
.btn-danger {
    background: linear-gradient(135deg, var(--accent-red), #dc2626);
    color: #fff;
    box-shadow: 0 2px 12px var(--accent-red-glow);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    height: 42px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-danger:hover { box-shadow: 0 4px 20px var(--accent-red-glow); }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 200ms ease;
}
.modal-overlay.active { display: flex; }

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    width: 520px;
    max-width: 95vw;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    animation: slideUp 250ms ease;
}

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

.modal-title {
    font-size: 17px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-input);
    color: var(--fg-muted);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}
.modal-close:hover { background: var(--accent-red); color: #fff; }

.modal-body { padding: 24px; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}

.confirm-text {
    font-size: 15px;
    color: var(--fg-secondary);
    line-height: 1.6;
    text-align: center;
    padding: 8px 0;
}
.confirm-text strong { color: var(--accent-red); }

/* Form */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
}

.form-label i {
    margin-right: 4px;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--fg-primary);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    color-scheme: dark;
}

.form-input:focus {
    border-color: var(--accent-amber);
    box-shadow: 0 0 0 3px var(--accent-amber-glow);
}

.tips-markdown {
    font-size: 12px;
    color: var(--fg-secondary);
    line-height: 1.6;
}

.tips-markdown h2 {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent-amber);
    margin: 0 0 10px 0;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-color);
}

.tips-markdown h3 {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-cyan);
    margin: 14px 0 8px 0;
}

.tips-markdown strong {
    color: var(--accent-amber);
    font-weight: 700;
}

.tips-markdown em {
    color: var(--fg-primary);
    font-style: italic;
}

.tips-markdown code {
    font-family: 'JetBrains Mono', 'Consolas', 'Courier New', monospace;
    font-size: 11px;
    background: var(--bg-deep);
    color: var(--accent-emerald);
    padding: 1px 5px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    white-space: nowrap;
}

/* Markdown Tables */
.tips-table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 12px;
}

.tips-table tr:first-child {
    background: var(--bg-elevated);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 11px;
    color: var(--accent-amber);
}

.tips-table tr:first-child td {
    border-bottom: 2px solid var(--accent-amber);
    padding: 8px 12px;
}

.tips-table tr {
    border-bottom: 1px solid var(--border-color);
    transition: background var(--transition);
}

.tips-table tr:hover {
    background: rgba(245, 158, 11, 0.04);
}

.tips-table tr:nth-child(even) {
    background: rgba(15, 23, 42, 0.3);
}

.tips-table tr:nth-child(even):hover {
    background: rgba(245, 158, 11, 0.06);
}

.tips-table td {
    padding: 8px 12px;
    vertical-align: top;
    color: var(--fg-secondary);
}

.tips-table td:first-child {
    font-weight: 700;
    color: var(--fg-primary);
    width: 40px;
    text-align: center;
}

.tips-table tr:not(:first-child) td:nth-child(2) {
    font-weight: 600;
    color: var(--fg-primary);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--fg-muted); }

/* Responsive */
@media (max-width: 768px) {
    .app-wrapper { padding: 20px 16px 40px; }
    .app-header { flex-direction: column; align-items: flex-start; gap: 14px; }
    .app-header-right { flex-wrap: wrap; }
    .filter-bar { flex-direction: column; align-items: flex-start; }
    .filter-count { margin-left: 0; }
    .data-card-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .data-card-controls { align-self: flex-end; }
    .data-table th, .data-table td { padding: 8px 10px; font-size: 12px; }
    .btn-icon { width: 30px; height: 30px; font-size: 13px; }
    .modal-box { width: 95vw; }
}