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

:root {
  --blue:    #1a56db;
  --blue-dk: #1340a8;
  --blue-lt: #e8f0fe;
  --gray-50: #f9fafb;
  --gray-100:#f3f4f6;
  --gray-200:#e5e7eb;
  --gray-400:#9ca3af;
  --gray-600:#4b5563;
  --gray-800:#1f2937;
  --red:     #dc2626;
  --red-lt:  #fee2e2;
  --green:   #16a34a;
  --green-lt:#dcfce7;
  --amber:   #d97706;
  --amber-lt:#fef3c7;
  --white:   #ffffff;
  --shadow:  0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
  --radius:  8px;
  --font:    'Inter', system-ui, -apple-system, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-800);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

/* HEADER*/
.site-header {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow);
}
.header-inner {
  max-width: 1200px; margin: 0 auto;
  padding: 0 24px;
  display: flex; align-items: center; gap: 16px;
  height: 64px;
}
.logos { display: flex; align-items: center; gap: 10px; }
.logo-img { height: 32px; width: auto; object-fit: contain; }
.logo-badge {
  background: var(--blue);
  color: white;
  font-size: 11px; font-weight: 700;
  padding: 4px 8px; border-radius: 4px;
  letter-spacing: .5px;
  white-space: nowrap;
}
.logo-badge.kps { background: var(--gray-800); }
.site-title {
  font-size: 17px; font-weight: 700; color: var(--blue);
  text-decoration: none; margin-left: 8px;
}
.header-nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.nav-link {
  color: var(--gray-600); text-decoration: none;
  padding: 6px 12px; border-radius: var(--radius);
  font-size: 14px; font-weight: 500;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.nav-link:hover, .nav-link.active {
  background: var(--blue-lt); color: var(--blue);
}
.nav-user { font-size: 13px; color: var(--gray-400); margin-left: 8px; }
.btn-logout {
  background: var(--gray-100); color: var(--gray-600);
  border: 1px solid var(--gray-200); padding: 6px 14px;
  border-radius: var(--radius); cursor: pointer;
  font-size: 14px; text-decoration: none;
  transition: background .15s;
}
.btn-logout:hover { background: var(--red-lt); color: var(--red); border-color: var(--red); }

/* hamburger */
.hamburger { display: none; background: none; border: none; cursor: pointer; padding: 8px; }
.hamburger span {
  display: block; width: 22px; height: 2px;
  background: var(--gray-600); margin: 4px 0;
  transition: transform .2s;
}

/* LAYOUT */
.main-content {
  max-width: 1200px; margin: 0 auto;
  padding: 32px 24px;
}
.page-title { font-size: 24px; font-weight: 700; margin-bottom: 24px; color: var(--gray-800); }
.page-title span { color: var(--blue); }

/* CARDS*/
.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 24px;
}
.card-title {
  font-size: 16px; font-weight: 600;
  margin-bottom: 16px; padding-bottom: 12px;
  border-bottom: 1px solid var(--gray-200);
  color: var(--gray-800);
}

/* STAT CARDS*/
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s;
  text-decoration: none; color: inherit;
  display: block;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-number { font-size: 32px; font-weight: 700; color: var(--blue); }
.stat-label { font-size: 13px; color: var(--gray-600); margin-top: 4px; }
.stat-card.green .stat-number  { color: var(--green); }
.stat-card.red   .stat-number  { color: var(--red); }
.stat-card.amber .stat-number  { color: var(--amber); }

/* TABLE */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead tr { background: var(--gray-50); }
th {
  text-align: left; padding: 10px 14px;
  font-size: 12px; font-weight: 600; color: var(--gray-600);
  text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}
th a { color: inherit; text-decoration: none; }
th a:hover { color: var(--blue); }
th .sort-icon { margin-left: 4px; opacity: .5; }
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--blue-lt); transition: background .1s; }

