:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #161b22;
  --muted: #687385;
  --line: #e1e5ea;
  --soft: #f1f4f7;
  --primary: #2454d6;
  --primary-dark: #1d3fa3;
  --success: #157347;
  --warning: #a15c05;
  --danger: #b42318;
  --info: #2454d6;
  --shadow: 0 12px 30px rgba(22, 27, 34, 0.06);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 18px; line-height: 1.2; letter-spacing: 0; }
h2 { font-size: 28px; line-height: 1.15; letter-spacing: 0; }
h3 { font-size: 16px; line-height: 1.25; }
p { color: var(--muted); line-height: 1.55; }

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(120deg, rgba(36, 84, 214, 0.14), rgba(21, 115, 71, 0.1)),
    #f6f7f9;
}

.auth-card {
  width: min(100%, 420px);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.logo {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
  background: #161b22;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.tab {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-weight: 800;
}

.tab + .tab { border-left: 1px solid var(--line); }
.tab.active { background: var(--soft); color: var(--text); }
.auth-form, .form-grid { display: grid; gap: 12px; }

label { display: grid; gap: 7px; color: #344054; font-size: 13px; font-weight: 800; }
input, select {
  width: 100%;
  min-height: 42px;
  border: 1px solid #ccd3dc;
  border-radius: 8px;
  padding: 0 11px;
  outline: none;
  background: #fff;
  color: var(--text);
}
input[type="file"] { padding: 8px 11px; }
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(36, 84, 214, 0.12); }

.btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: #344054;
  font-weight: 850;
  white-space: nowrap;
}
.btn.primary { border-color: var(--primary); background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.good { border-color: #bbf7d0; background: #f0fdf4; color: var(--success); }
.btn.bad { border-color: #fecaca; background: #fef2f2; color: var(--danger); }
.btn.full { width: 100%; margin-top: 4px; }
.error { color: var(--danger); font-size: 13px; font-weight: 800; }
.message { color: var(--success); font-size: 13px; font-weight: 800; }

.topbar {
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.topbar-inner {
  width: min(1320px, calc(100% - 32px));
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 auto;
}
.topbar .brand { margin-bottom: 0; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.shell {
  width: min(1320px, calc(100% - 32px));
  display: grid;
  grid-template-columns: 206px minmax(0, 1fr);
  gap: 18px;
  margin: 0 auto;
  padding: 18px 0 40px;
}

.sidebar {
  align-self: start;
  position: sticky;
  top: 18px;
  display: grid;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}
.nav-group {
  display: grid;
  gap: 4px;
}
.nav-title {
  padding: 0 8px 3px;
  color: #8a94a6;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}
.nav-btn {
  min-height: 38px;
  display: flex;
  align-items: center;
  border-radius: 8px;
  padding: 0 10px;
  color: #4d596b;
  font-size: 14px;
  font-weight: 800;
}
.nav-btn:hover { background: #f4f6fb; color: var(--primary); }
.nav-btn.active { background: #eef2ff; color: var(--primary-dark); box-shadow: inset 3px 0 0 var(--primary); }

.content { display: grid; gap: 16px; min-width: 0; }
.page-title {
  display: grid;
  gap: 6px;
  padding: 4px 0 2px;
}

.panel, .metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.panel { padding: 16px; overflow: hidden; }
.form-panel { max-width: 860px; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.metric { padding: 15px; }
.metric span { color: var(--muted); font-size: 12px; font-weight: 900; text-transform: uppercase; }
.metric strong { display: block; margin-top: 8px; font-size: 26px; line-height: 1; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}
table { width: 100%; min-width: 980px; border-collapse: collapse; font-size: 14px; background: #fff; table-layout: auto; }
.wide-table { min-width: 1420px; }
thead th { background: #f8fafc; border-top: 0; }
th, td { padding: 12px 11px; border-top: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}
.badge.ok { background: #dcfce7; color: var(--success); }
.badge.wait { background: #fef3c7; color: var(--warning); }
.badge.bad { background: #fee2e2; color: var(--danger); }
.badge.info { background: #dbeafe; color: var(--info); }

.inline {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.table-action { margin-top: 14px; }
.upload-inline { display: grid; grid-template-columns: minmax(190px, 1fr) auto; gap: 8px; align-items: center; }
.certificate-form {
  display: grid;
  grid-template-columns: 140px 120px 120px minmax(170px, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-width: 650px;
}
.type-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.type-chip {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 4px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: #344054;
  font-size: 13px;
  font-weight: 800;
}
.empty {
  padding: 18px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  color: var(--muted);
  background: #f8fafc;
  font-weight: 800;
}
.hidden { display: none !important; }

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .auth-card { padding: 20px; }
  .topbar-inner { align-items: flex-start; flex-direction: column; padding: 12px 0; }
  .shell { width: min(100% - 22px, 1320px); }
  .sidebar, .metrics, .inline, .upload-inline, .certificate-form { grid-template-columns: 1fr; }
  .panel-head { align-items: flex-start; flex-direction: column; }
  h2 { font-size: 24px; }
}
