/* ── Variables ──────────────────────────────────────────────────────────── */
:root {
  --bg:          #0a0c14;
  --surface:     #111420;
  --surface2:    #181c2e;
  --surface3:    #1e2338;
  --border:      #1e2236;
  --accent:      #4a7fff;
  --accent-dim:  rgba(74, 127, 255, 0.12);
  --accent-glow: rgba(74, 127, 255, 0.25);
  --text:        #e2e6f3;
  --text-muted:  #6b7099;
  --text-subtle: #454970;
  --green:       #22c55e;
  --green-dim:   rgba(34, 197, 94, 0.12);
  --amber:       #f59e0b;
  --amber-dim:   rgba(245, 158, 11, 0.12);
  --orange:      #f97316;
  --orange-dim:  rgba(249, 115, 22, 0.12);
  --red:         #ef4444;
  --red-dim:     rgba(239, 68, 68, 0.12);
  --blue-dim:    rgba(74, 127, 255, 0.12);
  --radius:      10px;
  --radius-sm:   6px;
  --sidebar-w:   230px;
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ─────────────────────────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
}

.sidebar-logo {
  padding: 24px 20px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.brand {
  font-size: 26px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.5px;
}

.brand .dot {
  color: #4f7cff;
}

.sidebar-company {
  padding: 10px 20px 16px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  list-style: none;
  padding: 4px 10px;
  flex: 1;
}

.sidebar-nav li { margin-bottom: 2px; }

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.sidebar-nav a:hover {
  background: var(--surface2);
  color: var(--text);
  text-decoration: none;
}

.sidebar-nav a.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
}

.nav-icon {
  font-size: 1rem;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logout-btn {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  text-align: center;
  transition: color 0.15s, border-color 0.15s;
}

.logout-btn:hover {
  color: var(--red);
  border-color: var(--red);
  text-decoration: none;
}

/* ── Main content ───────────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  padding: 36px 40px;
  max-width: 1200px;
}

/* ── Page header ────────────────────────────────────────────────────────── */
.page-header {
  margin-bottom: 32px;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.3px;
  margin-bottom: 4px;
}

.page-sub {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.card-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ── Summary stat cards ─────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: -0.5px;
  line-height: 1;
  color: var(--text);
  margin-bottom: 4px;
}

.stat-value.accent  { color: var(--accent); }
.stat-value.green   { color: var(--green); }
.stat-value.amber   { color: var(--amber); }
.stat-value.red     { color: var(--red); }

.stat-note {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── Content grid ───────────────────────────────────────────────────────── */
.content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

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

/* ── Tables ─────────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th {
  padding: 10px 14px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }

tr:hover td { background: var(--surface2); }

td a {
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
}

td a:hover { color: var(--accent); text-decoration: none; }

/* ── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* Status */
.badge-open              { background: var(--blue-dim);   color: var(--accent); }
.badge-in_progress       { background: var(--amber-dim);  color: var(--amber); }
.badge-waiting_on_client { background: var(--orange-dim); color: var(--orange); }
.badge-resolved          { background: var(--green-dim);  color: var(--green); }

/* Priority */
.badge-low    { background: var(--surface3); color: var(--text-muted); }
.badge-medium { background: var(--blue-dim); color: var(--accent); }
.badge-high   { background: var(--orange-dim); color: var(--orange); }
.badge-urgent { background: var(--red-dim);    color: var(--red); }

/* Plan / payment */
.badge-active   { background: var(--green-dim); color: var(--green); }
.badge-past_due { background: var(--red-dim);   color: var(--red); }

/* ── Status dot ─────────────────────────────────────────────────────────── */
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-online   { background: var(--green);  box-shadow: 0 0 5px rgba(34,197,94,.5); }
.status-degraded { background: var(--amber);  box-shadow: 0 0 5px rgba(245,158,11,.5); }
.status-offline  { background: var(--red);    box-shadow: 0 0 5px rgba(239,68,68,.5); }

/* ── Monitoring items ───────────────────────────────────────────────────── */
.monitor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.monitor-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: border-color 0.15s;
}

.monitor-card:hover { border-color: var(--accent); }

.monitor-icon {
  font-size: 1.2rem;
  color: var(--text-muted);
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.monitor-info { flex: 1; min-width: 0; }

.monitor-name {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.monitor-type {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: capitalize;
}

/* ── Forms ──────────────────────────────────────────────────────────────── */
.form-wrap {
  max-width: 640px;
}

.form-group {
  margin-bottom: 18px;
}

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  padding: 10px 13px;
  outline: none;
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}

input::placeholder, textarea::placeholder {
  color: var(--text-subtle);
}

select option { background: var(--surface2); }

textarea { resize: vertical; min-height: 130px; }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 9px 18px;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  transition: opacity 0.15s, transform 0.12s, border-color 0.15s;
  white-space: nowrap;
}

.btn:hover { opacity: 0.88; transform: translateY(-1px); text-decoration: none; }

.btn-primary  { background: var(--accent); color: #fff; }
.btn-ghost    { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); opacity: 1; }
.btn-danger   { background: transparent; color: var(--red); border-color: var(--red); }

/* ── Alert / error ──────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 20px;
}

.alert-error {
  background: var(--red-dim);
  border: 1px solid var(--red);
  color: var(--red);
}

/* ── Ticket detail ──────────────────────────────────────────────────────── */
.ticket-meta {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.ticket-meta-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ticket-meta-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  font-weight: 600;
}

.ticket-body {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.75;
  white-space: pre-wrap;
  margin-bottom: 32px;
}

/* ── Comments ───────────────────────────────────────────────────────────── */
.comments { display: flex; flex-direction: column; gap: 16px; }

.comment {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}

.comment-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.comment-author {
  font-size: 0.8rem;
  font-weight: 700;
}

.comment-role {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 100px;
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
}

.comment-role.admin { background: var(--orange-dim); color: var(--orange); }

.comment-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-left: auto;
}

