/* Mailbox Monitor — shares the visual language of surveys.jtnv.com:
   light grey canvas, white cards, #2c3e50 chrome, #3498db links. */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: #f5f5f5;
  color: #333;
  line-height: 1.6;
}

a {
  color: #3498db;
}

/* ---------------------------------------------------------------- Login -- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.login-card {
  background: white;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  padding: 40px;
}

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

.login-card h1 {
  font-size: 24px;
  margin-bottom: 10px;
  text-align: center;
}

.login-card > p {
  text-align: center;
  color: #666;
  margin-bottom: 30px;
}

.btn-microsoft {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  background: #fff;
  color: #1a1a1a;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: box-shadow 0.2s;
  width: 100%;
  justify-content: center;
}

.btn-microsoft:hover {
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}

/* --------------------------------------------------------------- Header -- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  background: #2c3e50;
  color: white;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-wrap: wrap;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: inherit;
}

.header-brand h1 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  flex-wrap: wrap;
}

.header-nav a {
  color: rgba(255,255,255,0.82);
  text-decoration: none;
  font-size: 14px;
  padding: 6px 12px;
  border-radius: 4px;
}

.header-nav a:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
}

.header-nav a.active {
  background: rgba(255,255,255,0.18);
  color: #fff;
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-user {
  font-size: 13px;
  opacity: 0.85;
}

.header-logout {
  color: white;
  text-decoration: none;
  font-size: 13px;
  padding: 4px 10px;
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: 4px;
  transition: background 0.2s;
}

.header-logout:hover {
  background: rgba(255,255,255,0.1);
}

/* ----------------------------------------------------------------- Page -- */
.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.page-head h2 {
  font-size: 24px;
  color: #2c3e50;
  margin: 0;
}

.page-head .subtitle {
  font-size: 14px;
  color: #666;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.breadcrumb {
  margin-bottom: 14px;
  font-size: 14px;
}

