:root{
  --bg1: #eaf4ff;
  --bg2: #ffffff;
  --card: rgba(255,255,255,0.75);
  --stroke: rgba(30, 64, 175, 0.14);
  --text: #0b1633;
  --muted: rgba(11, 22, 51, 0.65);
  --primary: #2f7cf6;
  --primary2: #6bb6ff;
  --shadow: 0 10px 30px rgba(15, 38, 84, 0.10);
  --radius: 16px;
}

*{ box-sizing: border-box; }

html, body{ height: 100%; }

body{
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background-color: #f4f8ff;
}

.topbar{
  background: linear-gradient(
    180deg,
    rgba(235,244,255,0.95),
    rgba(255,255,255,0.85)
  );
}

.container{
  width: min(1100px, 92vw);
  margin: 18px auto 48px;
}

.view{ margin-top: 18px; }
.hidden{ display: none !important; }

.card{
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.small{ font-size: 0.92rem; }
.muted{ color: var(--muted); }
.req{ color: var(--primary); font-weight: 700; }

.topbar{
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255,255,255,0.65);
  border-bottom: 1px solid var(--stroke);
  backdrop-filter: blur(12px);
}

.topbar-inner{
  width: min(1100px, 92vw);
  margin: 0 auto;
  padding: 16px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand{
  display: flex;
  align-items: center;
  gap: 12px;
}

h1{
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: 0.2px;
}

.tabs{
  display: flex;
  gap: 10px;
}

.tab{
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,0.55);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform .05s ease, background .15s ease;
}

.tab:active{ transform: translateY(1px); }

.tab.is-active{
  background: linear-gradient(135deg, rgba(47,124,246,0.18), rgba(107,182,255,0.22));
  border-color: rgba(47,124,246,0.25);
}

.toolbar{
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-title{
  margin: 0;
  font-size: 1.1rem;
}

.btn{
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,0.6);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform .05s ease, box-shadow .15s ease, background .15s ease;
}

.btn:active{ transform: translateY(1px); }

.btn-primary{
  background: linear-gradient(135deg, rgba(47,124,246,0.95), rgba(107,182,255,0.95));
  border-color: rgba(47,124,246,0.35);
  color: white;
  box-shadow: 0 10px 22px rgba(47,124,246,0.22);
}

.btn-ghost{ background: transparent; }

.table-wrap{
  margin-top: 14px;
  padding: 10px;
}

.table{
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 12px;
}

.table thead{
  background: linear-gradient(135deg, rgba(47,124,246,0.10), rgba(107,182,255,0.12));
}

.table th, .table td{
  padding: 10px 10px;
  border-bottom: 1px solid rgba(30, 64, 175, 0.12);
  text-align: left;
  font-size: 0.95rem;

  /* IMPORTANT: keep headers aligned nicely */
  vertical-align: middle;
}

.table tbody tr:hover{
  background: rgba(47,124,246,0.05);
}

.actions-col{ width: 170px; }

/* Row action buttons */
.row-actions{
  display: flex;
  gap: 8px;
  align-items: center;
}

.row-actions .btn{
  padding: 6px 10px;
  font-size: 0.85rem;
  border-radius: 8px;
  box-shadow: none;
}

/* Edit button */
.btn-edit{
  background: linear-gradient(
    135deg,
    rgba(47,124,246,0.15),
    rgba(107,182,255,0.18)
  );
  border: 1px solid rgba(47,124,246,0.35);
  color: #1e3a8a;
}
.btn-edit:hover{
  background: linear-gradient(
    135deg,
    rgba(47,124,246,0.25),
    rgba(107,182,255,0.28)
  );
}

/* Delete button */
.btn-delete{
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.35);
  color: rgba(127,29,29,0.9);
}
.btn-delete:hover{ background: rgba(239,68,68,0.18); }

.form-card{ padding: 16px; }

