/* ===== CSS Custom Properties ===== */
:root {
    --primary-navy: #0D1520;
    --primary-action: #6366F1;
    --secondary-action: #0891B2;
    --success-growth: #10B981;
    --warning-caution: #F59E0B;
    --error-alert: #DC2626;
    --surface-white: #FFFFFF;
    --surface-light: #F8FAFC;
    --text-primary: #1E293B;
    --text-secondary: #64748B;
    --text-tertiary: #94A3B8;
    --border-light: #E2E8F0;
    --border-medium: #CBD5E1;
    --sidebar-width: 240px;
    --header-height: 64px;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--surface-light);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}
a { color: var(--primary-action); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

/* ===== App Layout ===== */
.app-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: var(--header-height) 1fr;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    grid-row: 1 / -1;
    grid-column: 1;
    background: var(--primary-navy);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    z-index: 100;
    overflow-y: auto;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand-icon { font-size: 1.5rem; }
.sidebar-brand-text { font-size: clamp(18px, 2vw, 22px); font-weight: 700; letter-spacing: -0.02em; }
.sidebar-nav { flex: 1; padding: 1rem 0; }
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: rgba(255,255,255,0.7);
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
}
.sidebar-link:hover { background: rgba(255,255,255,0.06); color: white; text-decoration: none; }
.sidebar-link.active { background: rgba(99,102,241,0.2); color: white; border-right: 3px solid var(--primary-action); }
.sidebar-icon { font-size: 1.1rem; width: 1.5rem; text-align: center; }
.sidebar-label { flex: 1; }
.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-user { margin-bottom: 0.5rem; }
.sidebar-user-name { display: block; font-size: 14px; font-weight: 600; }
.sidebar-user-role { display: block; font-size: 12px; color: rgba(255,255,255,0.5); text-transform: uppercase; letter-spacing: 0.05em; }
.sidebar-logout { display: block; font-size: 13px; color: rgba(255,255,255,0.5); padding: 0.375rem 0; }
.sidebar-logout:hover { color: white; }

/* ===== Header ===== */
.header {
    grid-column: 2;
    grid-row: 1;
    background: var(--surface-white);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--header-height);
}
.header-left { display: flex; align-items: center; gap: 1rem; }
.header-right { display: flex; align-items: center; gap: 1rem; }
.breadcrumb { display: flex; align-items: center; gap: 0.5rem; font-size: 13px; color: var(--text-secondary); }
.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--primary-action); }
.breadcrumb-sep { color: var(--text-tertiary); }
.breadcrumb-current { color: var(--text-primary); font-weight: 500; }

/* ===== Main Content ===== */
.main-content {
    grid-column: 2;
    grid-row: 2;
    padding: 1.5rem;
    overflow-y: auto;
}

/* ===== Page Header ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.page-title { font-size: clamp(20px, 3vw, 24px); font-weight: 600; color: var(--primary-navy); }
.page-subtitle { font-size: 14px; color: var(--text-secondary); margin-top: 0.25rem; }

/* ===== Metric Cards ===== */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.metric-card {
    background: var(--surface-light);
    border-radius: 12px;
    padding: 1.25rem;
    border: 1px solid var(--border-light);
}
.metric-label { font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 0.375rem; }
.metric-value { font-size: clamp(24px, 3vw, 32px); font-weight: 700; color: var(--primary-navy); }
.metric-sub { font-size: 12px; color: var(--text-tertiary); margin-top: 0.25rem; }