.comment-body {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.7;
  white-space: pre-wrap;
}

/* ── Billing ────────────────────────────────────────────────────────────── */
.billing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.plan-card {
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 28px;
  position: relative;
  overflow: hidden;
}

.plan-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 200px; height: 200px;
  background: radial-gradient(circle at top right, rgba(74,127,255,0.08), transparent 60%);
  pointer-events: none;
}

.plan-name {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 8px;
}

.plan-price {
  font-size: 2.4rem;
  font-weight: 900;
  letter-spacing: -1px;
  line-height: 1;
  margin-bottom: 4px;
}

.plan-price sup { font-size: 1rem; vertical-align: top; margin-top: 6px; }
.plan-price sub { font-size: 0.85rem; font-weight: 400; color: var(--text-muted); }

.plan-details {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.plan-detail-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.plan-detail-row:last-child { border-bottom: none; }
.plan-detail-label { color: var(--text-muted); }
.plan-detail-value { font-weight: 600; }

.coming-soon-card {
  background: var(--surface2);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

.coming-soon-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-subtle);
  background: var(--surface3);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 100px;
}

.coming-soon-title {
  font-size: 1rem;
  font-weight: 700;
}

.coming-soon-body {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.7;
}

/* ── Section divider ────────────────────────────────────────────────────── */
.section-sep {
  border: none;
  border-top: 1px solid var(--border);
  margin: 28px 0;
}

/* ── Empty state ────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state p { margin-bottom: 16px; }

/* ── Toolbar / filter row ───────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

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

.filter-btn {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 13px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.filter-btn:hover { color: var(--text); border-color: var(--accent); text-decoration: none; }
.filter-btn.active { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }

/* ── Login page ─────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}

.login-box {
  width: 100%;
  max-width: 400px;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo a {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.3px;
}

.login-logo a span { color: var(--accent); }

.login-tagline {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}

.login-card h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 24px;
}

.login-card .btn-primary {
  width: 100%;
  justify-content: center;
  padding: 11px;
  font-size: 0.9rem;
  margin-top: 4px;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .content-grid,
  .content-grid.wide,
  .billing-grid { grid-template-columns: 1fr; }

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

@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    min-height: auto;
    position: relative;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 12px 16px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-logo  { padding: 0; border: none; margin: 0; }
  .sidebar-company { display: none; }

  .sidebar-nav {
    display: flex;
    padding: 0;
    flex-wrap: wrap;
    flex: 1;
    justify-content: center;
  }

  .sidebar-nav li { margin: 0; }

  .sidebar-nav a {
    padding: 6px 10px;
    font-size: 0.78rem;
    gap: 5px;
  }

  .sidebar-footer {
    padding: 0 0 0 12px;
    border-top: none;
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .sidebar-user { display: none; }

  .layout { flex-direction: column; }
  .main { margin-left: 0; padding: 20px 16px; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .monitor-grid { grid-template-columns: 1fr; }
  .ticket-meta { gap: 14px; }
}