.breadcrumb a {
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

/* -------------------------------------------------------------- Banners -- */
.banner {
  border-radius: 6px;
  padding: 14px 16px;
  margin-bottom: 20px;
  font-size: 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.banner strong {
  display: block;
  font-size: 15px;
  margin-bottom: 2px;
}

.banner-icon {
  font-size: 18px;
  line-height: 1.3;
}

.banner-shadow {
  background: #fff8e1;
  border-left: 4px solid #ffb300;
  color: #6d4c00;
}

.banner-error {
  background: #ffebee;
  border-left: 4px solid #f44336;
  color: #c62828;
}

.banner-info {
  background: #e3f2fd;
  border-left: 4px solid #2196f3;
  color: #14507d;
}

.banner-ok {
  background: #e8f5e9;
  border-left: 4px solid #4caf50;
  color: #2e7d32;
}

.banner a {
  color: inherit;
}

/* -------------------------------------------------------------- Sections -- */
.section {
  background: white;
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  margin-bottom: 24px;
}

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

.section h3 {
  font-size: 18px;
  color: #2c3e50;
  margin: 0;
}

.section-note {
  font-size: 13px;
  color: #777;
}

/* ----------------------------------------------------------- Stat tiles -- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px;
  margin-bottom: 26px;
}

.stat-card {
  background: white;
  border-radius: 8px;
  padding: 16px 18px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  display: block;
  text-decoration: none;
  color: inherit;
}

a.stat-card {
  transition: transform 0.15s, box-shadow 0.15s;
}

a.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.stat-card.level-ok       { border-left: 4px solid #2e7d32; }
.stat-card.level-warning  { border-left: 4px solid #b26a00; }
.stat-card.level-critical { border-left: 4px solid #e65100; }
.stat-card.level-urgent   { border-left: 4px solid #c62828; }

.stat-label {
  font-size: 13px;
  color: #666;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 30px;
  font-weight: 700;
  color: #2c3e50;
  line-height: 1.2;
}

.stat-subtitle {
  font-size: 12px;
  color: #999;
  margin-top: 2px;
}

/* -------------------------------------------------------- Client tiles -- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.client-card {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  padding: 18px;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 4px solid #cfd8dc;
  transition: transform 0.15s, box-shadow 0.15s;
}

.client-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.client-card.level-ok       { border-top-color: #2e7d32; }
.client-card.level-warning  { border-top-color: #b26a00; }
.client-card.level-critical { border-top-color: #e65100; }
.client-card.level-urgent   { border-top-color: #c62828; }

.client-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.client-name {
  font-size: 17px;
  font-weight: 700;
  color: #2c3e50;
}

.client-domain {
  font-size: 12px;
  color: #999;
}

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

.count-pill {
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  background: #f1f3f5;
  color: #555;
  display: flex;
  align-items: center;
  gap: 5px;
}

.count-pill .count-num {
  font-size: 15px;
  font-weight: 700;
}

.count-pill.level-ok       { background: #e8f5e9; color: #2e7d32; }
.count-pill.level-warning  { background: #fff8e1; color: #8a5300; }
.count-pill.level-critical { background: #fff3e0; color: #b34700; }
.count-pill.level-urgent   { background: #ffebee; color: #c62828; }
.count-pill.zero           { background: #f1f3f5; color: #8a8a8a; }

.client-worst {
  font-size: 13px;
  color: #555;
  border-top: 1px solid #eceff1;
  padding-top: 8px;
}

.client-worst .worst-upn {
  font-weight: 600;
  color: #2c3e50;
  word-break: break-all;
}

.client-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: #777;
  border-top: 1px solid #eceff1;
  padding-top: 8px;
}

/* --------------------------------------------------------------- Badges -- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  background: #eceff1;
  color: #455a64;
  white-space: nowrap;
}

.badge.level-unknown  { background: #eceff1; color: #546e7a; }
.badge.level-ok       { background: #e8f5e9; color: #2e7d32; }
.badge.level-warning  { background: #fff8e1; color: #8a5300; }
.badge.level-critical { background: #fff3e0; color: #b34700; }
.badge.level-urgent   { background: #ffebee; color: #c62828; }
.badge.badge-muted    { background: #ede7f6; color: #5e35b1; }
.badge.badge-stale    { background: #fff8e1; color: #8a5300; }
.badge.badge-fresh    { background: #e8f5e9; color: #2e7d32; }
.badge.badge-error    { background: #ffebee; color: #c62828; }
.badge.badge-shadow   { background: #fff8e1; color: #6d4c00; }

.badge-conceal {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ede7f6;
  color: #4527a0;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
}

.conceal-note {
  background: #ede7f6;
  border-left: 4px solid #7e57c2;
  color: #37256b;
  border-radius: 6px;
  padding: 12px 14px;
  font-size: 13px;
  margin-bottom: 18px;
}

/* ----------------------------------------------------------- Usage bars -- */
.usage-cell {
  min-width: 150px;
}

.usage-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #2c3e50;
}

.usage-bar {
  position: relative;
  height: 8px;
  border-radius: 4px;
  background: #eceff1;
  overflow: hidden;
  margin-top: 4px;
}

.usage-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-radius: 4px;
  background: #90a4ae;
}

