/* =====================================================
   SMSF Workflow Manager — Main Stylesheet
   ===================================================== */

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

:root {
    --primary: #00b6d6;
    --primary-dark: #006f93;
    --primary-light: #e0f7fb;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #0891b2;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --sidebar-w: 240px;
    --topbar-h: 60px;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
}

body { font-family: 'Inter', sans-serif; background: var(--gray-100); color: var(--gray-800); font-size: 14px; line-height: 1.5; }

/* Layout */
.app-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-w);
    background: var(--gray-900);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    overflow-y: auto;
    transition: transform .25s;
}
.sidebar-header { padding: 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.logo { display: flex; align-items: center; gap: 10px; }
.logo-badge { background: #fff; border-radius: 8px; padding: 8px 10px; display: inline-flex; align-items: center; }
.logo-badge img { height: 26px; display: block; }
.logo-sub { font-size: 11px; color: var(--gray-400); text-transform: uppercase; letter-spacing: .05em; margin-top: 6px; }

.sidebar-nav { flex: 1; padding: 12px 8px; }
.nav-section { font-size: 10px; font-weight: 700; letter-spacing: .1em; color: var(--gray-500); padding: 16px 8px 4px; text-transform: uppercase; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px; border-radius: 6px;
    color: var(--gray-300); text-decoration: none;
    font-size: 13.5px; font-weight: 500;
    transition: all .15s;
    margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,.08); }
.user-info { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; flex-shrink: 0; }
.user-name { font-size: 13px; font-weight: 600; color: #fff; }
.user-role { font-size: 11px; color: var(--gray-400); }
.btn-logout { display: block; text-align: center; background: rgba(255,255,255,.1); color: var(--gray-300); padding: 7px; border-radius: 6px; text-decoration: none; font-size: 13px; transition: all .15s; }
.btn-logout:hover { background: var(--danger); color: #fff; }

/* Main Content */
.main-content { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
    height: var(--topbar-h);
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    display: flex; align-items: center;
    padding: 0 24px; gap: 16px;
    position: sticky; top: 0; z-index: 50;
    box-shadow: var(--shadow);
}
.sidebar-toggle { display: none; background: none; border: none; font-size: 22px; cursor: pointer; color: var(--gray-600); }
.page-title { font-size: 18px; font-weight: 600; flex: 1; }
.topbar-right { font-size: 13px; color: var(--gray-500); }
.date-display { }

.content-area { padding: 24px; flex: 1; }

/* Cards */
.card { background: #fff; border-radius: var(--radius); border: 1px solid var(--gray-200); box-shadow: var(--shadow); margin-bottom: 20px; }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--gray-100); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-title { font-size: 15px; font-weight: 600; color: var(--gray-800); }
.card-body { padding: 20px; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--gray-100); background: var(--gray-50); border-radius: 0 0 var(--radius) var(--radius); }

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; border-radius: var(--radius); border: 1px solid var(--gray-200); padding: 18px 20px; box-shadow: var(--shadow); }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; margin-bottom: 6px; }
.stat-label { font-size: 12px; color: var(--gray-500); font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }
.stat-card.blue .stat-value { color: var(--primary); }
.stat-card.green .stat-value { color: var(--success); }
.stat-card.orange .stat-value { color: var(--warning); }
.stat-card.red .stat-value { color: var(--danger); }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.form-grid-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full-width { grid-column: 1 / -1; }
label { font-size: 13px; font-weight: 500; color: var(--gray-700); }
label .req { color: var(--danger); margin-left: 2px; }
input[type="text"], input[type="email"], input[type="number"], input[type="date"],
input[type="password"], select, textarea {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 14px;
    color: var(--gray-800);
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
    font-family: inherit;
    width: 100%;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
input[readonly] { background: var(--gray-50); color: var(--gray-500); cursor: default; }
textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 12px; color: var(--gray-400); }

/* Checkbox / Toggle */
.toggle-row { display: flex; align-items: center; gap: 10px; }
.toggle-row input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; accent-color: var(--primary); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 6px; font-size: 13.5px; font-weight: 500; cursor: pointer; border: none; text-decoration: none; transition: all .15s; line-height: 1.4; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #b45309; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-secondary { background: var(--gray-200); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-300); }
.btn-outline { background: transparent; border: 1px solid var(--gray-300); color: var(--gray-700); }
.btn-outline:hover { background: var(--gray-50); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }

/* Tables */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th { background: var(--gray-50); padding: 10px 14px; text-align: left; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--gray-500); border-bottom: 1px solid var(--gray-200); white-space: nowrap; }
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }

/* Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600; }
.badge-blue { background: var(--primary-light); color: var(--primary-dark); }
.badge-green { background: #dcfce7; color: #166534; }
.badge-orange { background: #fef3c7; color: #92400e; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }
.badge-purple { background: #ede9fe; color: #5b21b6; }

/* Complexity badges */
.complexity-simple { background: #dcfce7; color: #166534; }
.complexity-medium { background: var(--primary-light); color: var(--primary-dark); }
.complexity-complex { background: #fef3c7; color: #92400e; }
.complexity-high { background: #fee2e2; color: #991b1b; }

/* Alerts */
.alert { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; }
.alert-success { background: #f0fdf4; border: 1px solid #86efac; color: #166534; }
.alert-error { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; }
.alert-warning { background: #fffbeb; border: 1px solid #fcd34d; color: #92400e; }
.alert-info { background: #f0f9ff; border: 1px solid #7dd3fc; color: #075985; }
.alert-close { background: none; border: none; cursor: pointer; font-size: 18px; line-height: 1; opacity: .6; flex-shrink: 0; }
.alert-close:hover { opacity: 1; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 200; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.open { display: flex; }
.modal { background: #fff; border-radius: 10px; width: 100%; max-width: 680px; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-header { padding: 18px 20px; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--gray-400); line-height: 1; }
.modal-close:hover { color: var(--gray-700); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--gray-200); display: flex; gap: 10px; justify-content: flex-end; background: var(--gray-50); }

/* Timer */
.timer-box { background: var(--gray-900); color: #fff; border-radius: 10px; padding: 20px 24px; text-align: center; }
.timer-display { font-size: 42px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .04em; color: #4ade80; font-family: 'Courier New', monospace; }
.timer-stage { font-size: 12px; color: var(--gray-400); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .1em; }
.timer-controls { display: flex; gap: 10px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.timer-controls .btn { min-width: 80px; }

/* Unallocated Days Box */
.unallocated-box { background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; border-radius: 10px; padding: 20px 24px; text-align: center; }
.unallocated-days { font-size: 48px; font-weight: 800; line-height: 1; margin-bottom: 4px; }
.unallocated-label { font-size: 12px; opacity: .8; text-transform: uppercase; letter-spacing: .1em; }

/* Checklist */
.checklist-item { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--gray-100); }
.checklist-item:last-child { border-bottom: none; }
.checklist-check { width: 18px; height: 18px; cursor: pointer; accent-color: var(--success); flex-shrink: 0; margin-top: 1px; }
.checklist-text { flex: 1; font-size: 13.5px; }
.checklist-text .category { font-size: 11px; color: var(--gray-400); font-weight: 500; }
.checklist-deviation { display: flex; align-items: center; gap: 6px; }
.checklist-deviation input[type="checkbox"] { accent-color: var(--warning); width: 15px; height: 15px; }

/* Investment grid */
.inv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.inv-item { background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: 8px; padding: 10px; }
.inv-item label { font-size: 12px; color: var(--gray-600); display: block; margin-bottom: 4px; }
.inv-item input { text-align: center; font-weight: 600; font-size: 16px; padding: 5px; }

/* Date tracking grid */
.dates-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.date-item { background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: 8px; padding: 10px; }
.date-item label { font-size: 11px; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; display: block; }

/* Summary boxes */
.summary-boxes { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.summary-box { background: #fff; border: 1px solid var(--gray-200); border-radius: 8px; padding: 14px 16px; text-align: center; }
.summary-box-value { font-size: 22px; font-weight: 700; color: var(--primary); }
.summary-box-label { font-size: 11px; color: var(--gray-500); margin-top: 2px; }

/* Search bar */
.search-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.search-input { flex: 1; min-width: 200px; max-width: 320px; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--gray-200); margin-bottom: 20px; }
.tab { padding: 9px 18px; font-size: 13.5px; font-weight: 500; color: var(--gray-500); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .15s; background: none; border-top: none; border-left: none; border-right: none; }
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Section heading */
.section-heading { font-size: 14px; font-weight: 600; color: var(--gray-700); margin: 20px 0 12px; display: flex; align-items: center; gap: 8px; }
.section-heading::after { content: ''; flex: 1; height: 1px; background: var(--gray-200); }

/* Query stages */
.query-stage { border: 1px solid var(--gray-200); border-radius: 8px; overflow: hidden; margin-bottom: 12px; }
.query-stage-header { padding: 10px 14px; background: var(--gray-50); font-weight: 600; font-size: 13px; display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
.query-stage-body { padding: 14px; display: none; }
.query-stage-body.open { display: block; }

/* Pagination */
.pagination { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.page-btn { padding: 5px 10px; border: 1px solid var(--gray-200); border-radius: 5px; font-size: 13px; color: var(--gray-600); cursor: pointer; background: #fff; text-decoration: none; }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:hover:not(.active) { background: var(--gray-50); }

/* Login page */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #000000, var(--primary-dark), var(--primary)); }
.login-card { background: #fff; border-radius: 12px; padding: 40px; width: 380px; box-shadow: 0 25px 60px rgba(0,0,0,.3); }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo img { height: 48px; }
.login-logo h1 { font-size: 22px; font-weight: 700; margin-top: 8px; color: var(--gray-800); }
.login-logo p { font-size: 13px; color: var(--gray-500); }

/* File upload */
.file-upload-area { border: 2px dashed var(--gray-300); border-radius: 8px; padding: 20px; text-align: center; color: var(--gray-500); cursor: pointer; transition: all .15s; }
.file-upload-area:hover { border-color: var(--primary); background: var(--primary-light); }
.file-upload-area input { display: none; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .sidebar-toggle { display: block; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .form-grid { grid-template-columns: 1fr; }
}

/* Utilities */
.flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--gray-400); }
.font-bold { font-weight: 700; }
.text-right { text-align: right; }
.w-full { width: 100%; }
.hidden { display: none; }

/* ---- v2.0 additions ---- */
.status-pipeline { display:flex; align-items:center; gap:0; margin:16px 0; }
.pipeline-step { flex:1; text-align:center; padding:8px 4px; font-size:11px; font-weight:600;
    background:var(--gray-100); border:1px solid var(--gray-200); position:relative; }
.pipeline-step:not(:last-child)::after { content:'▶'; position:absolute; right:-8px; top:50%;
    transform:translateY(-50%); color:var(--gray-400); font-size:10px; z-index:1; }
.pipeline-step.done { background:#dcfce7; color:#166534; border-color:#86efac; }
.pipeline-step.active { background:var(--primary); color:#fff; border-color:var(--primary-dark); }
.pipeline-step.skipped { background:#fef3c7; color:#92400e; border-color:#fcd34d; }

.info-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(200px,1fr)); gap:12px; }
.info-item label { font-size:11px; font-weight:600; color:var(--gray-500); text-transform:uppercase; letter-spacing:.04em; display:block; margin-bottom:3px; }
.info-item .value { font-size:14px; font-weight:500; color:var(--gray-800); }

.billing-card { background:#fff; border:1px solid var(--gray-200); border-radius:10px; padding:20px; }
.billing-total { font-size:32px; font-weight:800; color:var(--primary); }
.billing-row { display:flex; justify-content:space-between; padding:8px 0; border-bottom:1px solid var(--gray-100); font-size:14px; }
.billing-row:last-child { border-bottom:none; }
.billing-row.total { font-weight:700; font-size:16px; border-top:2px solid var(--gray-200); margin-top:4px; padding-top:12px; }
.billing-row.subtotal { font-weight:600; background:var(--gray-50); padding:8px; border-radius:4px; }

.firm-card { background:#fff; border:1px solid var(--gray-200); border-radius:8px; padding:16px;
    display:flex; flex-direction:column; gap:8px; transition:box-shadow .15s; }
.firm-card:hover { box-shadow:var(--shadow-md); }
.firm-card-title { font-weight:700; font-size:15px; }
.firm-card-meta { font-size:12px; color:var(--gray-500); }
.firm-card-stats { display:flex; gap:12px; flex-wrap:wrap; }
.firm-stat { text-align:center; background:var(--gray-50); border-radius:6px; padding:6px 12px; }
.firm-stat-val { font-weight:700; font-size:18px; color:var(--primary); }
.firm-stat-lbl { font-size:10px; color:var(--gray-500); }

.sign-off-box { background:linear-gradient(135deg,#f0fdf4,#dcfce7); border:1px solid #86efac;
    border-radius:10px; padding:16px; }
.sign-off-box.pending { background:linear-gradient(135deg,#fefce8,#fef9c3); border-color:#fde047; }
.sign-off-box h4 { font-size:13px; font-weight:700; margin-bottom:10px; }

.actuarial-box { background:#fef3c7; border:1px solid #fcd34d; border-radius:8px; padding:14px; }
.actuarial-box.active { background:#dcfce7; border-color:#86efac; }

.fee-hidden { filter:blur(4px); user-select:none; pointer-events:none; }
.fee-hidden-label { font-size:11px; color:var(--gray-400); font-style:italic; }

.export-bar { background:var(--primary-dark); color:#fff; border-radius:8px; padding:14px 20px;
    display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:16px; }
.export-bar h3 { font-size:15px; font-weight:600; }

.invoice-badge { display:inline-flex; align-items:center; gap:4px; padding:3px 10px;
    border-radius:99px; font-size:12px; font-weight:600; }
.inv-draft  { background:#f3f4f6; color:#374151; }
.inv-sent   { background:var(--primary-light); color:var(--primary-dark); }
.inv-paid   { background:#dcfce7; color:#166534; }
.inv-overdue{ background:#fee2e2; color:#991b1b; }

.fund-link-badge { display:inline-flex; align-items:center; gap:4px; font-size:12px;
    color:var(--primary); background:var(--primary-light); padding:2px 8px; border-radius:4px; }
