/* ═══════════════════════════════════════════════════════════
   common.css  —  Single stylesheet for all pages.
   To restyle the app, edit only this file.
═══════════════════════════════════════════════════════════ */

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

:root { --header-h: 56px; }

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #f0f2f5;
  color: #333;
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────────── */
header {
  /* background: #1a73e8; */
  background:   #1a73e8;
  color: #fff;
  padding: 10px 20px;
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* Stay pinned to the top while the page scrolls */
  position: sticky;
  top: 0;
  height: var(--header-h);
  z-index: 200;
}

.header-left { display: flex; align-items: center; gap: 10px; }
.header-right { display: flex; align-items: center; gap: 12px; }

/* Logo + title brand group (injected by common.js from config.js) */
.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-logo {
  width: 60px;
  height: 36px;
  object-fit: contain;
  flex-shrink: 0;
}

.header-title {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  /* color: #050505; */
  color: #ffffff;
}

/* Role badge next to profile icon */
.header-role-badge {
  font-size: 1rem;
  /* background: rgba(255,255,255,0.18); */
  /* border: 1px solid rgba(255,255,255,0.38); */
  /* color: #050505; */
  color: #ffffff;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 500;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

/* ── Profile dropdown ──────────────────────────────────── */
.profile-wrapper { position: relative; }

.profile-btn {
  background: rgba(10, 10, 10, 0.2);
  border: 2px solid rgba(255,255,255,0.5);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.profile-btn:hover { background: rgba(255,255,255,0.32); }

.profile-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #fff;
  color: #050505;
  font-size: 0.88rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.profile-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  min-width: 230px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.16);
  border: 1px solid #e4e8ee;
  z-index: 1100;
  overflow: hidden;
  animation: dropIn 0.15s ease;
}
.profile-menu.open { display: block; }

@keyframes dropIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.profile-menu-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: #f8f9fc;
}

.profile-menu-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #1a73e8;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.profile-menu-text { min-width: 0; }

.profile-menu-email {
  font-size: 0.84rem;
  color: #222;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-menu-role {
  font-size: 0.73rem;
  color: #888;
  margin-top: 3px;
}

.profile-divider { border: none; border-top: 1px solid #eee; margin: 0; }

.profile-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 11px 16px;
  font-size: 0.88rem;
  color: #333;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.profile-menu-item:hover { background: #f0f4ff; color: #1a73e8; }
.profile-menu-logout:hover { background: #fff5f5; color: #d32f2f; }

/* ── Layout ─────────────────────────────────────────────── */
.layout { display: flex; min-height: calc(100vh - var(--header-h)); }

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: 270px;
  background: #fff;
  border-right: 1px solid #dde1e7;
  padding: 20px 0;
  flex-shrink: 0;
  /* Stay pinned beside the content while the page scrolls */
  position: sticky;
  top: var(--header-h);
  align-self: flex-start;
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
}

.sidebar h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #888;
  padding: 0 18px 10px;
}

.sidebar ul { list-style: none; }

