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

:root {
  --blue:          #1B2D5B;
  --blue-dark:     #0f1e3d;
  --yellow:        #F5C400;
  --yellow-dark:   #d4a900;
  --white:         #ffffff;
  --bg:            #eef0f4;
  --border:        #dde0e8;
  --header-height: 62px;
}

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
}

/* ── Header ─────────────────────────────────────────────────────────────────── */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: var(--blue);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  box-shadow: 0 2px 10px rgba(0,0,0,.35);
  z-index: 100;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: .7rem;
  user-select: none;
}

.header-brand {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.header-brand-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--white);
  letter-spacing: .07em;
}

.header-brand-tagline {
  font-size: .52rem;
  font-weight: 500;
  color: rgba(255,255,255,.55);
  letter-spacing: .18em;
  text-transform: uppercase;
  margin-top: .2rem;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: .45rem;
  color: rgba(255,255,255,.88);
  font-size: .855rem;
  font-weight: 500;
}

.user-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--yellow);
  flex-shrink: 0;
}

.btn-logout {
  padding: .4rem 1.1rem;
  background: transparent;
  border: 1.5px solid rgba(255,255,255,.38);
  border-radius: 7px;
  color: rgba(255,255,255,.9);
  font-family: inherit;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.btn-logout:hover:not(:disabled) {
  background: rgba(255,255,255,.12);
  border-color: rgba(255,255,255,.7);
}

.btn-logout:disabled { opacity: .6; cursor: not-allowed; }

/* ── Spinner ─────────────────────────────────────────────────────────────────── */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #d4d8e4;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}

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

/* ── HOME PAGE ───────────────────────────────────────────────────────────────── */
.home-main {
  padding-top: calc(var(--header-height) + 4rem);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
  padding-bottom: 3rem;
}

.home-welcome {
  text-align: center;
  margin-bottom: 3rem;
}

.home-greeting {
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--blue);
  margin-bottom: .4rem;
}

.home-greeting strong { color: var(--blue); }

.home-subtitle {
  font-size: .95rem;
  color: #6b7280;
  font-weight: 400;
}

.home-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  width: 100%;
  max-width: 700px;
}

.home-card {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 1.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.1rem;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: transform .16s, box-shadow .16s, border-color .16s;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.home-card[hidden] { display: none; }

.home-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 28px rgba(0,0,0,.12);
  border-color: var(--yellow);
}

.home-card:active { transform: translateY(-1px); }

.home-card-icon {
  width: 58px;
  height: 58px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.home-card-icon--blue {
  background: rgba(27,45,91,.08);
  color: var(--blue);
}

.home-card-icon--gray {
  background: rgba(107,114,128,.1);
  color: #374151;
}

.home-card-icon--yellow {
  background: rgba(245,196,0,.15);
  color: #92710a;
}

.home-card:hover .home-card-icon--yellow { background: rgba(245,196,0,.25); }

.home-card-icon--green {
  background: rgba(16,185,129,.12);
  color: #065f46;
}

.home-grid { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); max-width: 960px; }

.home-card:hover .home-card-icon--blue  { background: rgba(27,45,91,.14); }
.home-card:hover .home-card-icon--gray  { background: rgba(107,114,128,.16); }
.home-card:hover .home-card-icon--green { background: rgba(16,185,129,.22); }

.home-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}

.home-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--blue);
}

.home-card-desc {
  font-size: .8rem;
  color: #6b7280;
  font-weight: 400;
}

.home-card-arrow {
  color: #c0c4ce;
  flex-shrink: 0;
  transition: color .16s, transform .16s;
}

.home-card:hover .home-card-arrow {
  color: var(--yellow-dark);
  transform: translateX(3px);
}

/* ── DASHBOARDS LIST PAGE ────────────────────────────────────────────────────── */
.list-main {
  padding-top: calc(var(--header-height) + 2.5rem);
  min-height: 100vh;
  max-width: 720px;
  margin: 0 auto;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
  padding-bottom: 3rem;
}

.list-topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

.btn-back {
  display: flex;
  align-items: center;
  gap: .35rem;
  padding: .42rem .9rem;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: #5a6078;
  font-family: inherit;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}

.btn-back:hover {
  background: var(--white);
  border-color: #b0b8cc;
  color: var(--blue);
}

.list-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--blue);
}

.list-loading {
  display: flex;
  justify-content: center;
  padding-top: 3rem;
}

.list-loading[hidden] { display: none; }
.db-grid[hidden]      { display: none; }
.list-error[hidden]   { display: none; }

.list-error {
  background: #fff0f0;
  border: 1px solid #f5c6c6;
  color: #c0392b;
  padding: .85rem 1rem;
  border-radius: 8px;
  font-size: .88rem;
}

.db-grid {
  display: flex;
  flex-direction: column;
  gap: .85rem;
}

.db-card {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 1.4rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.1rem;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  width: 100%;
  transition: transform .15s, box-shadow .15s, border-color .15s;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}

.db-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(0,0,0,.1);
  border-color: var(--yellow);
}

.db-card:active { transform: none; }