/* ===== Cards ===== */
.card {
    background: var(--surface-white);
    border-radius: 12px;
    padding: 1.25rem;
    border: 1px solid var(--border-light);
    margin-bottom: 1.5rem;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.card-title { font-size: 18px; font-weight: 600; color: var(--text-primary); }
.card-actions { display: flex; gap: 0.5rem; }

/* ===== Tables ===== */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-weight: 500;
    font-size: 13px;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-light);
    white-space: nowrap;
}
tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}
tbody tr:hover { background: var(--surface-light); }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: box-shadow 0.15s, background 0.15s;
    white-space: nowrap;
    line-height: 1;
}
.btn:active { transform: scale(0.98); }
.btn:focus { outline: none; box-shadow: 0 0 0 3px rgba(99,102,241,0.2); }
.btn-primary { background: var(--primary-action); color: white; }
.btn-primary:hover { background: #4F46E5; box-shadow: 0 4px 12px rgba(99,102,241,0.4); text-decoration: none; }
.btn-secondary { background: var(--secondary-action); color: white; }
.btn-secondary:hover { background: #0E7490; box-shadow: 0 4px 12px rgba(8,145,178,0.4); text-decoration: none; }
.btn-success { background: var(--success-growth); color: white; }
.btn-success:hover { background: #059669; text-decoration: none; }
.btn-warning { background: var(--warning-caution); color: #1E293B; }
.btn-warning:hover { background: #D97706; text-decoration: none; }
.btn-error { background: var(--error-alert); color: white; }
.btn-error:hover { background: #B91C1C; text-decoration: none; }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border-light); }
.btn-ghost:hover { background: var(--surface-light); color: var(--text-primary); }
.btn-sm { padding: 0.5rem 1rem; font-size: 13px; }
.btn-xs { padding: 0.375rem 0.75rem; font-size: 12px; }

/* ===== Forms ===== */
.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; font-size: 14px; font-weight: 500; color: var(--text-secondary); margin-bottom: 0.375rem; }
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--surface-white);
    transition: box-shadow 0.15s, border-color 0.15s;
    font-family: inherit;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary-action);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.2);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-actions { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1.5rem; }
.form-error { font-size: 13px; color: var(--error-alert); margin-top: 0.25rem; }
.form-input.error, .form-select.error, .form-textarea.error { border-color: var(--error-alert); }

/* ===== Status Badges ===== */
.badge {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.badge-success { background: var(--success-growth); color: white; }
.badge-warning { background: var(--warning-caution); color: #1E293B; }
.badge-error { background: var(--error-alert); color: white; }
.badge-info { background: var(--secondary-action); color: white; }
.badge-navy { background: var(--primary-navy); color: white; }
.badge-light { background: var(--surface-light); color: var(--text-secondary); border: 1px solid var(--border-light); }
.badge-indigo { background: var(--primary-action); color: white; }

/* ===== Status mappings ===== */
.status-active, .status-sent, .status-in_progress { background: var(--secondary-action); color: white; }
.status-completed, .status-paid, .status-done { background: var(--success-growth); color: white; }
.status-on_hold, .status-blocked, .status-overdue { background: var(--warning-caution); color: #1E293B; }
.status-draft, .status-todo { background: var(--surface-light); color: var(--text-secondary); border: 1px solid var(--border-light); }

/* ===== Filters Bar ===== */
.filters-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    align-items: center;
}
.filters-bar .form-select { width: auto; min-width: 160px; }

/* ===== Modal ===== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--surface-white);
    border-radius: 12px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.5rem;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}
.modal-title { font-size: 18px; font-weight: 600; color: var(--text-primary); }
.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}
.modal-close:hover { color: var(--text-primary); }

/* ===== Dropdown ===== */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 180px;
    background: var(--surface-white);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    z-index: 150;
    padding: 0.375rem 0;
}
.dropdown-menu.open { display: block; }
.dropdown-item {
    display: block;
    padding: 0.5rem 1rem;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
}
.dropdown-item:hover { background: var(--surface-light); }
.dropdown-item.error { color: var(--error-alert); }
.dropdown-item.error:hover { background: #FEF2F2; }

/* ===== Alert / Messages ===== */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.alert-success { background: #F0FDF4; color: #065F46; border: 1px solid #BBF7D0; }
.alert-error { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }
.alert-warning { background: #FFFBEB; color: #92400E; border: 1px solid #FDE68A; }
.alert-info { background: #EFF6FF; color: #1E40AF; border: 1px solid #BFDBFE; }

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-tertiary);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state-text { font-size: 16px; font-weight: 500; margin-bottom: 0.5rem; color: var(--text-secondary); }
.empty-state-sub { font-size: 14px; }

/* ===== Task List (Ordered) ===== */
.task-list {
    list-style: decimal;
    padding-left: 1.5rem;
    margin: 0;
}
.task-list-item {
    padding: 0.5rem 0.5rem 0.5rem 0.25rem;
    border-bottom: 1px solid var(--border-light);
    font-size: 14px;
}
.task-list-item:last-child { border-bottom: none; }
.task-list-item.task-done { opacity: 0.7; }
.task-list-item.task-blocked-item { border-left: 3px solid var(--warning-caution); }
.task-list-main {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.task-list-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 200px;
}
.task-list-title {
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
}
.task-title-done {
    text-decoration: line-through;
    color: var(--text-tertiary);
}
.task-list-meta {
    display: flex;
    gap: 0.75rem;
    font-size: 12px;
    color: var(--text-tertiary);
    flex-wrap: wrap;
}
.task-checkBtn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--border-medium);
    background: var(--surface-white);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    transition: background 0.15s, border-color 0.15s;
    flex-shrink: 0;
}
.task-checkBtn:hover { border-color: var(--primary-action); }
.task-checkBtn-done:hover { background: var(--success-growth); color: white; border-color: var(--success-growth); }
.task-checkBtn-undone { border-color: var(--text-tertiary); color: var(--text-tertiary); }
.task-checkBtn-undone:hover { border-color: var(--warning-caution); color: var(--warning-caution); }
.task-checkBtn-resume { border-color: var(--secondary-action); color: var(--secondary-action); }
.task-checkBtn-resume:hover { background: var(--secondary-action); color: white; }
.task-expand-btn {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: 11px;
    padding: 0.25rem;
    flex-shrink: 0;
}
.task-expand-btn:hover { color: var(--text-primary); }
.task-details {
    display: none;
    margin-top: 0.75rem;
    margin-left: 2.25rem;
    padding: 0.75rem 1rem;
    background: var(--surface-light);
    border-radius: 8px;
    border: 1px solid var(--border-light);
}
.task-details.open { display: block; }
.task-desc { margin-bottom: 0.75rem; }
.task-desc strong { font-size: 13px; color: var(--text-secondary); display: block; margin-bottom: 0.25rem; }
.task-desc p { font-size: 14px; color: var(--text-primary); line-height: 1.6; }
.task-blocker-box {
    padding: 0.75rem;
    background: #FFFBEB;
    border-radius: 8px;
    border: 1px solid #FDE68A;
    margin-bottom: 0.75rem;
}
.task-blocker-box p { font-size: 14px; color: #92400E; margin-top: 0.25rem; line-height: 1.5; }
.task-actions { display: flex; gap: 0.375rem; flex-wrap: wrap; margin-top: 0.5rem; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .app-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }
    .sidebar {
        position: fixed;
        left: -100%;
        width: 280px;
        transition: left 0.2s;
        z-index: 200;
    }
    .sidebar.open { left: 0; }
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 199;
    }
    .sidebar-overlay.open { display: block; }
    .header { grid-column: 1; }
    .main-content { grid-column: 1; padding: 1rem; }
    .form-row { grid-template-columns: 1fr; }
    .metrics-grid { grid-template-columns: repeat(2, 1fr); }
    .hamburger { display: flex !important; }
}

@media (max-width: 480px) {
    .metrics-grid { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .filters-bar { flex-direction: column; }
    .filters-bar .form-select { width: 100%; }
}

/* ===== Hamburger (mobile) ===== */
.hamburger {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}
.hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
}

/* ===== Login Page ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-navy);
    padding: 2rem;
}
.login-card {
    background: var(--surface-white);
    border-radius: 12px;
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-brand {
    text-align: center;
    margin-bottom: 2rem;
}
.login-brand-icon { font-size: 2.5rem; }
.login-brand-name { font-size: 24px; font-weight: 700; color: var(--primary-navy); letter-spacing: -0.02em; }

/* ===== Crypto test page ===== */
.result-box {
    background: var(--primary-navy);
    color: white;
    padding: 1rem;
    border-radius: 8px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 13px;
    word-break: break-all;
}
