:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #0f766e;
  --primary-2: #14b8a6;
  --primary-soft: #ccfbf1;
  --danger: #dc2626;
  --warning: #d97706;
  --success: #15803d;
  --shadow: 0 15px 45px rgba(15, 23, 42, .07);
  --radius: 18px;
}

body.dark {
  --bg: #0b1220;
  --surface: #111827;
  --surface-2: #172033;
  --text: #e5eefb;
  --muted: #94a3b8;
  --border: #263449;
  --primary-soft: rgba(20,184,166,.15);
  --shadow: 0 15px 45px rgba(0,0,0,.2);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: Tahoma, Arial, sans-serif; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 280px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; background: linear-gradient(180deg,#0f766e 0%,#115e59 100%); color: white; padding: 22px 16px; display: flex; flex-direction: column; z-index: 30; }
.brand { display: flex; align-items: center; gap: 12px; padding: 8px 8px 24px; border-bottom: 1px solid rgba(255,255,255,.15); }
.brand-mark { width: 48px; height: 48px; border-radius: 14px; background: rgba(255,255,255,.16); display: grid; place-items: center; font-size: 26px; font-weight: 800; }
.brand h1 { margin: 0; font-size: 18px; }
.brand p { margin: 4px 0 0; font-size: 12px; opacity: .75; }
.nav { display: grid; gap: 6px; padding: 20px 0; overflow-y: auto; }
.nav-item { width: 100%; border: 0; background: transparent; color: rgba(255,255,255,.78); padding: 12px 14px; border-radius: 12px; display: flex; align-items: center; gap: 11px; text-align: right; transition: .2s; }
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.14); color: white; transform: translateX(-2px); }
.nav-item span { width: 24px; text-align: center; font-size: 18px; }
.sidebar-footer { margin-top: auto; display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 12px; background: rgba(255,255,255,.09); border-radius: 12px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #86efac; box-shadow: 0 0 0 5px rgba(134,239,172,.14); }

.main-area { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; min-height: 78px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(16px); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 12px 28px; }
.topbar-start, .topbar-actions, .inline-actions { display: flex; align-items: center; gap: 12px; }
.topbar h2 { margin: 0; font-size: 20px; }
.topbar p { margin: 3px 0 0; font-size: 12px; color: var(--muted); }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); }
#menuToggle { display: none; }
.search-box { min-width: 260px; display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); padding: 9px 12px; border-radius: 12px; }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); }
.notification-btn { position: relative; }
.notification-btn b { position: absolute; top: -5px; left: -5px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 10px; display: grid; place-items: center; background: var(--danger); color: #fff; font-size: 10px; }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 5px 8px; }
.avatar { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: 800; }
.user-chip strong, .user-chip small { display: block; }
.user-chip strong { font-size: 13px; }
.user-chip small { font-size: 11px; color: var(--muted); }

.view { display: none; padding: 26px 28px 40px; animation: fade .25s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.hero-card { background: linear-gradient(120deg,#0f766e,#0ea5a0 55%,#1d4ed8); color: white; padding: 28px; border-radius: 24px; display: flex; align-items: center; justify-content: space-between; gap: 20px; box-shadow: var(--shadow); }
.hero-card h3 { margin: 7px 0; font-size: 26px; }
.hero-card p { margin: 0; opacity: .85; max-width: 680px; }
.eyebrow { font-size: 12px; opacity: .75; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.primary-btn, .ghost-btn, .danger-btn, .text-btn { border: 0; border-radius: 11px; padding: 10px 15px; font-weight: 700; }
.primary-btn { background: var(--primary); color: white; }
.hero-card .primary-btn { background: white; color: #0f766e; }
.ghost-btn { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.hero-card .ghost-btn { background: rgba(255,255,255,.12); color: white; border-color: rgba(255,255,255,.3); }
.danger-btn { background: #fee2e2; color: #991b1b; }
.text-btn { background: transparent; color: var(--primary); padding: 6px; }

.metrics-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 16px; margin: 18px 0; }
.metric-card { background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); border-radius: var(--radius); padding: 18px; display: flex; align-items: center; gap: 14px; }
.metric-card p { margin: 0 0 5px; color: var(--muted); font-size: 13px; }
.metric-card h3 { margin: 0; font-size: 23px; }
.metric-card small { color: var(--muted); }
.metric-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-size: 22px; }

.dashboard-grid { display: grid; grid-template-columns: 1.8fr 1fr; gap: 18px; margin-top: 18px; }
.lower-grid { grid-template-columns: 1fr 1fr; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; min-width: 0; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-head h3, .panel h3 { margin: 0; font-size: 16px; }
.panel-head p, .panel > p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.panel-head select { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 7px 10px; }
canvas { max-width: 100%; }
.donut-wrap { position: relative; display: grid; place-items: center; margin: 10px auto 18px; }
.donut-center { position: absolute; text-align: center; }
.donut-center strong, .donut-center span { display: block; }
.donut-center strong { font-size: 28px; }
.donut-center span { font-size: 12px; color: var(--muted); }
.legend { display: grid; gap: 9px; }
.legend-row { display: flex; align-items: center; justify-content: space-between; font-size: 13px; }
.legend-row span { display: flex; align-items: center; gap: 8px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; }
.compact-list, .timeline { display: grid; gap: 11px; }
.compact-item { border: 1px solid var(--border); background: var(--surface-2); border-radius: 13px; padding: 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.compact-item strong { font-size: 13px; }
.compact-item p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.badge { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 99px; font-size: 11px; font-weight: 700; background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; }
.badge.high { background: #fee2e2; color: #991b1b; border: 0; }
.badge.medium { background: #fef3c7; color: #92400e; border: 0; }
.badge.low { background: #dcfce7; color: #166534; border: 0; }
.timeline-item { position: relative; padding-right: 22px; }
.timeline-item::before { content: ""; position: absolute; right: 3px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--primary); }
.timeline-item::after { content: ""; position: absolute; right: 7px; top: 17px; bottom: -12px; width: 1px; background: var(--border); }
.timeline-item:last-child::after { display: none; }
.timeline-item strong { font-size: 13px; }
.timeline-item p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }

.section-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; }
.section-toolbar h3 { margin: 0; font-size: 22px; }
.section-toolbar p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.filters-row { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.field { width: 100%; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 11px 12px; border-radius: 11px; outline: 0; }
.field:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.kanban { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 16px; align-items: start; }
.kanban-column { background: color-mix(in srgb, var(--surface) 60%, var(--bg)); border: 1px solid var(--border); border-radius: 16px; padding: 14px; min-height: 420px; }
.kanban-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.kanban-head h4 { margin: 0; }
.kanban-head span { min-width: 25px; height: 25px; border-radius: 99px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border); font-size: 11px; }
.task-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 13px; margin-bottom: 10px; box-shadow: 0 8px 20px rgba(15,23,42,.04); }
.task-card h4 { margin: 0 0 9px; font-size: 14px; }
.task-meta { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 11px; }
.task-actions { display: flex; gap: 6px; margin-top: 10px; }
.mini-btn { border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 8px; padding: 5px 8px; font-size: 11px; }

.cards-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 16px; }
.project-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.project-card .project-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.project-card h4 { margin: 0 0 4px; }
.project-card p { margin: 0; font-size: 12px; color: var(--muted); }
.project-details { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0; }
.project-details div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; padding: 10px; }
.project-details span, .project-details strong { display: block; }
.project-details span { font-size: 10px; color: var(--muted); }
.project-details strong { margin-top: 3px; font-size: 12px; }
.progress { width: 100%; height: 8px; border-radius: 99px; background: var(--border); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg,var(--primary),var(--primary-2)); border-radius: inherit; }
.progress-label { display: flex; justify-content: space-between; margin-bottom: 7px; font-size: 12px; }

.table-panel { padding: 0; overflow: hidden; }
.table-panel .panel-head { padding: 20px 20px 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 13px 16px; border-bottom: 1px solid var(--border); text-align: right; font-size: 13px; }
th { color: var(--muted); background: var(--surface-2); font-weight: 700; }
tbody tr:hover { background: var(--surface-2); }
.person-cell { display: flex; align-items: center; gap: 9px; }
.person-avatar { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: 800; }
.actions-cell { display: flex; gap: 6px; }

.planner-summary { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.planner-summary article { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 17px; box-shadow: var(--shadow); }
.planner-summary span, .planner-summary strong, .planner-summary small { display: block; }
.planner-summary span { color: var(--muted); font-size: 12px; }
.planner-summary strong { font-size: 24px; margin: 6px 0; }
.planner-summary small { color: var(--muted); }
.planner-layout { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.week-grid { display: grid; grid-template-columns: repeat(7,minmax(130px,1fr)); gap: 9px; overflow-x: auto; padding-bottom: 6px; }
.day-column { border: 1px solid var(--border); background: var(--surface-2); border-radius: 14px; padding: 10px; min-height: 350px; }
.day-column.today { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.day-head { text-align: center; padding-bottom: 8px; border-bottom: 1px solid var(--border); margin-bottom: 9px; }
.day-head strong, .day-head span { display: block; }
.day-head span { font-size: 11px; color: var(--muted); }
.planner-item { background: var(--surface); border: 1px solid var(--border); border-right: 4px solid var(--primary); border-radius: 10px; padding: 8px; margin-bottom: 7px; }
.planner-item strong, .planner-item span { display: block; }
.planner-item strong { font-size: 11px; }
.planner-item span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.goal-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.goal-item:last-child { border-bottom: 0; }
.goal-item .goal-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; font-size: 12px; }

.finance-metrics { margin-top: 0; }
.reports-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 16px; }
.report-card { text-align: center; }
.big-number { font-size: 32px; font-weight: 800; color: var(--primary); margin: 12px 0; }
.report-chart { margin-top: 18px; }
.settings-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; margin-top: 16px; }
.form-grid label span { display: block; margin-bottom: 6px; font-size: 12px; color: var(--muted); }
.full { grid-column: 1 / -1; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.setting-row strong { font-size: 13px; }
.setting-row p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.switch { width: 45px; height: 24px; padding: 3px; border: 0; border-radius: 99px; background: #cbd5e1; }
.switch i { display: block; width: 18px; height: 18px; border-radius: 50%; background: white; transition: .2s; }
.switch.active { background: var(--primary); }
.switch.active i { transform: translateX(-21px); }

.modal { position: fixed; inset: 0; z-index: 100; background: rgba(2,6,23,.58); display: none; align-items: center; justify-content: center; padding: 20px; }
.modal.open { display: flex; }
.modal-card { width: min(620px,100%); max-height: 90vh; overflow-y: auto; background: var(--surface); color: var(--text); border-radius: 20px; padding: 24px; position: relative; box-shadow: 0 30px 80px rgba(0,0,0,.25); }
.modal-card h3 { margin-top: 0; }
.modal-close { position: absolute; top: 14px; left: 14px; width: 34px; height: 34px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 10px; font-size: 22px; }
.notifications-panel { position: fixed; top: 74px; left: 24px; z-index: 90; width: min(360px, calc(100vw - 30px)); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 25px 65px rgba(15,23,42,.2); padding: 16px; display: none; }
.notifications-panel.open { display: block; }
.notification-item { padding: 11px 0; border-bottom: 1px solid var(--border); }
.notification-item:last-child { border-bottom: 0; }
.notification-item strong { font-size: 12px; }
.notification-item p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.toast { position: fixed; bottom: 26px; left: 26px; z-index: 120; background: #0f172a; color: white; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); opacity: 0; transform: translateY(15px); pointer-events: none; transition: .25s; }
.toast.show { opacity: 1; transform: none; }
.empty-state { text-align: center; padding: 30px 10px; color: var(--muted); }

@media (max-width: 1150px) {
  .metrics-grid, .reports-grid { grid-template-columns: repeat(2,1fr); }
  .cards-grid { grid-template-columns: repeat(2,1fr); }
  .dashboard-grid, .planner-layout, .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; right: -290px; width: 280px; transition: .25s; }
  .sidebar.open { right: 0; }
  #menuToggle { display: grid; }
  .topbar { padding: 10px 16px; }
  .view { padding: 20px 16px 35px; }
  .search-box { min-width: 180px; }
  .user-chip > div:last-child { display: none; }
  .kanban { grid-template-columns: 1fr; }
  .planner-summary { grid-template-columns: 1fr 1fr; }
  .planner-summary article:first-child { grid-column: 1/-1; }
}
@media (max-width: 650px) {
  .topbar-actions .search-box { display: none; }
  .hero-card, .section-toolbar { align-items: flex-start; flex-direction: column; }
  .hero-card h3 { font-size: 21px; }
  .metrics-grid, .reports-grid, .cards-grid, .planner-summary, .filters-row, .form-grid { grid-template-columns: 1fr; }
  .full, .planner-summary article:first-child { grid-column: auto; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .topbar { min-height: 70px; }
  .user-chip { display: none; }
}

@media print {
  .sidebar, .topbar, .section-toolbar button, .hero-actions, .filters-row { display: none !important; }
  .app-shell { display: block; }
  .view { display: none !important; padding: 0; }
  .view.active { display: block !important; }
  body { background: white; color: black; }
  .panel, .metric-card, .hero-card { box-shadow: none; break-inside: avoid; }
}