.db-card-icon {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  background: rgba(27,45,91,.08);
  color: var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.db-card:hover .db-card-icon { background: rgba(27,45,91,.14); }

.db-card-body {
  flex: 1;
}

.db-card-name {
  font-size: .98rem;
  font-weight: 700;
  color: var(--blue);
}

.db-card-desc {
  font-size: .78rem;
  color: #6b7280;
  margin-top: .15rem;
}

.db-card-arrow {
  color: #c0c4ce;
  flex-shrink: 0;
  transition: color .15s, transform .15s;
}

.db-card:hover .db-card-arrow {
  color: var(--yellow-dark);
  transform: translateX(3px);
}

/* ── Change Password Modal (shared) ─────────────────────────────────────────── */
.cpwd-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11,20,46,.62);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  backdrop-filter: blur(3px);
}

.cpwd-overlay[hidden] { display: none; }

.cpwd-modal {
  background: #fff;
  border-radius: 12px;
  width: min(420px, calc(100vw - 2rem));
  padding: 2rem;
  box-shadow: 0 20px 60px rgba(0,0,0,.32);
  animation: cpwd-in .18s ease;
}

@keyframes cpwd-in {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.cpwd-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.cpwd-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--blue);
}

.cpwd-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: #888;
  cursor: pointer;
  padding: .2rem .4rem;
  border-radius: 4px;
  transition: color .15s;
}

.cpwd-close:hover { color: var(--blue); }

.cpwd-field { margin-bottom: 1.1rem; }

.cpwd-field label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: #444;
  margin-bottom: .35rem;
  letter-spacing: .02em;
}

.cpwd-field input {
  width: 100%;
  padding: .6rem .85rem;
  border: 1.5px solid #d0d5de;
  border-radius: 7px;
  font-size: .9rem;
  font-family: inherit;
  color: #222;
  transition: border-color .18s;
  outline: none;
}

.cpwd-field input:focus { border-color: var(--blue); }

.cpwd-strength {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-top: .45rem;
}

.cpwd-strength-bar {
  flex: 1;
  height: 5px;
  background: #e4e7ef;
  border-radius: 99px;
  overflow: hidden;
}

.cpwd-strength-fill {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  transition: width .25s, background .25s;
}

.cpwd-strength-label {
  font-size: .72rem;
  font-weight: 600;
  min-width: 52px;
  color: #888;
}

.cpwd-feedback {
  padding: .65rem .9rem;
  border-radius: 7px;
  font-size: .83rem;
  font-weight: 500;
  margin-bottom: .9rem;
}

.cpwd-feedback[hidden] { display: none; }

.cpwd-feedback.error  { background: #fff0f0; color: #c0392b; border: 1px solid #f5c6c6; }
.cpwd-feedback.success { background: #f0faf3; color: #1e7e43; border: 1px solid #b7e4c7; }

.cpwd-actions { margin-top: 1.4rem; }

.cpwd-btn-primary {
  width: 100%;
  padding: .72rem;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .18s;
}

.cpwd-btn-primary:hover:not(:disabled) { background: var(--blue-dark); }
.cpwd-btn-primary:disabled { opacity: .6; cursor: not-allowed; }

/* ── App Viewer ──────────────────────────────────────────────────────────────── */
.app-frame-wrap {
  position: fixed;
  top: var(--header-height);
  left: 0; right: 0; bottom: 0;
}

.app-frame-wrap iframe {
  width: 100%; height: 100%;
  border: none;
}

/* App shell: sidebar + content */
.app-shell {
  position: fixed;
  top: var(--header-height);
  left: 0; right: 0; bottom: 0;
  display: flex;
}

.app-sidebar {
  width: 220px;
  background: var(--blue);
  border-right: 1px solid rgba(255,255,255,.1);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
  padding: 16px 0 8px;
}

.app-sidebar[hidden] { display: none; }

.app-sidebar-section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: rgba(255,255,255,.4);
  font-weight: 700;
  padding: 0 20px 12px;
}

.app-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px;
  background: none;
  border: none;
  color: rgba(255,255,255,.65);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background .15s, color .15s;
  border-radius: 0;
}

.app-nav-item:hover {
  background: rgba(255,255,255,.07);
  color: #fff;
}

.app-nav-item.active {
  background: rgba(245,196,0,.12);
  color: var(--yellow);
  border-left: 3px solid var(--yellow);
  padding-left: 17px;
}

.app-nav-icon { font-size: 16px; flex-shrink: 0; }

.app-nav-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.app-nav-badge {
  font-size: 9px;
  background: rgba(255,255,255,.1);
  color: rgba(255,255,255,.5);
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

.app-content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.app-content iframe {
  width: 100%; height: 100%;
  border: none;
}

.app-frame-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.app-frame-loading[hidden] { display: none; }

.app-frame-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: #c0392b;
  font-size: .95rem;
}

.app-frame-error[hidden] { display: none; }

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .header { padding: 0 1rem; }
  .header-brand-tagline { display: none; }
  .user-badge span:not(.user-dot) { display: none; }

  .home-grid { grid-template-columns: 1fr; max-width: 420px; }
  .home-greeting { font-size: 1.3rem; }
}
