:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #172033;
  --muted: #667085;
  --line: #d9e2ec;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --blue: #2563eb;
  --red: #dc2626;
  --amber: #b45309;
  --green: #15803d;
  --purple: #7c3aed;
  --shadow: 0 14px 40px rgba(23, 32, 51, 0.08);
}

[data-theme="dark"] {
  --bg: #111827;
  --panel: #172033;
  --panel-soft: #1f2937;
  --text: #f8fafc;
  --muted: #b8c2d1;
  --line: #334155;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(rgba(17,31,46,.72), rgba(17,31,46,.72)),
    radial-gradient(circle at top left, #0f766e, transparent 34%),
    var(--bg);
}

.login-card {
  width: min(430px, 100%);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(0,0,0,.22);
  padding: 26px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.login-brand h1 {
  margin: 0;
  font-size: 24px;
}

.login-brand p,
.forgot-text {
  margin: 0;
  color: var(--muted);
}

.forgot-text {
  font-size: 13px;
  margin-bottom: 14px;
}

.app-shell {
  display: grid;
  grid-template-columns: 270px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #111f2e;
  color: #f8fafc;
  padding: 22px 16px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.brand-logo {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 10px;
  background: var(--brand);
  font-weight: 800;
  overflow: hidden;
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-block h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.1;
}

.brand-block span {
  color: #b8c7d9;
  font-size: 12px;
}

.sidebar-nav {
  display: grid;
  gap: 6px;
}

.nav-link-button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  color: #c8d5e3;
  background: transparent;
  text-align: left;
}

.nav-link-button.active,
.nav-link-button:hover {
  color: #ffffff;
  background: rgba(255,255,255,0.11);
}

.main { min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
}

.searchbar {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(620px, 100%);
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.searchbar input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-badge {
  display: grid;
  gap: 1px;
  min-width: 150px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  font-size: 12px;
  line-height: 1.2;
}

.user-badge strong {
  font-size: 13px;
}

.password-strength {
  font-size: 12px;
  margin-top: 4px;
}

.icon-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}

.notify-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
}

.content { padding: 24px; }

.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.view-header h2 {
  margin: 0 0 4px;
  font-size: 28px;
}

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

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 16px;
}

.metric-card span {
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-header h3 {
  margin: 0;
  font-size: 17px;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.chart-box {
  height: 320px;
  padding: 16px;
}

.table-wrap { overflow-x: auto; }

.app-table {
  width: 100%;
  border-collapse: collapse;
}

.app-table th,
.app-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 14px;
}

.app-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
}

.badge-soft {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-open, .status-assigned { color: #1d4ed8; background: #dbeafe; }
.status-in-progress { color: #92400e; background: #fef3c7; }
.status-waiting-for-user, .status-on-hold { color: #7c2d12; background: #ffedd5; }
.status-resolved, .status-closed { color: #166534; background: #dcfce7; }
.priority-critical { color: #991b1b; background: #fee2e2; }
.priority-high { color: #9a3412; background: #ffedd5; }
.priority-medium { color: #854d0e; background: #fef9c3; }
.priority-low { color: #166534; background: #dcfce7; }

.filter-grid,
.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

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

.form-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.pagination-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  color: var(--muted);
}

.toast-host {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1200;
  display: grid;
  gap: 8px;
}

.app-toast {
  min-width: 260px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  box-shadow: var(--shadow);
  animation: slideIn .22s ease-out;
}

.loader-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  background: rgba(244,247,251,.82);
}

.loader-overlay.hidden { display: none; }

.empty-state {
  padding: 34px;
  color: var(--muted);
  text-align: center;
}

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

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    gap: 14px;
    overflow-x: auto;
    padding: 12px;
  }
  .brand-block { min-width: 220px; margin: 0; }
  .sidebar-nav { display: flex; gap: 8px; }
  .nav-link-button { min-width: 138px; }
  .topbar, .view-header { flex-direction: column; align-items: stretch; }
  .filter-grid, .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2, .form-grid .span-4 { grid-column: span 1; }
}