.sidebar ul li a {
  display: block;
  padding: 5px 18px;
  text-decoration: none;
  color: #444;
  font-size: 0.9rem;
  border-left: 3px solid transparent;
  cursor: default;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.sidebar ul li a:hover{
  background: #98e38e;
  color: #1a73e8;
  border-left-color: #1a73e8;
}
.sidebar ul li a.active {
  background: #98e38e;
  color: #056bf0;
  border-left-color: #1a73e8;
  /* font-weight: bold; */
}

.sidebar ul li a .icon { margin-right: 5px; }

/* ── Content Mapping group label ─────────── */
.sidebar ul li.nav-group-label {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #aaa;
  padding: 12px 18px 4px;
  font-weight: 600;
}

/* ── Expandable nav item (e.g. Content Mapping, Admin) ── */
.sidebar ul li.nav-expandable > a.nav-toggle {
  display: flex;
  align-items: center;
}

.nav-arrow {
  font-style: normal;
  font-size: 1.2rem;
  transition: transform 0.2s ease;
  margin-left: auto;
  padding-left: 6px;
}

.nav-expandable.expanded > a.nav-toggle .nav-arrow {
  transform: rotate(180deg);
}

.sidebar ul .nav-sub {
  display: none;
  list-style: none;
  padding: 3px;
  background: #f8f9fc;
  border-left: 3px solid #1a73e8;
  margin-left: 5px;
}

.nav-expandable.expanded > .nav-sub {
  display: block;
}

.sidebar ul .nav-sub li a {
  padding: 9px 18px 9px 36px;
  font-size: 0.85rem;
  border-left: none;
  color: #555;
}

.sidebar ul .nav-sub li a:hover,
.sidebar ul .nav-sub li a.active {
  background: #98e38e;
  font-weight: bold;
  color: #056bf0;
}

.sidebar ul .nav-sub li a.nav-restricted,
.sidebar ul .nav-sub li a.nav-restricted:hover {
  color: #aaa;
  cursor: not-allowed;
  background: none;
  font-style: italic;
}

/* ── Nested expandable within nav-sub (e.g. Content Mapping inside Tara Buddy App) ── */
.sidebar ul .nav-sub .nav-sub-nested {
  border-left: 2px solid #12f06b;
  margin-left: 0;
  background: #f0f4fc;
}

.sidebar ul .nav-sub .nav-sub-nested li a {
  padding: 8px 18px 8px 52px;
  font-size: 0.82rem;
}

/* ── Main ───────────────────────────────────────────────── */
.main { flex: 1; padding: 24px; overflow-x: auto; }

.page-title {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 20px;
  color: #1a1a2e;
}

/* ── Toolbar ────────────────────────────────────────────── */
.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.toolbar input[type="text"] {
  flex: 1;
  min-width: 180px;
  padding: 9px 14px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.2s;
}

.toolbar input[type="text"]:focus {
  border-color: #1a73e8;
  box-shadow: 0 0 0 3px rgba(26,115,232,0.15);
}

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  padding: 9px 18px;
  border: none;
  border-radius: 6px;
  font-size: 0.92rem;
  font-weight: 500;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }

.btn-search { background: #1a73e8; color: #fff; }
.btn-search:hover { background: #1558b0; }

.btn-add { background: #34a853; color: #fff; }
.btn-add:hover { background: #277d3e; }

.btn-primary { background: #1a73e8; color: #fff; padding: 10px 20px; flex: 1; }
.btn-primary:hover { background: #1558b0; }

.btn-cancel { background: #e76262; color: #f1f3f4; padding: 10px 20px; flex: 1; }
.btn-cancel:hover { background: #db4b4b; }

.btn-choose-file { background: #1a73e8; color: #fff; padding: 8px 16px; }
.btn-choose-file:hover { background: #1558b0; }

/* ── Table ──────────────────────────────────────────────── */
.table-wrapper {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  overflow-x: auto;
}

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

/* ── Pagination (reusable: createPaginator in common.js) ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 14px;
}
.pagination:empty { display: none; }

.pg-info { font-size: 0.85rem; color: #5f6b7a; }

.pg-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pg-size {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: #5f6b7a;
  margin-right: 8px;
}
.pg-size-select {
  padding: 5px 8px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.85rem;
  background: #fff;
  color: #333;
  cursor: pointer;
  outline: none;
}
.pg-size-select:focus { border-color: #1a73e8; }

.pg-page { font-size: 0.85rem; color: #333; padding: 0 8px; white-space: nowrap; }

.pg-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid #d4d9e0;
  border-radius: 6px;
  background: #fff;
  color: #1a73e8;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.pg-btn:hover:not(:disabled) { background: #eef4ff; border-color: #1a73e8; }
.pg-btn:disabled { color: #b7c0cc; cursor: not-allowed; background: #f6f7f9; }

thead { background: #1a73e8; color: #fff; }

thead th {
  padding: 12px 14px;
  text-align: left;
  font-weight: 500;
  white-space: nowrap;
}

/* ── Detail page top bar ────────────────────────────── */
.detail-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}
.detail-add-btn { margin-left: auto; }

.btn-back {
  background: #f1f3f4;
  color: #333;
  border: 1px solid #ddd;
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.btn-back:hover { background: #e0e0e0; }

.detail-breadcrumb {
  font-size: 1rem;
  font-weight: 600;
  color: #1a1a2e;
}

/* ── Options cell (two buttons side-by-side) ─────────── */
.options-cell { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }

/* ── Content page filter bar ────────────────────────── */
.content-filter-bar { flex-wrap: wrap; gap: 10px; align-items: flex-end; }

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
   /* width: 150px; */
}
.filter-group label {
  font-size: 0.90rem;
  font-weight: 500;
  color: #161616;
  letter-spacing: 0.02em;
}

.content-filter-bar select {
  padding: 9px 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.9rem;
  outline: none;
  background: #fff;
  color: #333;
  cursor: pointer;
  min-width: 200px;
  transition: border-color 0.2s;
}
/* Book dropdown holds long "name | (....isbn)" labels — pin its width so the
   control doesn't resize with each selection; truncate overflow with ellipsis. */
.content-filter-bar select#filterBook {
  width: 260px;
  min-width: 260px;
  max-width: 260px;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}
.content-filter-bar select:focus {
  border-color: #1a73e8;
  box-shadow: 0 0 0 3px rgba(26,115,232,0.15);
}

/* ── Searchable dropdown (createSearchDropdown in common.js) ── */
.sd { position: relative; min-width: 200px; }

.sd-input {
  width: 100%;
  padding: 9px 30px 9px 12px;   /* room for the arrow on the right */
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #fff;
  color: #333;
  font-size: 0.9rem;
  outline: none;
  text-overflow: ellipsis;
  transition: border-color 0.2s;
}
.sd-input:focus {
  border-color: #1a73e8;
  box-shadow: 0 0 0 3px rgba(26,115,232,0.15);
}

.sd-arrow {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #777;
  font-size: 0.8rem;
  pointer-events: none;          /* clicks fall through to the input */
  transition: transform 0.15s;
}
.sd.open .sd-arrow { transform: translateY(-50%) rotate(180deg); }

.sd-menu {
  position: absolute;
  z-index: 60;
  top: calc(100% + 4px);
  left: 0;
  min-width: 100%;
  max-width: 320px;
  background: #fff;
  border: 1px solid #c8c8c8;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.16);
}
.sd-menu.hidden { display: none; }

.sd-list {
  list-style: none;
  max-height: 240px;
  overflow-y: auto;
  padding: 4px 0;
  margin: 0;
}
.sd-list li {
  padding: 8px 12px;
  font-size: 0.88rem;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sd-list li:hover,
.sd-list li.sd-active { background: #f0f4ff; }
.sd-list li.sd-selected { font-weight: 600; color: #1a73e8; }

.sd-empty {
  padding: 10px 12px;
  color: #999;
  font-size: 0.85rem;
  font-style: italic;
}

.search-group {
  position: relative;
  width: 200px;
  flex-shrink: 0;
}
.search-group input {
  width: 100%;
  padding-right: 36px;
}
.search-group .btn-search {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 4px 6px;
  color: #999;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
  transition: color 0.15s;
}
.search-group .btn-search:hover { color: #1a73e8; }

.btn-reset {
  background: none;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 1.05rem;
  cursor: pointer;
  color: #777;
  line-height: 1;
  transition: color 0.15s, border-color 0.15s, transform 0.2s;
  flex-shrink: 0;
}
.btn-reset:hover {
  color: #140303;
  border-color: #2f0aec;
  /* transform: rotate(-30deg); */
}

/* ── Small action buttons inside table rows ─────────── */
.btn-sm {
  padding: 5px 12px;
  font-size: 0.8rem;
  border-radius: 5px;
  border: none;
  cursor: pointer;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s;
}
.btn-add-row  { background: #34a853; color: #fff; }
.btn-add-row:hover  { background: #277d3e; }
.btn-detail   { background: #1a73e8; color: #fff; }
.btn-detail:hover   { background: #1558b0; }
.btn-edit     { background: #34a853; color: #fff; }
.btn-edit:hover     { background: #277d3e; }
.btn-delete         { background: #1a73e8; color: #fff; padding: 10px 20px; flex: 1; }
.btn-delete:hover   { background: #1558b0; }
.btn-sm.btn-delete  { background: #ed7a78; color: #fff; padding: 5px 12px; flex: none; }
.btn-sm.btn-delete:hover   { background: #b71c1c; }
.btn-sm.btn-delete.btn-disabled,
.btn-sm.btn-delete.btn-disabled:hover { background: #bdbdbd; cursor: not-allowed; opacity: 0.7; }

/* Generic disabled state for any small action button (covers btn-add-row,
   btn-edit, btn-detail, etc.). Handles both the HTML `disabled` attribute
   and the `btn-disabled` class. */
.btn-sm:disabled,
.btn-sm:disabled:hover,
.btn-sm.btn-disabled,
.btn-sm.btn-disabled:hover { background: #bdbdbd !important; color: #fff; cursor: not-allowed; opacity: 0.7; }

/* ── Page completion badges ─────────────────────────── */
.page-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 600;
}
.badge-done    { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.badge-partial { background: #fff8e1; color: #856404; border: 1px solid #ffe082; }
.badge-none    { background: #f5f5f5; color: #9e9e9e; border: 1px solid #e0e0e0; }

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.76rem;
  font-weight: 600;
}

/* ── Wide modal (details) ───────────────────────────── */
.modal-wide { max-width: 820px; }

/* ── Modal breadcrumb context line ─────────────────── */
.modal-context {
  font-size: 0.82rem;
  color: #666;
  background: #f5f7fa;
  border: 1px solid #e4e7ec;
  border-radius: 5px;
  padding: 7px 12px;
  margin-bottom: 14px;
  font-weight: 500;
}

/* ── Details table inside modal ─────────────────────── */
.details-scroll {
  max-height: 52vh;
  overflow-y: auto;
  border: 1px solid #e8e8e8;
  border-radius: 6px;
  margin-top: 6px;
}
.details-scroll table { font-size: 0.85rem; }
.details-empty {
  text-align: center;
  color: #aaa;
  padding: 32px;
  font-style: italic;
}
.link-cell {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Update modal read-only info row ────────────────── */
.update-info-row {
  display: flex;
  gap: 10px;
  background: #f5f7fa;
  border: 1px solid #e4e7ec;
  border-radius: 6px;
  padding: 10px 14px;
  flex-wrap: wrap;
}
.update-info-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 80px;
}
.info-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #888;
  font-weight: 600;
}
.info-value {
  font-size: 0.9rem;
  font-weight: 600;
  color: #1a1a2e;
}

/* ── Utility ─────────────────────────────────────────── */
.text-center { text-align: center; }

/* ── Column filter button inside <th> ───────────────── */
.th-inner {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.col-filter-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 3px;
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.col-filter-btn:hover   { background: rgba(255,255,255,0.32); color: #fff; }
.col-filter-btn.is-active {
  background: #fdd835;
  border-color: #f9a825;
  color: #5f4000;
}

/* ── Excel-style floating filter panel ──────────────── */
.cfp-panel {
  position: fixed;
  z-index: 1000;
  width: 230px;
  background: #fff;
  border: 1px solid #c8c8c8;
  border-radius: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  font-size: 0.85rem;
  color: #333;
}
.cfp-panel.hidden { display: none; }

.cfp-search {
  display: block;
  width: calc(100% - 16px);
  margin: 8px;
  padding: 5px 8px;
  border: 1px solid #ccc;
  border-radius: 3px;
  font-size: 0.82rem;
  outline: none;
}
.cfp-search:focus { border-color: #1a73e8; }

.cfp-select-all {
  padding: 4px 10px 4px;
  border-bottom: 1px solid #eee;
}
.cfp-select-all label {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.83rem;
}

.cfp-list {
  max-height: 200px;
  overflow-y: auto;
  padding: 4px 0;
}

.cfp-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  cursor: pointer;
  transition: background 0.1s;
}
.cfp-item:hover { background: #f0f4ff; }
.cfp-item input[type=checkbox] { cursor: pointer; accent-color: #1a73e8; }
.cfp-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.cfp-footer {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid #eee;
}

.cfp-btn {
  flex: 1;
  padding: 6px 0;
  border: 1px solid #ccc;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  transition: background 0.15s;
}
.cfp-ok     { background: #1a73e8; color: #fff; border-color: #1a73e8; }
.cfp-ok:hover { background: #1558b0; }
.cfp-cancel { background: #e76262; color: #f1f3f4; }
.cfp-cancel:hover { background: #db4b4b; }

tbody tr {
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.15s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f5f8ff; }

tbody td {
  padding: 10px 14px;
  color: #444;
  white-space: nowrap;
}

tbody td a { color: #1a73e8; text-decoration: none; }
tbody td a:hover { text-decoration: underline; }

.empty-row td {
  text-align: center;
  color: #e03b3b;
  padding: 36px;
  font-style: bold;
  font-size: 17px;
  white-space: normal;
}

/* ── Skeleton ───────────────────────────────────────────── */
.skeleton td { padding: 12px 14px; }

.skel-bar {
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(90deg, #e8e8e8 25%, #f5f5f5 50%, #e8e8e8 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Modal ──────────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: #fff;
  border-radius: 12px;
  padding: 28px 28px 22px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  animation: slideIn 0.2s ease;
}

@keyframes slideIn {
  from { transform: translateY(-20px); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #1a1a2e;
  margin-bottom: 18px;
}

/* 2-column grid; fields span full width with .full-width */
.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
}

.modal-field { display: flex; flex-direction: column; }
.modal-field.full-width { grid-column: 1 / -1; }

.modal-field label {
  font-size: 0.82rem;
  font-weight: 500;
  color: #555;
  margin-bottom: 5px;
}

.req { color: #e53935; }

.modal-field input,
.modal-field select {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid #ccc;
  border-radius: 7px;
  font-size: 0.9rem;
  outline: none;
  background: #fff;
  color: #333;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.modal-field select { cursor: pointer; }

.modal-field input:focus,
.modal-field select:focus {
  border-color: #1a73e8;
  box-shadow: 0 0 0 3px rgba(26,115,232,0.14);
}

.modal-field input.input-error,
.modal-field select.input-error { border-color: #e53935; }

.field-err {
  font-size: 0.76rem;
  color: #e53935;
  margin-top: 3px;
  display: none;
}
.field-err.show { display: block; }

.modal-warn {
  padding: 9px 12px;
  border-radius: 7px;
  font-size: 0.83rem;
  background: #fff8e1;
  color: #856404;
  border: 1px solid #ffe082;
  margin-bottom: 14px;
  display: none;
}
.modal-warn.show { display: block; }

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

/* ── Router: page-load spinner ─────────────────────────── */
.page-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}

.page-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid #e8f0fe;
  border-top-color: #1a73e8;
  border-radius: 50%;
  animation: routerSpin 0.7s linear infinite;
}

@keyframes routerSpin {
  to { transform: rotate(360deg); }
}

/* ── Toast ──────────────────────────────────────────────── */
#toastContainer {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 500;
  min-width: 260px;
  max-width: 340px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.14);
  animation: toastIn 0.25s ease;
}

@keyframes toastIn {
  from { transform: translateX(60px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

.toast.success { background: #e8f5e9; color: #2e7d32; border-left: 4px solid #34a853; }
.toast.warn    { background: #fff8e1; color: #856404; border-left: 4px solid #f9a825; }
.toast.error   { background: #fdecea; color: #c62828; border-left: 4px solid #e53935; }
.toast.info    { background: #e3f2fd; color: #1565c0; border-left: 4px solid #1a73e8; }

/* ── Hamburger ──────────────────────────────────────────── */
.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
}

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: #fff;
  margin: 5px 0;
  border-radius: 2px;
}

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .hamburger { display: block; }

  .sidebar {
    position: fixed;
    top: 0;
    left: -240px;
    height: 100%;
    width: 220px;
    z-index: 100;
    transition: left 0.3s ease;
    padding-top: 60px;
    box-shadow: 2px 0 8px rgba(0,0,0,0.15);
  }

  .sidebar.open { left: 0; }
  .overlay.open { display: block; }

  .main { padding: 16px; }

  .modal-grid { grid-template-columns: 1fr; }
  .modal-field.full-width { grid-column: 1; }
  .modal { max-width: 100%; }

  .btn { padding: 9px 12px; font-size: 0.85rem; }

  #toastContainer { right: 10px; top: 10px; }
  .toast { min-width: 200px; font-size: 0.82rem; }
}

/* ── Assign-Coupon modal — profile list rows ─────────────── */
.assign-profile-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background 0.12s;
}
.assign-profile-row:last-child { border-bottom: none; }
.assign-profile-row:hover { background: #f5f8ff; }
.assign-profile-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #1a73e8;
  flex-shrink: 0;
  cursor: pointer;
}

.assign-profile-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.assign-profile-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: #1a1a2e;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.assign-profile-grade {
  font-size: 0.78rem;
  color: #888;
}

.assign-profile-badge {
  font-size: 0.88rem;
  font-weight: 600;
  color: #302f2f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Assign-Coupon modal — profile table ─────────────────── */
.assign-profile-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
.assign-profile-table thead tr {
  background: #f5f6f8;
  position: sticky;
  top: 0;
  z-index: 1;
}
.assign-profile-table th {
  padding: 9px 12px;
  text-align: left;
  font-weight: 600;
  color: #555;
  border-bottom: 1px solid #dde1e7;
  white-space: nowrap;
}
.assign-profile-table td {
  padding: 9px 12px;
  border-bottom: 1px solid #f0f0f0;
  color: #333;
  vertical-align: middle;
}
.assign-profile-table tbody tr:last-child td { border-bottom: none; }
.assign-profile-table tbody tr:hover { background: #f5f8ff; }
.assign-profile-table input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: #1a73e8;
  cursor: pointer;
}
.assign-profile-table input[type="checkbox"]:disabled { cursor: not-allowed; opacity: 0.5; }
.profile-name-cell { font-weight: 600; color: #1a1a2e; }

.badge-removeed {
  font-size: 0.74rem;
  color: #9e9e9e;
}

/* ── Embedded mode (content-detail loaded inside an iframe) ── */
html.embedded-mode header,
html.embedded-mode .sidebar,
html.embedded-mode .overlay,
html.embedded-mode .detail-topbar .btn-back {
  display: none !important;
}
html.embedded-mode .layout { min-height: 100vh; }
html.embedded-mode .main { padding: 16px; }

/* Detail container injected into content.html when entering Map Content view. */
.detail-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.detail-container iframe {
  flex: 1;
  width: 100%;
  border: 0;
  min-height: calc(100vh - 200px);
  background: #f0f2f5;
}
.detail-container .detail-back-btn {
  align-self: flex-start;
  margin-bottom: 12px;
}

/* ── Role Permissions grid ─────────────────────────────── */
.perm-section-row td {
  background: #f5f7fb;
  font-weight: 700;
  color: #1a73e8;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 8px 14px;
}
.perm-row-indent td:first-child { padding-left: 32px; color: #444; }

.perm-cb-group {
  display: inline-flex;
  gap: 30px;
  align-items: center;
}
.perm-cb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  user-select: none;
}
.perm-cb input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: #1a73e8;
  cursor: pointer;
}
