/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green:       #1D9E75;
  --green-dark:  #0F6E56;
  --green-light: #f0fdf8;
  --green-mid:   #d1fae5;
  --red:         #dc2626;
  --red-light:   #fee2e2;
  --amber:       #b45309;
  --amber-light: #fef3c7;
  --gray-50:     #f8fafc;
  --gray-100:    #f1f5f9;
  --gray-200:    #e2e8f0;
  --gray-400:    #94a3b8;
  --gray-600:    #475569;
  --gray-900:    #0f172a;
  --radius:      8px;
  --radius-lg:   12px;
  --shadow:      0 1px 4px rgba(0,0,0,.08);
  --shadow-md:   0 4px 16px rgba(0,0,0,.12);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-100);
  color: var(--gray-900);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px; min-height: 64px;
  background: #ffffff;
  border-bottom: 2px solid var(--gray-200);
  box-shadow: 0 1px 6px rgba(0,0,0,0.06);
  position: sticky; top: 0; z-index: 100;
}

.logo {
  display: flex; align-items: center;
  text-decoration: none !important; flex-shrink: 0;
}
.logo:hover { text-decoration: none !important; opacity: 0.92; }
.logo-img {
  height: 48px; width: auto; display: block;
}
.logo-icon {
  width: 30px; height: 30px; border-radius: 7px;
  background: var(--green); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800; flex-shrink: 0;
}
.logo-sub { font-size: 11px; color: var(--gray-400); font-weight: 400; }

.nav-links { display: flex; gap: 2px; margin-left: 16px; }
.nav-link {
  padding: 6px 14px; border-radius: var(--radius);
  color: var(--gray-600); font-size: 13px; font-weight: 500;
  transition: all .15s;
}
.nav-link:hover { background: var(--gray-100); color: var(--gray-900); text-decoration: none; }
.nav-link.active { background: var(--green-light); color: var(--green-dark); }

.user-pill {
  margin-left: auto; display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--gray-600);
}
.logout-btn {
  padding: 5px 12px; border-radius: var(--radius);
  border: 1px solid var(--gray-200); color: var(--gray-600);
  font-size: 12px; transition: all .15s;
}
.logout-btn:hover { background: var(--gray-100); color: var(--gray-900); text-decoration: none; }

/* ── Content ──────────────────────────────────────────────── */
.content { max-width: 1100px; margin: 0 auto; padding: 28px 24px; }

.page-title {
  font-size: 22px; font-weight: 700; margin-bottom: 20px; color: var(--gray-900);
}

/* ── Stat cards ───────────────────────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px;
}
.stat-card {
  background: #fff; border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200); padding: 18px 20px;
}
.stat-label {
  font-size: 11px; color: var(--gray-400); text-transform: uppercase;
  letter-spacing: .5px; font-weight: 600; margin-bottom: 8px;
}
.stat-val { font-size: 30px; font-weight: 800; }
.stat-val.c-total { color: var(--gray-900); }
.stat-val.c-pass  { color: var(--green-dark); }
.stat-val.c-fail  { color: var(--red); }
.stat-val.c-warn  { color: var(--amber); }

/* ── Card / panel ─────────────────────────────────────────── */
.panel {
  background: #fff; border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200); overflow: hidden; margin-bottom: 20px;
}
.panel-title {
  font-size: 12px; font-weight: 700; color: var(--gray-400);
  text-transform: uppercase; letter-spacing: .5px;
  padding: 12px 18px; border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
}

/* ── Tables ───────────────────────────────────────────────── */
.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: var(--gray-400);
  text-transform: uppercase; letter-spacing: .4px;
  border-bottom: 1px solid var(--gray-200); background: var(--gray-50);
}
.data-table td {
  padding: 11px 18px; border-bottom: 1px solid var(--gray-100);
  color: var(--gray-900); vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--gray-50); }
