:root {
  --topbar-bg: #161616;
  --sidebar-bg: #262626;
  --sidebar-text: #b9b9b9;
  --sidebar-active: #2f80c3;
  --bg: #eef0f2;
  --card: #ffffff;
  --text: #333a40;
  --muted: #8a939b;
  --border: #e3e6e9;
  --blue: #2f80c3;
  --blue-dark: #266ba5;
  --teal: #38b2a7;      /* Delivered */
  --gold: #b8860b;      /* Hard Bounce */
  --gold-soft: #d9a93f; /* Soft Bounce */
  --red: #c0392b;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Topbar ---------- */
.topbar {
  height: 48px;
  background: var(--topbar-bg);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand {
  font-weight: 800;
  font-size: 17px;
  letter-spacing: .5px;
  color: #fff;
}
.brand span { color: var(--blue); font-weight: 800; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.topbar-user { color: #ddd; font-size: 13px; }
.btn-logout {
  color: #fff;
  background: var(--blue);
  padding: 5px 14px;
  border-radius: 4px;
  font-size: 13px;
}
.btn-logout:hover { background: var(--blue-dark); text-decoration: none; }
.hamburger {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
}

/* ---------- Shell / Sidebar ---------- */
.shell { display: flex; min-height: calc(100vh - 48px); }
.sidebar {
  width: 190px;
  background: var(--sidebar-bg);
  padding-top: 10px;
  flex-shrink: 0;
}
.side-item {
  display: block;
  color: var(--sidebar-text);
  padding: 11px 18px;
  font-size: 13.5px;
  border-left: 3px solid transparent;
}
.side-item:hover { color: #fff; text-decoration: none; background: #303030; }
.side-item.active {
  background: var(--sidebar-active);
  color: #fff;
  border-left-color: #7cc4f5;
}
.side-ico { margin-right: 6px; }
.side-sub { padding-left: 34px; font-size: 13px; }
.side-group {
  color: #7d7d7d;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 14px 18px 4px;
}

/* ---------- Content ---------- */
.content { flex: 1; padding: 20px 24px; min-width: 0; }
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 10px;
  flex-wrap: wrap;
}
.page-head h1 { font-size: 19px; margin: 0; font-weight: 600; }
.muted { color: var(--muted); font-weight: 400; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 18px;
}
.card-title { font-size: 15px; margin: 0 0 12px; font-weight: 600; }

/* ---------- Dashboard stats ---------- */
.stat-row { display: flex; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.stat-usage, .stat-kpi {
  flex: 1;
  min-width: 170px;
  text-align: center;
  padding: 18px 14px;
}
.usage-count { font-size: 30px; font-weight: 700; color: var(--blue); }
.usage-label, .kpi-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .05em;
  margin-top: 6px;
}
.kpi-num { font-size: 26px; font-weight: 600; }
.kpi-tag {
  font-size: 10px;
  font-weight: 700;
  vertical-align: super;
  padding: 2px 6px;
  border-radius: 3px;
  color: #fff;
}
.tag-good { background: #3aa757; }
.tag-fair { background: var(--gold-soft); }
.tag-poor { background: var(--red); }
.chart-card { position: relative; }
.chart-legend-note { position: absolute; top: 14px; left: 16px; font-size: 12px; color: var(--muted); }

/* ---------- Filters ---------- */
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}
.filters select, .filters input[type="text"], .filters input[type="date"] {
  padding: 8px 10px;
  border: 1px solid #cfd6db;
  border-radius: 4px;
  font-size: 13px;
  background: #fff;
  color: var(--text);
}
.search-input { flex: 1; min-width: 200px; }
.btn-primary {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 8px 18px;
  font-size: 13px;
  cursor: pointer;
}
.btn-primary:hover { background: var(--blue-dark); }
.btn-secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid #cfd6db;
  border-radius: 4px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  display: inline-block;
}
.btn-secondary:hover { background: #f5f7f9; text-decoration: none; }

/* ---------- Table ---------- */
.table-scroll { overflow-x: auto; }
.log-table { width: 100%; border-collapse: collapse; }
.log-table th {
  text-align: left;
  padding: 12px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.log-table td {
  padding: 10px 12px;
  font-size: 13px;
  border-bottom: 1px solid #eef1f3;
  vertical-align: middle;
}
.log-table tbody tr:nth-child(even) td { background: #f7f9fa; }
.activity-table tbody tr { cursor: pointer; }
.activity-table tbody tr:hover td { background: #eef5fb; }
.nowrap { white-space: nowrap; }
.time-dim { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.link-like { color: var(--blue); }
.subject-cell { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 34px; }
.total-row td { border-top: 2px solid var(--border); background: #fafbfc !important; }
.text-hard { color: var(--gold); font-weight: 600; }
.text-soft { color: var(--gold-soft); font-weight: 600; }

/* ---------- Badges (SMTP2GO stili) ---------- */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 3px;
  font-size: 11.5px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}
.badge-delivered { background: var(--teal); }
.badge-hard { background: var(--gold); }
.badge-soft { background: var(--gold-soft); }
.badge-neutral { background: #9aa4ad; }

/* ---------- Pager ---------- */
.pager {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  padding-top: 14px;
}
.pager-info { color: var(--muted); font-size: 13px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 100;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 16px 16px;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: #fff;
  border-radius: 6px;
  max-width: 720px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 18px 22px;
  box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
}
.modal-sub { color: var(--muted); font-size: 13px; margin: 6px 0 14px; }
.modal-foot { text-align: right; margin-top: 16px; }
.detail-table { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.detail-table th, .detail-table td {
  text-align: left;
  padding: 8px 10px;
  font-size: 13px;
  border-bottom: 1px solid #eef1f3;
  word-break: break-word;
}
.detail-table th { font-weight: 600; background: #f7f9fa; }
.detail-key { font-weight: 600; width: 130px; }
.timeline-title { margin: 16px 0 8px; font-size: 14px; }

/* ---------- Login ---------- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--topbar-bg);
}
.login-box {
  background: #fff;
  padding: 34px 30px;
  border-radius: 8px;
  width: 320px;
  text-align: center;
}
.login-logo { font-weight: 800; font-size: 20px; margin-bottom: 22px; letter-spacing: .5px; }
.login-logo span { color: var(--blue); }
.login-box input {
  width: 100%;
  padding: 11px;
  margin-bottom: 12px;
  border: 1px solid #cfd6db;
  border-radius: 5px;
  font-size: 14px;
}
.login-box button {
  width: 100%;
  padding: 11px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 5px;
  font-size: 14px;
  cursor: pointer;
}
.login-box button:hover { background: var(--blue-dark); }
.login-box .error { color: var(--red); font-size: 13px; margin: 0 0 10px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .hamburger { display: block; }
  .sidebar {
    position: fixed;
    top: 48px;
    left: -200px;
    height: calc(100vh - 48px);
    z-index: 60;
    transition: left .2s ease;
  }
  .sidebar.open { left: 0; box-shadow: 4px 0 20px rgba(0,0,0,.3); }
  .content { padding: 14px; }
  .subject-cell { max-width: 200px; }
}
@media (max-width: 640px) {
  .hide-sm { display: none; }
  .stat-row { flex-direction: column; }
  .filters { flex-direction: column; align-items: stretch; }
  .search-input { min-width: 0; }
  .page-head h1 { font-size: 16px; }
}
