:root {
  /* ==================== COLORS ==================== */
  --bg-body: #ffeeee;
  --bg-container: white;
  --bg-light: #f8f8f8;
  --border-red: #ff0000;
  --border-light: #dddddd;
  --accent-red: #dc2626;
  --accent-green: #16a34a;
  --text-main: #1f2937;
  --text-muted: #374151;
  --tooltip-bg: #1f2937;
  --tooltip-text: #f1f5f9;

  /* Action badge colors */
  --allow-bg: #ddffee;
  --allow-text: #116633;
  --block-bg: #ffeeee;
  --block-text: #991111;
  --bypass-bg: #ffffcc;
  --bypass-text: #994400;

  /* Spacing & Sizing */
  --radius: 12px;
  --radius-sm: 6px;
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.6);
  --padding-standard: 20px;
  --padding-small: 4px;

  /* Typography */
  --font-sans: system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, monospace;
}

/* ==================== BASE ==================== */
body {
  font-family: var(--font-sans);
  line-height: 1.6;
  max-width: 2500px;
  margin: 40px auto;
  padding: var(--padding-standard);
  background: var(--bg-body);
  color: var(--text-main);
}

h1 {
  color: var(--accent-red);
  text-align: center;
  margin-bottom: 1.5rem;
}

h2, h3 {
  margin: 1.5rem 0 0.75rem;
}

.container {
  background: var(--bg-container);
  padding: var(--padding-standard);
  border-radius: var(--radius);
  border: 1px solid var(--border-red);
  margin: 20px auto;
  max-width: 2500px;
  box-shadow: var(--shadow);
}

.blocked-emoji {
  text-align: center;
  font-size: 80px;
}

/* ==================== FORM ELEMENTS ==================== */
label {
  display: block;
  margin: 12px 0 4px;
  font-weight: 600;
}

select, input, textarea {
  width: 100%;
  padding: var(--padding-small);
  border-radius: var(--radius-sm);
  border: 1px solid #ccc;
  box-sizing: border-box;
}

button {
  margin-top: 20px;
  padding: var(--padding-small);
  background: var(--accent-green);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1.05em;
  cursor: pointer;
}

button:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}

/* ==================== CONTENT STYLES ==================== */
dl { margin: 0; }

dt {
  font-weight: 600;
  color: var(--text-muted);
  margin: 1.25rem 0 0.25rem;
  position: relative;
}

dt:hover::after {
  content: attr(data-desc);
  position: absolute;
  left: 0;
  top: 100%;
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  padding: var(--padding-small);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  white-space: pre-wrap;
  max-width: 400px;
  z-index: 10;
  pointer-events: none;
}

dd {
  margin: 0.25rem 0 1rem 1.5rem;
  font-family: var(--font-mono);
  background: var(--bg-light);
  padding: var(--padding-small);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  word-break: break-all;
}

.categories {
  display: inline-block;
  background: #dbeafe;
  color: #1e40af;
  padding: var(--padding-small);
  margin: 4px 6px 4px 0;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}

.email-warning {
  color: #cccc00;
  font-weight: bold;
}

.ai-notes {
  background: #fefce8;
  padding: var(--padding-small);
  border-radius: var(--radius-sm);
  margin: 12px 0;
}

.tech-details {
  margin-top: 20px;
}
.tech-details summary {
  cursor: pointer;
}

/* ==================== TOOLTIP ==================== */
.tooltip {
  position: fixed;
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  padding: var(--padding-small);
  border-radius: var(--radius-sm);
  font-size: 0.84em;
  line-height: 1.45;
  max-width: 680px;
  z-index: 1000;
  display: none;
  box-shadow: var(--shadow);
  pointer-events: none;
  border: 1px solid #334155;
  white-space: pre-wrap;
}

/* ==================== LOGS TABLE ==================== */
.logs {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92em;
  table-layout: fixed;
  background: var(--bg-container);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.logs th,
.logs td {
  padding: var(--padding-small);
  text-align: left;
  border-bottom: 1px solid var(--border-light);
  vertical-align: top;
}

.logs th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--text-muted);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logs td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1;
}

