@import url("https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;600;700&display=swap");

:root {
  --bg-0: #0b1118;
  --bg-1: #111a24;
  --bg-2: #162232;
  --panel: #121b27;
  --card: #1b2634;
  --text: #e7edf4;
  --muted: #9fb2c8;
  --accent: #2b7fff;
  --low: #2dd4bf;
  --mid: #f59e0b;
  --high: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --stroke: rgba(255, 255, 255, 0.08);
  --glow: rgba(43, 127, 255, 0.25);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --sidebar-collapsed: 64px;
  --sidebar-mobile-width: min(85vw, 380px);
}

* {
  box-sizing: border-box;
}

.icon {
  font-family: "Material Symbols Rounded";
  font-weight: 400;
  font-style: normal;
  font-size: 18px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
}

.icon.icon-sm {
  font-size: 16px;
}

.icon.icon-md {
  font-size: 20px;
}

.icon.icon-lg {
  font-size: 24px;
}

.icon.icon-xl {
  font-size: 28px;
}

.icon.icon-xxl {
  font-size: 48px;
}

body {
  margin: 0;
  font-family: "Cairo", "Noto Kufi Arabic", "Tajawal", sans-serif;
  background: radial-gradient(900px 600px at 8% 8%, #1d2a3a 0%, transparent 60%),
    radial-gradient(900px 500px at 90% 16%, #1b2a3f 0%, transparent 55%),
    linear-gradient(135deg, var(--bg-0), var(--bg-2));
  color: var(--text);
  min-height: 100vh;
  direction: rtl;
  text-align: right;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: radial-gradient(
      rgba(255, 255, 255, 0.04) 1px,
      transparent 1px
    ),
    radial-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 120px 120px, 80px 80px;
  background-position: 0 0, 40px 40px;
  opacity: 0.35;
  pointer-events: none;
}

.app {
  --sidebar-width: 260px;
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, #0f1824, #121d2b);
  border-left: 1px solid var(--stroke);
  padding: 24px 20px;
  grid-column: 1;
  position: sticky;
  top: 0;
  height: 100vh;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.35);
  order: 1;
  width: var(--sidebar-width);
  transition: width 0.25s ease, transform 0.25s ease, opacity 0.2s ease;
}

.sidebar-toggle {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: rgba(12, 18, 28, 0.85);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.25);
}

.sidebar-toggle-mobile {
  display: none;
}

.sidebar-toggle-desktop {
  display: inline-flex;
}

.topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(12, 18, 28, 0.95);
  border-bottom: 1px solid var(--stroke);
  position: sticky;
  top: 0;
  z-index: 45;
}

.topbar-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--text);
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 10, 16, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 50;
}

.sidebar-open .sidebar-overlay {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
}

.sidebar-header .brand {
  margin-bottom: 0;
}

.sidebar-footer {
  position: absolute;
  bottom: 20px;
  left: 20px;
  right: 20px;
}

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

body:not(.sidebar-open) .sidebar {
  padding: 16px 10px;
  overflow: hidden;
}

body:not(.sidebar-open) .sidebar-header {
  margin-bottom: 0;
  justify-content: flex-start;
}

body:not(.sidebar-open) .sidebar-header .brand,
body:not(.sidebar-open) .nav,
body:not(.sidebar-open) .sidebar-footer {
  display: none;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 32px;
  letter-spacing: 0.4px;
  text-align: center;
  color: var(--accent);
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(43, 127, 255, 0.15);
  border: 1px solid rgba(43, 127, 255, 0.3);
  box-shadow: 0 10px 30px rgba(43, 127, 255, 0.2);
}

.nav {
  display: grid;
  gap: 12px;
}

.nav a {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  color: var(--muted);
  text-decoration: none;
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  transition: all 0.2s ease;
  text-align: right;
  font-weight: 500;
  min-height: 44px;
}

.nav a:hover,
.nav a.active {
  color: var(--text);
  border-color: var(--stroke);
  background: rgba(43, 127, 255, 0.08);
}