.form-header{
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.form{ margin-top: 12px; }

.grid{
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

label{
  display: grid;
  gap: 6px;
  font-size: 0.95rem;
}

input, select{
  font: inherit;
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,0.7);
  outline: none;
}

input:focus, select:focus{
  border-color: rgba(47,124,246,0.35);
  box-shadow: 0 0 0 4px rgba(47,124,246,0.12);
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button{
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"]{
  -moz-appearance: textfield;
  appearance: textfield;
}

.error{
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.08);
  color: rgba(127, 29, 29, 0.95);
}

.form-actions{
  margin-top: 14px;
  display: flex;
  gap: 10px;
}

.empty{ padding: 12px 10px 2px; }

#statsView > .card{ padding: 22px; }

.stats-grid{
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.stat{
  border: 2px solid var(--stroke);
  border-radius: 14px;
  padding: 14px;
  background: rgba(255,255,255,0.60);
}

.stat-label{
  color: var(--muted);
  font-size: 0.9rem;
}

.stat-value{
  margin-top: 6px;
  font-size: 1.6rem;
  letter-spacing: 0.2px;
}

@media (max-width: 900px){
  .grid{ grid-template-columns: 1fr 1fr; }
  .stats-grid{ grid-template-columns: 1fr 1fr; }
  .topbar-inner{ flex-direction: column; align-items: flex-start; }
}

@media (max-width: 560px){
  .grid{ grid-template-columns: 1fr; }
  .stats-grid{ grid-template-columns: 1fr; }
  .row-actions{ flex-direction: column; align-items: flex-start; }
}

/* Pager improvements */
.pager{
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pager .btn{
  border-radius: 999px;
  padding: 8px 12px;
}

.pager-center{
  display: flex;
  align-items: center;
  gap: 10px;
}

.pager-indicator{
  text-align: center;
  flex: 1;
}

.pager-size{
  display: flex;
  align-items: center;
  gap: 6px;
}

.pager-size select{
  width: 60px;
  height: 30px;
  padding: 2px 6px;
  font-size: 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,0.6);
  box-shadow: none;
}

.pager-size select:focus{
  outline: none;
  box-shadow: 0 0 0 2px rgba(47,124,246,0.15);
}

.small-btn{
  padding: 6px 10px;
  font-size: 0.9rem;
}

/* Compact Search Bar */
.search-compact{
  padding: 10px 16px;
  margin-top: 12px;
}

.search-inline{
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-label{
  font-size: 0.85rem;
  color: var(--muted);
}

.search-box{
  height: 32px;
  padding: 6px 10px;
  font-size: 0.9rem;
  border-radius: 10px;
  width: min(520px, 70vw);
}

.search-hint{ margin-top: 8px; }
.search-hint.hidden{ display: none !important; }

/* Sortable table headers */
th.sortable{
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 22px; /* space for arrow */
}

th.sortable:hover{
  background: rgba(47,124,246,0.06);
}

th.sortable::after{
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.35;
  font-size: 0.9rem;
}

th.sortable[data-dir="asc"]::after{
  content: "▲";
  opacity: 0.75;
}

th.sortable[data-dir="desc"]::after{
  content: "▼";
  opacity: 0.75;
}

/* ----------------------------- */
/* PERFECT Type column alignment */
/* ----------------------------- */

/* Ensure the whole row centers consistently */
.table tbody td{
  vertical-align: middle;
}

/* Make the Type cell a stable flex row */
.table td.type-cell{
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1;     /* prevents font baseline “drop” */
}

/* Create a fixed “slot” so every icon occupies the same box */
.table td.type-cell .type-icon{
  width: 24px;
  height: 24px;
  display: block;     /* kills inline-image baseline spacing */
  flex: 0 0 24px;
  object-fit: contain;
}

.table td.type-cell{
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1;
}

.type-icon-box{
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 24px;
}

/* Make all table cells align consistently */
.table th, .table td {
  vertical-align: middle;
  line-height: 1.2;
}

/* Type column wrapper (don’t flex the TD itself) */
.type-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Icon sizing + remove baseline weirdness */
.type-icon {
  width: 24px;
  height: 24px;
  display: block;
  object-fit: contain;
}
/* Banner / toast notifications */
.banner{
  position: sticky;
  top: 72px;
  z-index: 20;
  width: min(1100px, 92vw);
  margin: 10px auto 0;
  padding: 12px 14px;
  border-radius: 14px;

  /* Make it NOT blend weirdly with the glass UI */
  background: #f6fbff; /* solid light background */
  border: 1px solid rgba(30, 64, 175, 0.18);
  box-shadow: 0 10px 22px rgba(15, 38, 84, 0.10);

  font-weight: 650;
}

.banner.hidden{ display: none !important; }

.banner.success{
  background: #f2fff6;
  border-color: rgba(34,197,94,0.22);
}

.banner.error{
  background: #fff5f5;
  border-color: rgba(239,68,68,0.22);
}