.data-table td strong { font-weight: 700; }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 3px 9px;
  border-radius: 20px; font-size: 11px; font-weight: 700; white-space: nowrap;
}
.badge-pass    { background: var(--green-mid); color: #065f46; }
.badge-fail    { background: var(--red-light); color: #991b1b; }
.badge-overdue { background: var(--red-light); color: #991b1b; }
.badge-due     { background: var(--amber-light); color: #92400e; }
.badge-ok      { background: var(--green-mid); color: #065f46; }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--gray-600); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .3px;
}
.form-input, .form-select {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--gray-200); border-radius: var(--radius);
  font-family: inherit; font-size: 14px; color: var(--gray-900);
  background: #fff; transition: border-color .15s, box-shadow .15s;
}
.form-input:focus, .form-select:focus {
  outline: none; border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(29,158,117,.12);
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius);
  font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; border: none; transition: all .15s; text-decoration: none !important;
}
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); color: #fff; }
.btn-secondary {
  background: #fff; color: var(--gray-600);
  border: 1px solid var(--gray-200);
}
.btn-secondary:hover { background: var(--gray-100); color: var(--gray-900); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }

/* ── Alert messages ───────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: var(--radius);
  font-size: 13px; margin-bottom: 16px; border-left: 3px solid;
}
.alert-success { background: var(--green-light); color: var(--green-dark); border-color: var(--green); }
.alert-error   { background: var(--red-light); color: #991b1b; border-color: var(--red); }
.alert-info    { background: #eff6ff; color: #1e40af; border-color: #3b82f6; }

/* ── Search bar ───────────────────────────────────────────── */
.search-row { display: flex; gap: 8px; margin-bottom: 20px; }
.search-row .form-input { flex: 1; }
.search-row .form-select { width: 160px; }

/* ── Drop zone ────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--gray-200); border-radius: var(--radius-lg);
  padding: 56px 40px; text-align: center; cursor: pointer;
  background: #fff; transition: all .2s;
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--green); background: var(--green-light);
}
.drop-zone h3 { font-size: 17px; font-weight: 700; margin: 12px 0 6px; }
.drop-zone p  { font-size: 13px; color: var(--gray-400); }
.drop-icon    { font-size: 44px; line-height: 1; }

.progress-wrap {
  background: var(--gray-200); border-radius: 4px; height: 6px;
  margin-top: 16px; overflow: hidden; display: none;
}
.progress-bar { height: 6px; background: var(--green); width: 0; transition: width .4s; }
.import-log {
  margin-top: 14px; background: #0f172a; border-radius: var(--radius-lg);
  padding: 16px; font-family: 'Courier New', monospace; font-size: 12px;
  color: #a3e635; max-height: 200px; overflow-y: auto; line-height: 1.7; display: none;
}

/* ── Asset card (search results) ─────────────────────────── */
.asset-card {
  background: #fff; border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg); padding: 18px 20px;
  margin-bottom: 12px; transition: box-shadow .15s;
}
.asset-card:hover { box-shadow: var(--shadow-md); }
.asset-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.asset-id   { font-size: 16px; font-weight: 800; color: var(--gray-900); }
.asset-desc { font-size: 13px; color: var(--gray-400); margin-top: 3px; }
.asset-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.asset-meta {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; font-size: 12px;
}
.meta-item label { display: block; color: var(--gray-400); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; margin-bottom: 3px; }
.meta-item span  { color: var(--gray-900); font-weight: 500; }

/* ── Reminder cards ───────────────────────────────────────── */
.reminder-card {
  background: #fff; border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg); padding: 16px 20px;
  margin-bottom: 10px; display: flex; align-items: center; gap: 14px;
}
.reminder-icon {
  width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.reminder-icon.overdue { background: var(--red-light); }
.reminder-icon.soon    { background: var(--amber-light); }
.reminder-info { flex: 1; }
.reminder-info .r-id   { font-size: 14px; font-weight: 700; }
.reminder-info .r-sub  { font-size: 12px; color: var(--gray-400); margin-top: 2px; }
.reminder-info .r-date { font-size: 12px; color: var(--gray-600); margin-top: 4px; }

/* ── Certificate modal ────────────────────────────────────── */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 20px; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-bg.open { opacity: 1; pointer-events: all; }
.modal {
  background: #fff; border-radius: var(--radius-lg);
  padding: 28px; width: 100%; max-width: 580px;
  max-height: 90vh; overflow-y: auto;
  transform: translateY(12px); transition: transform .2s;
}
.modal-bg.open .modal { transform: translateY(0); }
.modal-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;
}
.modal-title { font-size: 17px; font-weight: 700; }
.modal-close {
  background: none; border: none; font-size: 20px; cursor: pointer;
  color: var(--gray-400); padding: 4px; line-height: 1;
}
.modal-close:hover { color: var(--gray-900); }

/* ── Certificate content ──────────────────────────────────── */
.cert-header {
  text-align: center; padding: 18px; background: var(--green-light);
  border-radius: var(--radius); margin-bottom: 16px; border: 1px solid #a7f3d0;
}
.cert-company   { font-size: 20px; font-weight: 800; color: #065f46; }
.cert-subtitle  { font-size: 12px; color: var(--green); margin-top: 4px; }
.cert-status {
  text-align: center; padding: 12px; border-radius: var(--radius);
  margin-bottom: 16px; font-size: 16px; font-weight: 800;
}
.cert-status.pass { background: var(--green-mid); color: #065f46; }
.cert-status.fail { background: var(--red-light); color: #991b1b; }
.cert-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.cert-field label { font-size: 10px; color: var(--gray-400); text-transform: uppercase; font-weight: 700; letter-spacing: .4px; display: block; margin-bottom: 3px; }
.cert-field span  { font-size: 13px; font-weight: 600; color: var(--gray-900); }
.cert-tests { margin-bottom: 16px; }
.cert-tests table { width: 100%; border-collapse: collapse; font-size: 13px; border: 1px solid var(--gray-200); border-radius: var(--radius); overflow: hidden; }
.cert-tests th { padding: 8px 12px; background: var(--gray-50); font-size: 11px; color: var(--gray-400); text-transform: uppercase; letter-spacing: .3px; text-align: left; }
.cert-tests td { padding: 8px 12px; border-top: 1px solid var(--gray-100); }
.cert-footer { font-size: 11px; color: var(--gray-400); text-align: center; border-top: 1px solid var(--gray-200); padding-top: 14px; line-height: 1.7; }

/* ── Login page ───────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--gray-100);
}
.login-card {
  background: #fff; border-radius: var(--radius-lg);
  padding: 40px; width: 100%; max-width: 400px;
  border: 1px solid var(--gray-200); box-shadow: var(--shadow-md);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .logo-icon { width: 48px; height: 48px; font-size: 22px; margin: 0 auto 10px; }
.login-logo .login-logo-img { height: 70px; width: auto; margin: 0 auto 16px; display: block; }
.login-logo h1 { font-size: 22px; font-weight: 800; }
.login-logo p  { font-size: 13px; color: var(--gray-400); margin-top: 4px; }

/* ── Admin table ──────────────────────────────────────────── */
.admin-section { margin-bottom: 32px; }
.admin-section h2 { font-size: 16px; font-weight: 700; margin-bottom: 14px; }

/* ── Empty state ──────────────────────────────────────────── */
.empty-state { text-align: center; padding: 64px 20px; color: var(--gray-400); }
.empty-state .e-icon { font-size: 48px; margin-bottom: 14px; }
.empty-state p { font-size: 15px; }

/* ── History list ─────────────────────────────────────────── */
.history-item {
  padding: 14px 18px; border-bottom: 1px solid var(--gray-100); font-size: 13px;
}
.history-item:last-child { border-bottom: none; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .asset-meta { grid-template-columns: repeat(2, 1fr); }
  .cert-grid  { grid-template-columns: 1fr; }
  .nav-links  { display: none; }
  .topbar     { padding: 0 16px; }
  .content    { padding: 20px 16px; }
}

@media print {
  .topbar, .nav-links, .btn, .modal-close { display: none !important; }
}