/* Column widths */
@media (min-width: 769px) {
  .logs .time       { width: 140px; }
  .logs .action     { width: 50px; }
  .logs .url        { width: 400px; }
  .logs .policy     { width: 170px; }
  .logs .application{ width: 180px; }
  .logs .category   { width: 220px; }
  .logs .device     { width: 100px; }
  .logs .referer    { width: 100px; }
  .logs .useragent  { width: 140px; }
}

/* Long text fields */
.logs td.url,
.logs td.referer,
.logs td.useragent {
  position: relative;
  font-family: var(--font-mono);
  font-size: 0.9em;
}

/* Action badges */
.logs td.action {
  font-weight: 600;
  text-align: center;
  border-radius: var(--radius-sm);
  padding: var(--padding-small);
  margin: 2px 4px;
  white-space: nowrap;
}
.logs td.action.allow  { color: var(--allow-text);  background: var(--allow-bg); }
.logs td.action.block  { color: var(--block-text);  background: var(--block-bg); }
.logs td.action.bypass { color: var(--bypass-text); background: var(--bypass-bg); }

/* TLS Logs specific adjustments */
#logsTabletls {
  table-layout: fixed;
}

#logsTabletls .time   { width: 90px; }
#logsTabletls .action { width: 180px; }
#logsTabletls .url    { width: 300px; }
#logsTabletls .device { width: 50px; }

#logsContainertls {
  overflow-x: auto;
}

/* Logs container */
#logsContainer {
  overflow-x: auto;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
}

.notice {
  text-align: center;
  padding: var(--padding-standard);
}




/* Organization display */
.organization-known  { color: var(--allow-text);  background: var(--allow-bg); }
.organization-unknown{ color: var(--block-text);  background: var(--block-bg); }


footer {
  text-align: center;
}

ul {
  max-height: 200px;
  overflow: auto;
  font-family: var(--font-mono);
}

/* ==================== MOBILE CARD VIEW FOR LOGS ==================== */
@media (max-width: 768px) {
  .logs {
    display: block;
    width: 100%;
    border: none;
  }

  .logs thead {
    display: none; /* Hide headers on mobile */
  }

  .logs tbody,
  .logs tr {
    display: block;
    margin-bottom: 16px;
  }

  .logs tr {
    background: var(--bg-container);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 12px;
    box-shadow: var(--shadow);
    position: relative;
  }

  /* Color entire card based on action */
  .logs tr:has(td.action.allow)  { border-left: 6px solid var(--allow-text); }
  .logs tr:has(td.action.block)  { border-left: 6px solid var(--block-text); }
  .logs tr:has(td.action.bypass){ border-left: 6px solid var(--bypass-text); }

  .logs td {
    display: block;
    /*width: 100%;*/
    padding: 6px 0;
    border: none;
    white-space: normal;
    text-overflow: unset;
  }

  .logs td.time {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.9em;
  }

  /* Show only time (HH:MM) in header */
  .logs td.time::before {
    content: attr(data-timeonly) " • ";
    font-weight: normal;
  }

  .logs td.action {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 4px 10px;
    font-size: 0.8em;
    border-radius: 9999px;
  }

  .logs td:not(.time):not(.action) {
    font-size: 0.9em;
  }

  /* Expandable full content */
  .logs td.url[data-full],
  .logs td.referer[data-full],
  .logs td.useragent[data-full] {
    white-space: pre-wrap;
    word-break: break-all;
  }
  body {
    padding: var(--padding-standard);
    margin: 10px auto;
  }
  .container {
    margin: 12px auto;
    padding: var(--padding-standard);
  }
  .logs th,
  .logs td {
    padding: var(--padding-small);
    font-size: 0.65em;
  }

  /* Column widths */
  .logs .time       { width: 70px; }
  .logs .action     { width: 30px; }
}

@media (max-width: 480px) {
  button {
    width: 100%;
    padding: var(--padding-small);
  }
}