:root {
  --bg: #f0f4f3;
  --card: #ffffff;
  --text: #16211f;
  --muted: #5b6b68;
  --border: #e1e8e6;
  --primary: #0f766e;
  --primary-dark: #0b5c56;
  --primary-light: #ecfaf8;
  --danger: #dc2626;
  --danger-dark: #b91c1c;
  --warn-bg: #fff7ed;
  --warn-text: #c2410c;
  --warn-accent: #f59e0b;
  --expired-bg: #fef2f2;
  --expired-text: #b91c1c;
  --expired-accent: #ef4444;
  --ok-bg: #f0fdf4;
  --ok-text: #15803d;
  --ok-accent: #22c55e;
  --shadow: 0 1px 2px rgba(16, 24, 22, 0.04), 0 1px 12px rgba(16, 24, 22, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 28px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
}
.brand-text h1 { font-size: 16px; margin: 0; line-height: 1.2; }
.brand-text .tagline { font-size: 12px; color: var(--muted); }

.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar form { margin: 0; }

.menu { position: relative; }
.menu > summary {
  list-style: none;
  width: 36px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary:hover { background: var(--bg); }
.menu > summary span { width: 16px; height: 2px; background: var(--text); border-radius: 1px; }
.menu-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  min-width: 170px;
  overflow: hidden;
  z-index: 20;
}
.menu-dropdown a, .menu-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 500;
  background: none;
  border: none;
  border-radius: 0;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}
.menu-dropdown a:hover, .menu-dropdown button:hover { background: var(--bg); }

.container { max-width: 1140px; margin: 28px auto; padding: 0 20px 40px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
}

h2 { margin-top: 0; font-size: 15px; font-weight: 700; }
.section-sub { color: var(--muted); font-size: 13px; margin: -8px 0 16px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stat-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
  border-top: 3px solid var(--accent, var(--primary));
}
.stat-tile .stat-value { font-size: 28px; font-weight: 700; line-height: 1.1; }
.stat-tile .stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .02em; }
.stat-tile.total { --accent: var(--primary); }
.stat-tile.valid { --accent: var(--ok-accent); }
.stat-tile.expiring { --accent: var(--warn-accent); }
.stat-tile.expired { --accent: var(--expired-accent); }

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

label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }

input[type=text], input[type=tel], input[type=date], input[type=password], select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
select { cursor: pointer; }
input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
input:disabled { background: var(--bg); color: var(--muted); }

button, .btn {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background .15s, transform .1s;
}
button:hover, .btn:hover { background: var(--primary-dark); }
button:active, .btn:active { transform: translateY(1px); }

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: var(--danger-dark); }
.btn-secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--bg); }
tbody tr:last-child td { border-bottom: none; }

.badge { padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; display: inline-block; }
.badge-ok { background: var(--ok-bg); color: var(--ok-text); }
.badge-warn { background: var(--warn-bg); color: var(--warn-text); }
.badge-expired { background: var(--expired-bg); color: var(--expired-text); }

.actions { display: flex; gap: 6px; }
.actions a, .actions button { font-size: 12.5px; padding: 6px 12px; }

.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(circle at top left, var(--primary-light), var(--bg) 60%);
}

.login-card { width: 360px; text-align: center; }
.login-card .brand-mark { margin: 0 auto 14px; width: 46px; height: 46px; font-size: 18px; }
.login-card h2 { font-size: 18px; margin-bottom: 2px; }
.login-card .section-sub { margin-bottom: 20px; }
.login-card form { text-align: left; }
.login-card button { width: 100%; margin-top: 4px; padding: 11px; }

.error-text {
  color: var(--expired-text);
  background: var(--expired-bg);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 14px;
  text-align: left;
}
.muted { color: var(--muted); font-size: 13px; }
.search-bar { margin-bottom: 18px; display: flex; gap: 10px; }
.search-bar input { max-width: 420px; }

.empty-state { text-align: center; padding: 32px 0; color: var(--muted); }
