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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: #1a1a2e;
  background: #f4f4f4;
  line-height: 1.5;
  overflow-x: hidden;
}

/* ── Header ── */
.site-header {
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  gap: 12px;
}
.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.header-brand {
  font-weight: 700;
  font-size: 15px;
  color: #1a1a2e;
}
.header-divider { color: #ccc; }
.header-section { color: #888; font-size: 13px; }
.header-user {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  min-width: 0;
}
.header-account {
  color: #555;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.header-logout {
  color: #888;
  text-decoration: none;
  transition: color 0.15s;
  flex-shrink: 0;
  white-space: nowrap;
}
.header-logout:hover { color: #1a1a2e; }

/* ── Nav ── */
.site-nav {
  display: flex;
  padding: 0 24px;
  background: #ffffff;
  border-top: 1px solid #f0f0f0;
  gap: 2px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex-wrap: nowrap;
}
.site-nav::-webkit-scrollbar { display: none; }
.nav-link {
  padding: 10px 14px;
  font-size: 13px;
  color: #666;
  text-decoration: none;
  border-bottom: 3px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
  white-space: nowrap;
  flex-shrink: 0;
}
.nav-link:hover { color: #1a1a2e; }
.nav-link.active {
  color: #1a1a2e;
  font-weight: 600;
  border-bottom-color: #1a1a2e;
}

/* ── Page body ── */
.main-content { padding: 24px; max-width: 100%; }
.page-body { max-width: 1040px; margin: 0 auto; }

/* ── Metrics ── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.metric-card {
  background: #fff;
  border: 1px solid #e8eaed;
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  border-left: 4px solid transparent;
}
.metric-card.metric-danger { border-left-color: #E8232A; }
.metric-card.metric-danger .metric-value { color: #E8232A; }
.metric-card.metric-warn { border-left-color: #d97706; }
.metric-card.metric-warn .metric-value { color: #d97706; }
.metric-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #8892a4;
  margin-bottom: 6px;
}
.metric-value { font-size: 26px; font-weight: 700; color: #1a1a2e; }
.metric-sub { font-size: 12px; color: #aaa; margin-top: 4px; }

/* ── Alert banner ── */
.alert-banner {
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  line-height: 1.5;
}
.alert-danger {
  background: #fff2f2;
  border: 1px solid #ffcccc;
  border-left: 4px solid #E8232A;
  color: #7a1a1a;
}
.alert-warn {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-left: 4px solid #d97706;
  color: #78350f;
}
.btn-link-danger {
  background: none;
  border: 1.5px solid #E8232A;
  color: #E8232A;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  padding: 6px 14px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.btn-link-danger:hover { background: #E8232A; color: #fff; }

/* ── Section card ── */
.section-card {
  background: #fff;
  border: 1px solid #e8eaed;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
/* Scrollable table wrapper inside section cards */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
/* General padded content inside a section card */
.card-body {
  padding: 16px 20px;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid #f0f0f0;
  background: #fafbfc;
  gap: 10px;
  flex-wrap: wrap;
}
.section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #1a1a2e;
}
.section-hint { font-size: 12px; color: #aaa; }
.section-action {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Responsive grid ── */
.grid-cols-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ── Table ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  padding: 10px 18px;
  font-size: 11px;
  font-weight: 700;
  color: #8892a4;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: #f8f9fb;
  border-bottom: 1px solid #eaecef;
  white-space: nowrap;
}
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f5f5f5;
  color: #1a1a2e;
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: #fafbfc; }
.table-total td {
  background: #f8f9fb;
  font-weight: 700;
  border-top: 1px solid #eaecef;
}
.td-bold { font-weight: 600; }
.td-muted { color: #8892a4; }
.td-danger { color: #E8232A; font-weight: 600; }
.td-warn { color: #b7701a; }
.td-green { color: #2e7d32; }
.td-right { text-align: right; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge-danger { background: #fff2f2; color: #E8232A; border: 1px solid #ffcccc; }
.badge-warn   { background: #fff8e6; color: #b35c00; border: 1px solid #ffd980; }
.badge-ok     { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }
.badge-neutral { background: #f4f4f4; color: #555; border: 1px solid #e0e0e0; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: 1.5px solid transparent;
  transition: opacity 0.15s, background 0.15s;
  white-space: nowrap;
  min-height: 34px;
}
.btn-primary {
  background: #1a1a2e;
  color: #fff;
  border-color: #1a1a2e;
}
.btn-primary:hover { opacity: 0.82; }
.btn-outline {
  background: transparent;
  color: #1a1a2e;
  border-color: #d0d0d0;
}
.btn-outline:hover { background: #f4f4f4; }
.action-row {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Empty state ── */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: #8892a4;
  font-size: 14px;
}

/* ── Page note ── */
.page-note {
  font-size: 12px;
  color: #aaa;
  line-height: 1.6;
}
.page-note a { color: #8892a4; }

/* ── Site footer ── */
.site-footer {
  background: #1a1a2e;
  padding: 24px 32px;
  text-align: center;
  margin-top: 40px;
}
.site-footer p {
  color: #8892a4;
  font-size: 13px;
  margin: 0 0 4px 0;
}
.site-footer a { color: #a0b0cc; }

/* ── Login ── */
.login-body {
  background: #f4f4f4;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
.login-card {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 420px;
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,0,0,0.10);
}
.login-hero {
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  padding: 24px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.login-portal-label {
  font-size: 12px;
  color: #888;
  white-space: nowrap;
}
.login-hero-text h1 {
  color: #1a1a2e;
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 2px;
}
.login-hero-text p {
  color: #888;
  font-size: 12px;
}
.login-body-inner { padding: 32px; }
.login-heading { font-size: 16px; font-weight: 700; color: #1a1a2e; margin-bottom: 6px; }
.login-intro { font-size: 13px; color: #666; margin-bottom: 24px; line-height: 1.6; }
.login-card label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #8892a4;
  margin-bottom: 6px;
}
.login-card input[type="email"] {
  display: block;
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid #d8dce2;
  border-radius: 7px;
  font-size: 14px;
  margin-bottom: 16px;
  outline: none;
  color: #1a1a2e;
  transition: border-color 0.15s;
}
.login-card input[type="email"]:focus { border-color: #1a1a2e; }
.login-card button[type="submit"] {
  width: 100%;
  padding: 12px;
  background: #1a1a2e;
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 16px;
  transition: opacity 0.15s;
  letter-spacing: 0.02em;
}
.login-card button[type="submit"]:hover { opacity: 0.82; }
.login-help { font-size: 12px; color: #aaa; text-align: center; }
.login-help a { color: #8892a4; }
.form-error {
  background: #fff2f2;
  border: 1px solid #ffcccc;
  border-left: 4px solid #E8232A;
  color: #7a1a1a;
  border-radius: 7px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}
.login-sent { text-align: center; padding: 8px 0; }
.sent-icon {
  width: 52px; height: 52px;
  background: #e8f5e9;
  color: #2e7d32;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  margin: 0 auto 16px;
}
.login-sent h2 { font-size: 18px; font-weight: 700; margin-bottom: 12px; color: #1a1a2e; }
.login-sent p { font-size: 13px; color: #555; line-height: 1.6; margin-bottom: 8px; }
.sent-note { color: #aaa; font-size: 12px; }

/* ── Info tooltip / popover (hover on desktop, tap on mobile) ── */
.kkc-tip { position: relative; display: inline-block; cursor: pointer; }
.kkc-tip-box {
  display: none;
  position: absolute;
  z-index: 60;
  top: calc(100% + 7px);
  left: 0;
  width: 250px;
  max-width: 76vw;
  background: #1a1a2e;
  color: #fff;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.55;
  letter-spacing: normal;
  text-transform: none;
  text-align: left;
  white-space: normal;
  padding: 11px 13px;
  border-radius: 9px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.28);
}
.kkc-tip-box::before {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 18px;
  border: 6px solid transparent;
  border-bottom-color: #1a1a2e;
}
.kkc-tip:hover .kkc-tip-box,
.kkc-tip.open .kkc-tip-box { display: block; }
.kkc-tip .badge { cursor: pointer; }
/* subtle dotted underline cue that there's more info */
.kkc-tip .badge::after { content: " ⓘ"; font-size: 0.85em; opacity: 0.7; }

/* ── Responsive table → stacked cards on mobile ── */
@media (max-width: 640px) {
  table.data-table.responsive thead { display: none; }
  table.data-table.responsive,
  table.data-table.responsive tbody { display: block; width: 100%; }
  table.data-table.responsive tr {
    display: block;
    border: 1px solid #e8eaed;
    border-radius: 10px;
    margin: 0 0 10px;
    padding: 4px 14px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  }
  table.data-table.responsive td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding: 9px 0;
    border-bottom: 1px solid #f3f4f6;
    text-align: right;
    white-space: normal;
  }
  table.data-table.responsive tr td:last-child { border-bottom: none; }
  table.data-table.responsive td::before {
    content: attr(data-label);
    font-weight: 700;
    color: #8892a4;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: left;
    flex-shrink: 0;
  }
  table.data-table.responsive td[data-label=""]::before { content: none; }
  /* full-width action cells (no label) */
  table.data-table.responsive td[data-label=""] { justify-content: flex-start; flex-wrap: wrap; }
  table.data-table.responsive .kkc-tip-box { left: auto; right: 0; }
}

/* ── Mobile ── */
@media (max-width: 640px) {

  /* Header */
  .header-inner { padding: 10px 16px; gap: 8px; }
  .header-section, .header-divider { display: none; }
  .header-logo img { height: 28px; }
  .header-user { gap: 10px; }
  .header-account { max-width: 130px; font-size: 12px; }
  .header-logout { font-size: 12px; }

  /* Nav — scrolls horizontally, never wraps */
  .site-nav { padding: 0 16px; }
  .nav-link { padding: 10px 12px; font-size: 12px; }

  /* Main content */
  .main-content { padding: 14px 14px 24px; }
  .page-body { max-width: 100%; }

  /* Metrics — 2 per row */
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 14px;
  }
  .metric-card { padding: 12px 14px; }
  .metric-value { font-size: 19px; }
  .metric-label { font-size: 10px; margin-bottom: 4px; }
  .metric-sub { font-size: 11px; }

  /* Alert banners — stack */
  .alert-banner { flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px 14px; }
  .btn-link-danger { align-self: flex-start; }

  /* Section cards */
  .section-card { margin-bottom: 12px; border-radius: 8px; }
  .section-head { padding: 11px 14px; }
  .card-body { padding: 14px; }

  /* Tables */
  .data-table th,
  .data-table td { padding: 10px 12px; font-size: 12px; }

  /* 2-col grids → 1 col */
  .grid-cols-2 { grid-template-columns: 1fr; }

  /* Buttons */
  .btn { padding: 8px 12px; font-size: 12px; min-height: 36px; }

  /* Footer */
  .site-footer { padding: 18px 16px; margin-top: 24px; }
  .site-footer p { font-size: 12px; }

  /* Login */
  .login-body { padding: 16px; }
  .login-hero { padding: 20px; }
  .login-body-inner { padding: 24px 20px; }
}
