:root {
  --primary: #007bff;
  --secondary: #aaa;
  --background: #f5f5fa;
  --foreground: #fff;
  --text: #222;
  --border: #ddd;
  --card: #f8f8ff;
  --danger: #dc3545;
  --success: #28a745;
  --sidebar-bg: #23243c;
  --sidebar-text: #fff;
  --sidebar-active: #007bff;
  --shadow: 0 2px 12px #ddd;
}
[data-theme="dark"] {
  --primary: #4f90ff;
  --secondary: #333;
  --background: #181924;
  --foreground: #22223b;
  --text: #eee;
  --border: #333;
  --card: #23243c;
  --danger: #e05268;
  --success: #2bc48a;
  --sidebar-bg: #151522;
  --sidebar-text: #eee;
  --sidebar-active: #4f90ff;
  --shadow: 0 2px 12px #222;
}
body { font-family: 'Segoe UI', Arial, sans-serif; background: var(--background); margin: 0; color: var(--text); transition: background 0.2s, color 0.2s;}
.main-wrapper { display: flex; min-height: 100vh;}
.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  box-shadow: 2px 0 8px #0002;
  z-index: 2;
  min-height: 100vh;
}
.sidebar h2 { margin: 1em 0 0.5em; text-align:center; font-size:1.3em;}
.sidebar-nav { flex:1; display:flex; flex-direction:column; gap:0.2em; margin:1em 0; }
.sidebar-nav button {
  background: none; color: var(--sidebar-text); border: none; border-left: 4px solid transparent; text-align: left; padding: 0.8em 1em; font-size: 1em; cursor: pointer; transition: background 0.15s, border 0.15s; border-radius:0;
}
.sidebar-nav button.active, .sidebar-nav button:hover {
  background: var(--sidebar-active)22; border-left: 4px solid var(--sidebar-active); color: var(--sidebar-active);
}
.sidebar-footer { margin: 1em 0; padding: 0 1em; }
.sidebar-theme { margin: 1em 0; text-align: center;}
.sidebar-theme label { cursor:pointer; padding:0.4em 1em; background: var(--primary); color:#fff; border-radius:3em; display:inline-block;}
.topbar {
  width: 100%; background: var(--foreground); color: var(--text); height: 62px; box-shadow: 0 1px 8px var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 2em;
  position: sticky; top: 0; z-index: 1;
}
.topbar .user-info { display: flex; align-items: center; gap: 1em; font-size:1em;}
.topbar .avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--card); object-fit: cover; border: 2px solid var(--primary);}
.topbar .logout-btn { font-size:0.95em; padding:0.3em 1em; margin-left:1em;}
.container {
  flex:1;
  max-width: none;
  background: var(--foreground);
  padding: 2em;
  border-radius: 0;
  box-shadow: none;
  min-height: 100vh;
}
.dashboard-cards { display:flex; flex-wrap:wrap; gap:1em; margin-top:2em;}
.dashboard-card { background:var(--card); border-radius:8px; box-shadow:0 1px 4px var(--border); padding:1.5em; flex:1; text-align:center; min-width:160px; position:relative;}
.dashboard-card .card-icon { font-size:2em; position:absolute; top:1em; right:1em; opacity:0.18;}
.dashboard-widgets { margin-top:2em; display:flex; flex-wrap:wrap; gap:2em;}
.widget { background:var(--card); border-radius:8px; box-shadow:0 1px 4px var(--border); padding:1.2em 1em; flex:1; min-width:250px;}
.widget-title { font-size:1.1em; font-weight:bold; margin-bottom:0.7em;}
.chart-container { width:100%; max-width:420px; margin:0 auto;}
.btn { padding: 0.7em 1.4em; margin: 0.4em; background: var(--primary); color: #fff; border: none; border-radius: 5px; font-size: 1em; cursor: pointer; transition: background 0.2s;}
.btn:hover, .btn.active { background: #0056b3; }
.btn-secondary { background: var(--secondary);}
.btn-danger { background: var(--danger);}
.btn-success { background: var(--success);}
.panel { margin-top: 2em;}
.actions { margin-bottom: 1em; display: flex; flex-wrap: wrap; gap: 1em;}
input, select, textarea { padding: 0.6em; margin: 0.3em 0; font-size: 1em; border-radius: 4px; border: 1px solid var(--border); width: 100%; box-sizing: border-box;}
textarea { resize: vertical;}
table { border-collapse: collapse; width: 100%; margin-top: 1em;}
th, td { border: 1px solid var(--border); padding: 0.5em 1em; text-align: left;}
.modal { position:fixed; top:0; left:0; right:0; bottom:0; background:#2228c044; display:flex; align-items:center; justify-content:center; z-index:9999;}
.modal-content { background: var(--foreground); color: var(--text); padding:2em; border-radius:10px; min-width:320px; box-shadow:0 2px 12px var(--primary);}
.modal-actions { display:flex; gap:1em; margin-top:1em;}
.fade-in { animation:fadein 0.2s;}
@keyframes fadein { from { opacity:0; } to { opacity:1; } }
.toast { position:fixed; top:20px; right:20px; background:var(--primary); color:#fff; padding:1em; border-radius:5px; box-shadow:0 2px 8px #555; z-index:99999; font-weight:600;}
.toast-success { background:var(--success);}
.toast-info { background:#17a2b8;}
.toast-error { background:var(--danger);}
@media (max-width:900px) {
  .main-wrapper { flex-direction:column;}
  .sidebar {
    width: 100vw;
    min-height: 0;
    flex-direction: row;
    align-items: flex-start;
    box-shadow: none;
    overflow-x: auto;
    padding: 0.3em 0;
  }
  .sidebar-nav {
    flex-direction:row;
    gap:0.3em;
    margin: 0 1em;
  }
  .sidebar-footer { margin: 0.5em 0; }
  .sidebar h2 {display:none;}
  .container { padding: 1em; }
  .dashboard-cards { flex-direction:column;}
  .dashboard-widgets { flex-direction:column;}
  .widget { min-width: 0; }
  .topbar { padding: 0 0.5em; }
}
@media (max-width:600px) {
  .topbar { flex-direction:column; height:auto; padding:1em 0.5em;}
  .topbar .user-info { margin-top:0.5em;}
}