.main {
  padding: 28px 32px 40px;
  order: 2;
}

body.dashboard-page {
  background: #1a2332;
}

body.dashboard-page .container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

body.dashboard-page h1,
body.dashboard-page h2,
body.dashboard-page h3,
body.dashboard-page h4,
body.dashboard-page h5,
body.dashboard-page h6 {
  color: #e2e8f0;
}

body.dashboard-page .dark-card {
  background: #2d3748;
  border: 1px solid #3d4958;
  border-radius: 12px;
  padding: 25px;
  margin-bottom: 30px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

body.dashboard-page .dark-card h3 {
  margin-top: 0;
  margin-bottom: 20px;
  border-bottom: 2px solid #3d4958;
  padding-bottom: 10px;
  color: #e2e8f0;
}

body.dashboard-page .stat-card {
  background: #2d3748;
  border: 1px solid #3d4958;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: all 0.3s;
  text-align: center;
}

body.dashboard-page .stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

body.dashboard-page .stats-grid {
  gap: 20px;
  margin-bottom: 30px;
}

body.dashboard-page .stat-icon {
  font-size: clamp(20px, 2.6vw, 28px);
  margin-bottom: 8px;
}

body.dashboard-page .stat-label {
  color: #a0aec0;
  font-size: clamp(12px, 1.2vw, 14px);
  margin-bottom: 8px;
}

body.dashboard-page .stat-value {
  color: #fff;
  font-size: clamp(22px, 3vw, 32px);
  font-weight: 700;
}

body.dashboard-page .action-btn {
  background: #2d3748;
  border: 1px solid #3d4958;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  color: #e2e8f0;
  text-decoration: none;
  display: block;
  transition: all 0.3s;
}

body.dashboard-page .action-btn:hover {
  background: #3d4958;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  color: #fff;
}

body.dashboard-page .quick-actions {
  gap: 15px;
}

body.dashboard-page .table-dark {
  width: 100%;
  border-collapse: collapse;
  background: #2d3748;
  color: #e2e8f0;
}

body.dashboard-page .table-dark th {
  background: #1a2332;
  color: #cbd5e0;
  border-bottom: 2px solid #3d4958;
  padding: 12px;
  text-align: right;
}

body.dashboard-page .table-dark td {
  border-bottom: 1px solid #3d4958;
  padding: 12px;
  color: #e2e8f0;
}

body.dashboard-page .table-dark tr:hover {
  background: #3d4958;
}

body.dashboard-page .badge {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

body.dashboard-page .badge-new {
  background: #2c5aa0;
  color: white;
}

body.dashboard-page .badge-in-progress {
  background: #dd6b20;
  color: white;
}

body.dashboard-page .badge-pending {
  background: #b83280;
  color: white;
}

body.dashboard-page .badge-completed {
  background: #25855a;
  color: white;
}

body.dashboard-page .badge-cancelled {
  background: #c53030;
  color: white;
}

body.dashboard-page .badge-high {
  background: #c53030;
  color: white;
}

body.dashboard-page .badge-medium {
  background: #dd6b20;
  color: white;
}

body.dashboard-page .badge-low {
  background: #25855a;
  color: white;
}

body.dashboard-page .badge-official {
  background: #2c5aa0;
  color: white;
}

body.dashboard-page .badge-verbal {
  background: #805ad5;
  color: white;
}

body.dashboard-page .badge-initiative {
  background: #00b5d8;
  color: white;
}

body.dashboard-page .badge-team {
  background: #d69e2e;
  color: white;
}

body.dashboard-page .badge-primary {
  background: #3182ce;
  color: white;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

body.dashboard-page .badge-success {
  background: #48bb78;
  color: white;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

body.dashboard-page .badge-warning {
  background: #ed8936;
  color: white;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

body.dashboard-page .badge-danger {
  background: #f56565;
  color: white;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

body.dashboard-page .btn {
  padding: 8px 16px;
  min-height: 44px;
  border-radius: 6px;
  border: none;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
}

body.dashboard-page .btn-primary {
  background: #3182ce;
  color: white;
}

body.dashboard-page .btn-primary:hover {
  background: #2c5aa0;
}

body.dashboard-page .btn-success {
  background: #48bb78;
  color: white;
}

body.dashboard-page .btn-success:hover {
  background: #38a169;
}

body.dashboard-page .btn-danger {
  background: #f56565;
  color: white;
}

body.dashboard-page .btn-danger:hover {
  background: #e53e3e;
}

body.dashboard-page .empty-state {
  text-align: center;
  color: #718096;
  padding: 40px;
}

body.dashboard-page .empty-state-icon {
  font-size: 48px;
  margin-bottom: 10px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  margin-bottom: 24px;
}

.header h1 {
  font-size: clamp(22px, 2.4vw, 30px);
  margin: 0;
}

.header p {
  margin: 4px 0 0;
  color: var(--muted);
}

.form {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
  align-items: end;
}

.form-wide {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.form input,
.form select,
.form textarea {
  width: 100%;
  padding: 12px 14px;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: #101923;
  color: var(--text);
  text-align: right;
  direction: rtl;
  font-size: 14px;
}

.login-form input {
  width: 100%;
  padding: 12px 14px;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: #111a25;
  color: var(--text);
  text-align: right;
  direction: rtl;
  font-size: 14px;
}

.form textarea {
  grid-column: span 2;
  min-height: 44px;
  resize: vertical;
}

.button {
  padding: 12px 20px;
  min-height: 48px;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 30px var(--glow);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px var(--glow);
}

.button-danger {
  background: var(--high);
  box-shadow: 0 10px 30px rgba(239, 68, 68, 0.25);
  padding: 6px 12px;
  font-size: 13px;
}

.button-danger:hover {
  box-shadow: 0 14px 30px rgba(239, 68, 68, 0.35);
}

.button-success {
  background: var(--success);
  box-shadow: 0 10px 30px rgba(34, 197, 94, 0.25);
}

.button-success:hover {
  box-shadow: 0 14px 30px rgba(34, 197, 94, 0.35);
}

.panel {
  background: rgba(13, 20, 30, 0.65);
  border: 1px solid var(--stroke);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: rgba(11, 17, 27, 0.8);
  border: 1px solid var(--stroke);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.stat-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: clamp(12px, 1.2vw, 14px);
}

.stat-value {
  margin: 0;
  font-size: clamp(20px, 2.6vw, 32px);
  font-weight: 700;
}

.stat-trend {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  opacity: 0.8;
}

.section {
  background: rgba(13, 20, 30, 0.65);
  border: 1px solid var(--stroke);
  border-radius: 18px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.section h2 {
  margin: 0 0 16px;
  font-size: clamp(16px, 1.8vw, 20px);
  font-weight: 600;
  color: var(--text);
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--stroke);
  text-decoration: none;
  color: var(--text);
  font-weight: 500;
  transition: all 0.2s ease;
  min-height: 52px;
}

.action-btn:hover {
  background: rgba(43, 127, 255, 0.08);
  border-color: rgba(43, 127, 255, 0.3);
}

.action-btn.primary {
  background: rgba(43, 127, 255, 0.12);
  border-color: rgba(43, 127, 255, 0.3);
}

.action-btn.primary:hover {
  background: rgba(43, 127, 255, 0.18);
}

.action-btn .icon {
  font-size: 20px;
}

.tasks-list {
  display: grid;
  gap: 10px;
}

.task-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  transition: all 0.2s ease;
}

.task-item:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(43, 127, 255, 0.3);
}

.task-info {
  flex: 1;
}

.task-title {
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}

.task-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
}

.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.task-status {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.task-status.status-new {
  background: rgba(43, 127, 255, 0.15);
  color: #5a9fff;
}

.task-status.status-in_progress {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.task-status.status-pending_review {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
}

.task-status.status-completed {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}

.task-status.status-cancelled {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.org-units-list {
  display: grid;
  gap: 10px;
}

.org-unit-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--stroke);
  border-radius: 12px;
}

.unit-name {
  font-weight: 600;
  color: var(--text);
}

.unit-stats {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--muted);
}

.unit-stat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.panel h2 {
  margin: 0 0 16px;
  font-size: 18px;
}

.board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  animation: fadeIn 0.6s ease;
}

.column {
  background: rgba(12, 18, 28, 0.7);
  border: 1px solid var(--stroke);
  border-radius: 18px;
  padding: 12px;
  min-height: 360px;
}

.column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 6px 14px;
}

.column h3 {
  margin: 0;
  font-size: 16px;
  color: var(--muted);
}

.count {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--stroke);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  color: var(--text);
}

.card {
  background: linear-gradient(160deg, rgba(29, 40, 55, 0.95), rgba(20, 29, 41, 0.95));
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 12px;
  animation: slideUp 0.3s ease;
  cursor: pointer;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.25);
}