.usage-fill.level-ok       { background: #2e7d32; }
.usage-fill.level-warning  { background: #b26a00; }
.usage-fill.level-critical { background: #e65100; }
.usage-fill.level-urgent   { background: #c62828; }

/* --------------------------------------------------------------- Tables -- */
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

thead {
  background-color: #f8f9fa;
}

th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  color: #2c3e50;
  border-bottom: 2px solid #dee2e6;
  white-space: nowrap;
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid #dee2e6;
  vertical-align: top;
}

tbody tr:hover {
  background-color: #f8f9fa;
}

th.sortable {
  cursor: pointer;
  user-select: none;
}

th.sortable:hover {
  color: #3498db;
}

th.sortable .sort-arrow {
  color: #b0bec5;
  font-size: 11px;
  margin-left: 4px;
}

th.sortable[aria-sort="ascending"] .sort-arrow,
th.sortable[aria-sort="descending"] .sort-arrow {
  color: #3498db;
}

tr.noisy td {
  opacity: 0.6;
}

tr.muted-row td {
  background: #fafafa;
}

.cell-link {
  color: #3498db;
  text-decoration: none;
  font-weight: 600;
  word-break: break-all;
}

.cell-link:hover {
  text-decoration: underline;
}

.loading, .no-data, .error-text {
  text-align: center;
  color: #666;
  padding: 30px !important;
}

.error-text {
  color: #c62828;
}

.mono {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 12px;
}

.muted-text {
  color: #888;
  font-size: 12px;
}

.nowrap { white-space: nowrap; }
.num    { text-align: right; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------- Chips --- */
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

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

.chip {
  border: 1px solid #d5dbe0;
  background: #fff;
  border-radius: 14px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #55606a;
  cursor: pointer;
}

.chip:hover {
  border-color: #3498db;
  color: #2c3e50;
}

.chip.active {
  background: #2c3e50;
  border-color: #2c3e50;
  color: #fff;
}

.search-input {
  padding: 7px 11px;
  border: 1px solid #d5dbe0;
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
  min-width: 220px;
  flex: 1;
  max-width: 340px;
}

.search-input:focus {
  outline: none;
  border-color: #3498db;
}

/* -------------------------------------------------------------- Buttons -- */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background: #3498db;
  color: #fff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn:hover { background: #2980b9; }

.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-secondary { background: #95a5a6; }
.btn-secondary:hover { background: #7f8c8d; }

.btn-danger { background: #e74c3c; }
.btn-danger:hover { background: #c0392b; }

.btn-outline {
  background: #fff;
  color: #2c3e50;
  border: 1px solid #d5dbe0;
}

.btn-outline:hover {
  background: #f4f6f8;
}

.btn-small {
  padding: 4px 10px;
  font-size: 12px;
}

/* ---------------------------------------------------------------- Forms -- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
  font-size: 13px;
  color: #455a64;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid #d5dbe0;
  border-radius: 4px;
  font-family: inherit;
  font-size: 14px;
  background: #fff;
  color: #333;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #3498db;
}

.form-hint {
  font-size: 12px;
  color: #888;
  margin-top: 4px;
}

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

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.checkbox-row input {
  width: auto;
}

/* ------------------------------------------------------------- Key/value -- */
.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px 24px;
}

.kv-label {
  font-size: 12px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kv-value {
  font-size: 15px;
  color: #2c3e50;
  font-weight: 600;
  word-break: break-word;
}

/* --------------------------------------------------------------- Charts -- */
.chart-wrap {
  position: relative;
  width: 100%;
  height: 320px;
}

.chart-empty {
  color: #888;
  font-size: 14px;
  padding: 24px 0;
  text-align: center;
}

/* ------------------------------------------------------------- Copy box -- */
.copy-box {
  display: flex;
  gap: 8px;
  align-items: stretch;
  flex-wrap: wrap;
}

.copy-box input {
  flex: 1;
  min-width: 240px;
  padding: 9px 11px;
  border: 1px solid #d5dbe0;
  border-radius: 4px;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 12px;
  background: #f8f9fa;
  color: #333;
}

/* ---------------------------------------------------------------- Modal -- */
.modal {
  position: fixed;
  z-index: 1000;
  inset: 0;
  background-color: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal[hidden] { display: none; }

.modal-content {
  background-color: white;
  border-radius: 8px;
  padding: 24px;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  position: relative;
}

.modal-content h3 {
  margin-bottom: 16px;
  color: #2c3e50;
}

.modal-close {
  position: absolute;
  right: 16px;
  top: 10px;
  font-size: 26px;
  line-height: 1;
  font-weight: bold;
  color: #aaa;
  cursor: pointer;
  background: none;
  border: none;
}

.modal-close:hover { color: #000; }

/* ------------------------------------------------------------- Messages -- */
.msg {
  border-radius: 4px;
  padding: 10px 12px;
  font-size: 13px;
  margin-top: 10px;
}

.msg[hidden] { display: none; }

.msg-error {
  background-color: #ffebee;
  color: #c62828;
  border-left: 4px solid #f44336;
}

.msg-success {
  background-color: #e8f5e9;
  color: #2e7d32;
  border-left: 4px solid #4caf50;
}

.msg-info {
  background-color: #e3f2fd;
  color: #14507d;
  border-left: 4px solid #2196f3;
}

/* ----------------------------------------------------------- Responsive -- */
@media (max-width: 768px) {
  .page {
    padding: 18px 12px 50px;
  }

  .section {
    padding: 16px;
  }

  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
  }

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

  .header-user {
    display: none;
  }

  .header-nav a {
    padding: 6px 8px;
    font-size: 13px;
  }

  .chart-wrap {
    height: 260px;
  }

  .search-input {
    max-width: none;
  }
}