/* BADGES*/
.badge {
  display: inline-block; padding: 2px 9px;
  border-radius: 20px; font-size: 12px; font-weight: 600;
}
.badge-green  { background: var(--green-lt);  color: #15803d; }
.badge-red    { background: var(--red-lt);    color: #b91c1c; }
.badge-amber  { background: var(--amber-lt);  color: #92400e; }
.badge-blue   { background: var(--blue-lt);   color: var(--blue-dk); }
.badge-gray   { background: var(--gray-100);  color: var(--gray-600); }

/* FORMS*/
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--gray-600); }
.form-group input,
.form-group select,
.form-group textarea {
  padding: 9px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 14px; font-family: var(--font);
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(26,86,219,.12);
}

/* BUTTONS*/
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius);
  font-size: 14px; font-weight: 600; cursor: pointer;
  border: none; text-decoration: none;
  transition: all .15s; white-space: nowrap;
}
.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover { background: var(--blue-dk); }
.btn-secondary { background: var(--gray-100); color: var(--gray-800); border: 1px solid var(--gray-200); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-danger { background: var(--red-lt); color: var(--red); }
.btn-danger:hover { background: var(--red); color: white; }
.btn-sm { padding: 5px 12px; font-size: 13px; }

/* SEARCH/FILTER BAR  */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 10px;
  align-items: flex-end;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.filter-bar .form-group { flex: 1; min-width: 150px; }
.filter-bar .btn { align-self: flex-end; }

/* ALERTS*/
.alert {
  padding: 12px 16px; border-radius: var(--radius);
  margin-bottom: 20px; font-size: 14px;
  display: flex; align-items: center; gap: 8px;
}
.alert-success { background: var(--green-lt); color: #15803d; border: 1px solid #bbf7d0; }
.alert-error   { background: var(--red-lt);   color: #b91c1c; border: 1px solid #fecaca; }

/* LOGIN PAGE */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center; background: var(--gray-50);
  padding: 24px;
}
.login-box {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,.08);
  padding: 40px;
  width: 100%; max-width: 420px;
}
.login-logos {
  display: flex; justify-content: center; gap: 12px; margin-bottom: 24px;
}
.login-title { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 8px; }
.login-sub   { font-size: 14px; color: var(--gray-400); text-align: center; margin-bottom: 28px; }
.login-tabs  { display: flex; border-bottom: 2px solid var(--gray-200); margin-bottom: 24px; }
.login-tab {
  flex: 1; padding: 10px; text-align: center;
  font-size: 14px; font-weight: 600; cursor: pointer;
  color: var(--gray-400); border: none; background: none;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: color .15s;
}
.login-tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.login-form { display: none; }
.login-form.active { display: block; }

/* QUERY RESULTS*/
.query-card {
  border-left: 4px solid var(--blue);
  padding-left: 16px; margin-bottom: 32px;
}
.query-label {
  font-size: 11px; font-weight: 700; color: var(--blue);
  text-transform: uppercase; letter-spacing: 1px;
  margin-bottom: 6px;
}
.query-title { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.query-desc  { font-size: 14px; color: var(--gray-600); margin-bottom: 16px; }
.query-sql {
  background: var(--gray-800); color: #e2e8f0;
  padding: 14px 16px; border-radius: var(--radius);
  font-family: 'Fira Code', 'Courier New', monospace;
  font-size: 13px; margin-bottom: 16px;
  overflow-x: auto; white-space: pre;
  line-height: 1.7;
}

/* PROGRESS BAR */
.progress-bar-wrap { background: var(--gray-200); border-radius: 4px; height: 8px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--blue); border-radius: 4px; transition: width .4s; }
.progress-bar.red   { background: var(--red); }
.progress-bar.green { background: var(--green); }

/* FOOTER*/
footer {
  text-align: center; padding: 24px;
  font-size: 13px; color: var(--gray-400);
  border-top: 1px solid var(--gray-200);
  background: var(--white); margin-top: 48px;
}

/* RESPONSIVE */
@media (max-width: 768px) {
  .hamburger { display: block; margin-left: auto; }
  .header-nav {
    display: none; position: absolute; top: 64px; left: 0; right: 0;
    background: var(--white); border-bottom: 1px solid var(--gray-200);
    flex-direction: column; padding: 12px;
    box-shadow: var(--shadow-md);
  }
  .header-nav.open { display: flex; }
  .main-content { padding: 20px 16px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .form-grid  { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; }
  .login-box  { padding: 24px; }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .header-inner { padding: 0 16px; }
  .site-title { font-size: 15px; }
}

/* ANIMATIONS */
@keyframes fadeIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }
.card, .stat-card { animation: fadeIn .25s ease both; }
.stat-card:nth-child(1) { animation-delay: .05s; }
.stat-card:nth-child(2) { animation-delay: .10s; }
.stat-card:nth-child(3) { animation-delay: .15s; }
.stat-card:nth-child(4) { animation-delay: .20s; }
.stat-card:nth-child(5) { animation-delay: .25s; }