.card h4 {
  margin: 0 0 6px;
  font-size: 15px;
}

.card p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.08);
}

.badge.low {
  color: var(--low);
}

.badge.medium {
  color: var(--mid);
}

.badge.high {
  color: var(--high);
}

.badge.status {
  color: var(--accent);
}

.assigned {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th,
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--stroke);
  text-align: right;
}

.table th {
  color: var(--muted);
  font-weight: 600;
}

.table-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.button.button-sm {
  padding: 6px 10px;
  min-height: 36px;
  font-size: 12px;
  border-radius: 10px;
}

.team-members {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.member-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--stroke);
  color: var(--text);
  font-size: 12px;
}

.chip-remove {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0 4px;
  font-size: 14px;
  line-height: 1;
}

.chip-remove:hover {
  color: var(--high);
}

.login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  width: min(360px, 90vw);
  background: rgba(13, 20, 30, 0.8);
  border: 1px solid var(--stroke);
  border-radius: 20px;
  padding: 28px;
  text-align: right;
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0 0 8px;
}

.login-card p {
  margin: 0 0 20px;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 12px;
}

.alert {
  background: rgba(239, 68, 68, 0.15);
  color: #fecaca;
  padding: 10px 12px;
  border-radius: 12px;
  margin-bottom: 12px;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(7, 11, 17, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 10;
}

.modal.active {
  display: flex;
}

.modal-card {
  width: min(880px, 92vw);
  max-height: 90vh;
  overflow: auto;
  background: rgba(15, 22, 32, 0.96);
  border: 1px solid var(--stroke);
  border-radius: 20px;
  padding: 24px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.modal-actions.empty {
  color: var(--muted);
  font-size: 13px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.modal-section {
  background: rgba(9, 14, 21, 0.5);
  border: 1px solid var(--stroke);
  border-radius: 14px;
  padding: 14px;
}

.modal-section h4 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--muted);
}

.modal-list {
  display: grid;
  gap: 8px;
  font-size: 13px;
}

.modal-close {
  background: transparent;
  border: 1px solid var(--stroke);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
}

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

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

@media (max-width: 1280px) {
  .main {
    padding: 24px 24px 36px;
  }

  .form {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1024px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar-open {
    overflow: hidden;
  }

  .topbar {
    display: flex;
    justify-content: center;
    position: sticky;
  }

  .sidebar-toggle-mobile {
    display: inline-flex !important;
    position: absolute;
    right: 12px;
    left: auto;
    top: 50%;
    transform: translateY(-50%);
    z-index: 60;
  }

  .sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    width: var(--sidebar-mobile-width);
    max-width: 85vw;
    height: 100vh;
    border-left: 1px solid var(--stroke);
    border-bottom: none;
    transform: translateX(calc(100% + 12px));
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 55;
    padding: 20px 18px;
    box-shadow: var(--shadow);
    will-change: transform;
  }

  .sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-footer {
    position: static;
    margin-top: 16px;
  }

  .brand {
    margin-bottom: 20px;
  }

  .nav {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .nav a {
    flex-direction: row;
    justify-content: flex-start;
    text-align: right;
    padding: 10px 12px;
    font-size: 13px;
    gap: 6px;
  }

  .main {
    padding: 20px 16px 32px;
  }

  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form textarea {
    grid-column: span 2;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .table th,
  .table td {
    padding: 8px 10px;
  }

  .modal-card {
    padding: 18px;
  }

  .modal-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 1024px) and (orientation: landscape) {
  .topbar {
    padding: 8px 12px;
  }

  .sidebar {
    width: min(70vw, 360px);
  }

  .main {
    padding: 16px 14px 24px;
  }

  .stats-grid,
  .quick-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .main {
    padding: 18px 14px 28px;
  }

  .quick-actions {
    grid-template-columns: 1fr;
  }

  .task-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .unit-stats {
    flex-wrap: wrap;
    gap: 8px;
  }
}

@media (min-width: 1025px) {
  .topbar {
    display: none;
  }

  .sidebar-toggle-mobile {
    display: none;
  }

  body:not(.sidebar-open) .app {
    --sidebar-width: var(--sidebar-collapsed);
  }

  .sidebar-overlay {
    display: none;
  }

  .stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .nav a {
    font-size: 12px;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .header h1 {
    font-size: 22px;
  }

  .form {
    grid-template-columns: 1fr;
  }

  .form-wide {
    grid-template-columns: 1fr;
  }

  .form textarea {
    grid-column: span 1;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .quick-actions {
    grid-template-columns: 1fr;
  }

  .table {
    font-size: 13px;
  }

  .modal {
    padding: 12px;
  }

  .modal-card {
    width: 100%;
    max-height: 92vh;
  }

  .main table thead,
  .table-wrap .table thead,
  .table-responsive .table thead,
  .table-wrap .table-dark thead,
  .table-responsive .table-dark thead {
    display: none;
  }

  .main table,
  .main table tbody,
  .main table tr,
  .main table td,
  .table-wrap .table,
  .table-wrap .table tbody,
  .table-wrap .table tr,
  .table-wrap .table td,
  .table-responsive .table,
  .table-responsive .table tbody,
  .table-responsive .table tr,
  .table-responsive .table td,
  .table-wrap .table-dark,
  .table-wrap .table-dark tbody,
  .table-wrap .table-dark tr,
  .table-wrap .table-dark td,
  .table-responsive .table-dark,
  .table-responsive .table-dark tbody,
  .table-responsive .table-dark tr,
  .table-responsive .table-dark td {
    display: block;
    width: 100%;
  }

  .main table tr,
  .table-wrap .table tr,
  .table-responsive .table tr {
    border: 1px solid var(--stroke);
    border-radius: 12px;
    margin-bottom: 12px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.02);
  }

  .main table.table-dark tr,
  .table-wrap .table-dark tr,
  .table-responsive .table-dark tr {
    border-color: #3d4958;
    background: #2d3748;
  }

  .main table td,
  .table-wrap .table td,
  .table-responsive .table td,
  .main table.table-dark td,
  .table-wrap .table-dark td,
  .table-responsive .table-dark td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--stroke);
  }

  .main table.table-dark td,
  .table-wrap .table-dark td,
  .table-responsive .table-dark td {
    border-bottom-color: #3d4958;
  }

  .main table td::before,
  .table-wrap .table td::before,
  .table-responsive .table td::before,
  .main table.table-dark td::before,
  .table-wrap .table-dark td::before,
  .table-responsive .table-dark td::before {
    content: attr(data-label);
    color: #a0aec0;
    font-weight: 600;
    font-size: 12px;
  }

  .main table td:last-child,
  .table-wrap .table td:last-child,
  .table-responsive .table td:last-child,
  .main table.table-dark td:last-child,
  .table-wrap .table-dark td:last-child,
  .table-responsive .table-dark td:last-child {
    border-bottom: none;
  }
}
