:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-soft: #dbeafe;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --purple: #7c3aed;
  --shadow: 0 20px 60px rgba(15, 23, 42, 0.08);
  --radius: 24px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 20%, rgba(37, 99, 235, 0.11), transparent 28%),
    radial-gradient(circle at 85% 15%, rgba(124, 58, 237, 0.10), transparent 25%),
    var(--bg);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px;
  background: #0f172a;
  color: white;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  color: white;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark,
.login-logo {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(135deg, #60a5fa, #2563eb);
  font-weight: 900;
  letter-spacing: -0.05em;
}

.brand small,
.user-card small {
  display: block;
  color: #94a3b8;
  margin-top: 2px;
}

.nav { display: grid; gap: 10px; }
.nav a,
.logout-form button {
  border: 0;
  color: #cbd5e1;
  background: transparent;
  border-radius: 16px;
  padding: 14px 16px;
  text-align: left;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
}
.nav a:hover,
.logout-form button:hover { color: white; background: rgba(255, 255, 255, 0.10); }

.user-card {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
}

.avatar {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  font-weight: 900;
}

.logout-form { margin: 0; }
.logout-form button { width: 100%; }

.main {
  padding: 32px;
  max-width: 1480px;
  width: 100%;
}

.main-login {
  grid-column: 1 / -1;
  min-height: 100vh;
  display: grid;
  place-items: center;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: clamp(30px, 4vw, 46px); letter-spacing: -0.04em; }
h2 { font-size: 22px; letter-spacing: -0.02em; }
p { color: var(--muted); line-height: 1.5; }

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

.panel,
.login-card,
.stat {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(229, 231, 235, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel { padding: 24px; }
.narrow { max-width: 860px; }

.login-card {
  width: min(440px, calc(100vw - 32px));
  padding: 32px;
}
.login-logo { color: white; margin-bottom: 18px; }
.hint,
.alert {
  margin-top: 16px;
  border-radius: 16px;
  padding: 14px;
  line-height: 1.45;
  color: #475569;
  background: #f8fafc;
  border: 1px solid var(--line);
}
.alert { color: #991b1b; background: #fee2e2; border-color: #fecaca; }

.form { display: grid; gap: 16px; }
.compact-form { gap: 12px; }
label { display: grid; gap: 8px; font-weight: 800; font-size: 14px; }

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px 14px;
  font: inherit;
  color: var(--text);
  background: white;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(37, 99, 235, 0.7);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.10);
}
textarea { resize: vertical; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 16px;
  padding: 13px 18px;
  font-weight: 900;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.primary { color: white; background: linear-gradient(135deg, var(--blue), var(--purple)); box-shadow: 0 14px 30px rgba(37, 99, 235, 0.20); }
.ghost { color: #334155; background: #f1f5f9; }

.messages { display: grid; gap: 10px; margin-bottom: 18px; }
.message { padding: 14px 16px; border-radius: 16px; background: #dbeafe; color: #1e40af; font-weight: 800; }
.message.success { background: #dcfce7; color: #166534; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat { padding: 20px; }
.stat span { color: var(--muted); font-weight: 800; }
.stat b { display: block; margin-top: 8px; font-size: 34px; letter-spacing: -0.04em; }

.filters {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 190px 120px;
  gap: 12px;
  margin-bottom: 18px;
}
.admin-filters { grid-template-columns: minmax(260px, 1fr) 160px 160px 160px 190px 170px 120px; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 18px; }
table { width: 100%; border-collapse: collapse; min-width: 980px; background: white; }
th, td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
th { color: #475569; background: #f8fafc; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f8fafc; }

.chip,
.status,
.priority {
  display: inline-flex;
  padding: 6px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}
.category { background: #e0e7ff; color: #3730a3; }
.priority.critical { color: #991b1b; background: #fee2e2; }
.priority.normal { color: #92400e; background: #fef3c7; }
.priority.low { color: #475569; background: #f1f5f9; }
.status.new { color: #991b1b; background: #fee2e2; }
.status.in_progress { color: #1e40af; background: #dbeafe; }
.status.waiting { color: #92400e; background: #fef3c7; }
.status.resolved { color: #166534; background: #dcfce7; }

.cards-list { display: grid; gap: 12px; }
.ticket-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--text);
  text-decoration: none;
  background: white;
}
.ticket-card:hover { border-color: #bfdbfe; background: #eff6ff; }
.ticket-card small { display: block; color: var(--muted); margin-top: 5px; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; margin-bottom: 22px; }
.ticket-meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 22px; }
.ticket-meta div { padding: 14px; border-radius: 16px; border: 1px solid var(--line); background: #f8fafc; }
.ticket-meta span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; font-weight: 900; text-transform: uppercase; }
.description { padding: 18px; border-radius: 18px; background: white; border: 1px solid var(--line); line-height: 1.6; }
.attachment { display: inline-block; margin-top: 12px; font-weight: 800; }
.attachment a { color: var(--blue-dark); }

.chat-panel { margin-bottom: 32px; }
.chat { display: grid; gap: 12px; margin-bottom: 18px; }
.chat-msg { max-width: 760px; padding: 14px; border-radius: 18px; background: #f8fafc; border: 1px solid var(--line); }
.chat-msg.mine { margin-left: auto; background: #eff6ff; border-color: #bfdbfe; }
.chat-msg.system { max-width: 100%; background: #f1f5f9; color: #475569; }
.chat-head { display: flex; justify-content: space-between; gap: 14px; margin-bottom: 6px; }
.chat-head small { color: var(--muted); }
.chat-text { line-height: 1.55; }
.chat-form { margin-top: 12px; }
.chat-actions { display: grid; grid-template-columns: 1fr 160px; gap: 12px; align-items: center; }

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

@media (max-width: 1180px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .nav { display: flex; flex-wrap: wrap; }
  .user-card { margin-top: 0; margin-left: auto; }
  .logout-form { width: auto; }
  .admin-filters, .filters { grid-template-columns: 1fr 1fr; }
  .detail-grid, .ticket-meta { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .main, .sidebar { padding: 18px; }
  .page-header { flex-direction: column; }
  .grid-2, .stats, .filters, .admin-filters, .chat-actions { grid-template-columns: 1fr; }
  .ticket-card { align-items: flex-start; flex-direction: column; }
}
