@font-face {
  font-family: "IBM Plex Sans";
  src: url("../fonts/IBMPlexSans-VariableFont_wdth,wght.ttf") format("truetype");
  font-weight: 100 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("../fonts/IBMPlexSans-Italic-VariableFont_wdth,wght.ttf") format("truetype");
  font-weight: 100 700;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Serif";
  src: url("../fonts/IBMPlexSerif-Light.ttf") format("truetype");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Serif";
  src: url("../fonts/IBMPlexSerif-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Serif";
  src: url("../fonts/IBMPlexSerif-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Serif";
  src: url("../fonts/IBMPlexSerif-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

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

body {
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  background: #f0f2f5;
  color: #1a1a2e;
  min-height: 100vh;
  padding: 2rem 1rem;
}

h1 {
  text-align: center;
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 2rem;
  color: #1a1a2e;
  letter-spacing: -0.5px;
}

h1 span {
  color: #2563eb;
}

.container {
  max-width: 900px;
  margin: 0 auto;
}

/* Form Card */
.card {
  background: #fff;
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.07);
  margin-bottom: 2rem;
}

.card h2 {
  font-size: 1rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 1.25rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
}

input {
  padding: 0.65rem 0.9rem;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  font-size: 1rem;
  color: #1a1a2e;
  background: #f9fafb;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}

input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
  background: #fff;
}

input[readonly] {
  color: #6b7280;
  cursor: default;
}

button {
  padding: 0.7rem 1.6rem;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
  align-self: flex-end;
}

button:hover { background: #1d4ed8; }
button:active { transform: scale(0.97); }

/* Stats Bar */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: #fff;
  border-radius: 14px;
  padding: 1.1rem 1.3rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  border-left: 4px solid #2563eb;
}

.stat-card.green  { border-color: #16a34a; }
.stat-card.amber  { border-color: #d97706; }
.stat-card.purple { border-color: #7c3aed; }

.stat-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 0.3rem;
}

.stat-value {
  font-size: 1.35rem;
  font-weight: 700;
  color: #1a1a2e;
}

/* Table Card */
.table-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.07);
  overflow: hidden;
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #f3f4f6;
}

.table-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.btn-clear {
  padding: 0.4rem 1rem;
  background: #fee2e2;
  color: #dc2626;
  border: none;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-clear:hover { background: #fecaca; }

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

thead {
  background: #f8fafc;
}

th {
  padding: 0.85rem 1rem;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 700;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid #f3f4f6;
}

td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid #f9fafb;
  color: #374151;
}

tr:last-child td { border-bottom: none; }

tbody tr {
  transition: background 0.15s;
}

tbody tr:hover { background: #f8fafc; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.badge-blue   { background: #eff6ff; color: #2563eb; }
.badge-green  { background: #f0fdf4; color: #16a34a; }

.btn-del {
  background: none;
  border: none;
  color: #d1d5db;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  border-radius: 6px;
  font-size: 1rem;
  transition: color 0.2s, background 0.2s;
}

.btn-del:hover { color: #dc2626; background: #fee2e2; }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #9ca3af;
}

.empty-state .icon { font-size: 3rem; margin-bottom: 0.75rem; }
.empty-state p { font-size: 0.95rem; }

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: #1a1a2e;
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  z-index: 100;
}

.toast.show { opacity: 1; transform: translateY(0); }

/* Analytics toggle bar */
.stats-toggle-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.stats-toggle-btn {
  padding: 0.3rem 0.85rem;
  border: 1.5px solid #e5e7eb;
  border-radius: 999px;
  background: #fff;
  color: #9ca3af;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: "IBM Plex Sans", sans-serif;
}

.stats-toggle-btn.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.stats-row { transition: opacity 0.2s; }
.stats-row.hidden { display: none; }

/* Login overlay */
.login-overlay {
  position: fixed;
  inset: 0;
  background: #f0f2f5;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}

.login-overlay.hidden { display: none; }

.login-card {
  background: #fff;
  border-radius: 20px;
  padding: 2.5rem 2rem;
  box-shadow: 0 8px 32px rgba(0,0,0,0.10);
  width: 100%;
  max-width: 380px;
}

.login-card h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 0.3rem;
}

.login-card p {
  font-size: 0.88rem;
  color: #6b7280;
  margin-bottom: 1.75rem;
}

.login-card .field { margin-bottom: 1rem; }

.login-card button {
  width: 100%;
  margin-top: 0.5rem;
  align-self: unset;
}

.login-error {
  background: #fee2e2;
  color: #dc2626;
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 1rem;
  display: none;
}

.login-error.show { display: block; }

/* Header bar with logout */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
}

.top-bar h1 { margin-bottom: 0; }

.btn-logout {
  padding: 0.4rem 1rem;
  background: #f3f4f6;
  color: #6b7280;
  border: none;
  border-radius: 8px;
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  align-self: unset;
}

.btn-logout:hover { background: #fee2e2; color: #dc2626; }

.home-link {
  font-size: 0.8rem;
  color: #9ca3af;
  text-decoration: none;
  transition: color 0.2s;
}

.home-link:hover { color: #2563eb; }

/* Export dropdown */
.export-wrap { position: relative; }

.btn-export {
  padding: 0.4rem 1rem;
  background: #f9fafb;
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #374151;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  align-self: unset;
}

.btn-export:hover { border-color: #2563eb; color: #2563eb; background: #eff6ff; }

.export-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: #fff;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.10);
  min-width: 130px;
  z-index: 50;
  overflow: hidden;
  display: none;
}

.export-menu.open { display: block; }

.export-menu button {
  display: block;
  width: 100%;
  padding: 0.65rem 1rem;
  text-align: left;
  background: none;
  border: none;
  border-radius: 0;
  font-size: 0.85rem;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  align-self: unset;
  transform: none;
}

.export-menu button:hover { background: #f8fafc; color: #2563eb; }

@media (max-width: 500px) {
  .form-grid { grid-template-columns: 1fr; }
  h1 { font-size: 1.4rem; }
}

footer {
  max-width: 900px;
  margin: 2rem auto 0;
  padding: 1.5rem 1rem 2rem;
  border-top: 1px solid #e5e7eb;
  text-align: center;
  font-size: 0.83rem;
  color: #9ca3af;
}

footer a {
  color: #6b7280;
  text-decoration: none;
  transition: color 0.2s;
}

footer a:hover { color: #2563eb; }

.footer-note {
  margin-top: 0.4rem;
  font-size: 0.78rem;
  color: #d1d5db;
}
