@layer reset, base, components, utilities;

@layer reset {
  html { height: 100%; }
  .intel-body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100vh;
    max-width: none;
    background: #040b16;
    color: #e5e7eb;
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    overflow: hidden;
  }
  #intel-root,
  #intel-root * {
    box-sizing: border-box;
  }
  #intel-root a,
  #intel-root button {
    font: inherit;
  }
}

@layer base {
  #intel-root {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: radial-gradient(120% 120% at 10% 10%, rgba(59,130,246,0.08), transparent),
                radial-gradient(100% 100% at 80% 0%, rgba(229,9,20,0.05), transparent),
                #050d1a;
    color: #e5e7eb;
  }
  #intel-header {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    background: linear-gradient(90deg, rgba(8,16,30,0.9), rgba(8,12,24,0.75));
    backdrop-filter: blur(10px);
  }
  #intel-header .hdr-left { display: flex; align-items: center; gap: 12px; }
  #intel-header .titles h1 { margin: 0; font-size: 18px; letter-spacing: 0.02em; }
  #intel-header .titles .eyebrow { margin: 0; font-size: 11px; letter-spacing: 0.2em; color: #8b9cb8; }
  #intel-header .hdr-right { display: flex; align-items: center; gap: 10px; }
  #intel-main {
    flex: 1;
    overflow: auto;
    padding: 16px 18px 22px;
  }
  #intel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 14px;
  }
}

@layer components {
  .btn {
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.04);
    color: #e5e7eb;
    padding: 8px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    text-decoration: none;
  }
  .btn:hover { border-color: rgba(255,255,255,0.25); background: rgba(255,255,255,0.07); }
  .btn-primary { border-color: #38bdf8; color: #e0f2fe; }
  .btn-primary.loading { opacity: 0.6; pointer-events: none; }
  .btn-ghost { background: transparent; border-color: rgba(255,255,255,0.12); }

  .pill {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    border: 1px solid rgba(255,255,255,0.2);
  }
  .pill-ok { background: rgba(34,197,94,0.14); border-color: rgba(34,197,94,0.4); color: #a7f3d0; }
  .pill-warn { background: rgba(234,179,8,0.14); border-color: rgba(234,179,8,0.4); color: #fcd34d; }
  .pill-critical { background: rgba(248,113,113,0.14); border-color: rgba(248,113,113,0.45); color: #fecdd3; }

  .timestamp { font-size: 12px; color: #9ca3af; }

  .card { position: relative; padding: 14px 14px 12px; background: linear-gradient(135deg, rgba(12,22,38,0.95), rgba(10,16,28,0.92)); border: 1px solid rgba(255,255,255,0.08); border-radius: 16px; box-shadow: 0 18px 45px rgba(0,0,0,0.45); overflow: hidden; }
  .card::after { content: ""; position: absolute; inset: 0; background: linear-gradient(120deg, rgba(255,255,255,0.03), transparent); pointer-events: none; }
  .card h3 { margin: 0 0 6px; font-size: 14px; letter-spacing: 0.02em; color: #cbd5e1; }
  .card p.meta { margin: 0 0 6px; font-size: 12px; color: #94a3b8; }
  .metric-row { display: flex; align-items: baseline; gap: 10px; }
  .metric-number { font-family: "Roboto Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-size: 28px; color: #e5e7eb; }
  .metric-label { font-size: 12px; color: #8da2c0; }

  .card--micro { min-height: 220px; max-height: 260px; }
  .card--large { min-height: 320px; }

  .placeholder {
    grid-column: 1 / -1;
    padding: 32px;
    border: 1px dashed rgba(255,255,255,0.2);
    border-radius: 16px;
    text-align: center;
    color: #cbd5e1;
    background: rgba(255,255,255,0.03);
  }

  .list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 220px;
    overflow: auto;
  }
  .list li { padding: 10px; border: 1px solid rgba(255,255,255,0.08); border-radius: 12px; background: rgba(255,255,255,0.02); }
  .alert-warn { border-color: rgba(234,179,8,0.5); color: #fcd34d; }
  .alert-critical { border-color: rgba(248,113,113,0.6); color: #fecdd3; }

  table.intel-table { width: 100%; border-collapse: collapse; font-size: 13px; }
  table.intel-table th, table.intel-table td { padding: 8px 6px; text-align: left; }
  table.intel-table th { color: #cbd5e1; font-weight: 600; border-bottom: 1px solid rgba(255,255,255,0.1); }
  table.intel-table tr + tr td { border-top: 1px solid rgba(255,255,255,0.05); }

  .inline-alert {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 10px;
    border: 1px solid rgba(248,113,113,0.5);
    color: #fecdd3;
    background: rgba(248,113,113,0.12);
    font-size: 12px;
  }

  .chart-shell { position: relative; width: 100%; height: 180px; }
  .chart-shell.small { height: 150px; }

  .kpi-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-top: 8px; }
  .kpi-item { padding: 10px 12px; border: 1px solid rgba(255,255,255,0.08); border-radius: 12px; background: rgba(255,255,255,0.02); }
  .kpi-item .label { color: #8da2c0; font-size: 12px; margin-bottom: 4px; }
  .kpi-item .value { font-family: "Roboto Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-size: 22px; color: #e5e7eb; }
  .kpi-item .meta { color: #9ca3af; font-size: 12px; }
}

@layer utilities {
  .grid-span-2 { grid-column: span 2; }
  .mono { font-family: "Roboto Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }
  .hidden { display: none !important; }
}

@media (max-width: 768px) {
  #intel-root { position: fixed; inset: 0; }
  #intel-header { flex-wrap: wrap; padding: 10px 12px; gap: 8px; }
  #intel-header .hdr-left { flex-wrap: wrap; gap: 6px; }
  #intel-header .titles h1 { font-size: 16px; }
  #intel-header .titles .eyebrow { font-size: 10px; }
  #intel-header .hdr-right { width: 100%; justify-content: flex-start; gap: 8px; flex-wrap: wrap; }
  #intel-main { padding: 12px 12px 16px; }
  #intel-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
  .card { padding: 12px; }
  .card h3 { font-size: 13px; }
  .card--micro { min-height: 180px; max-height: 220px; }
  .card--large { min-height: 240px; }
  .chart-shell { height: 150px; }
  .chart-shell.small { height: 130px; }
  .placeholder { padding: 20px; }
  .kpi-strip { gap: 10px; }
}
