:root { --primary: #2563eb; --bg: #f3f4f6; --card: #ffffff; }
body { font-family: -apple-system, sans-serif; background: var(--bg); display: flex; justify-content: center; align-items: center; min-height: 100vh; margin: 0; }
.container { width: 100%; max-width: 450px; padding: 20px; padding-top: 50px; }
.card { background: var(--card); padding: 2rem; border-radius: 8px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); }
.hidden { display: none; }
input { width: 100%; padding: 10px; margin: 10px 0; border: 1px solid #ddd; border-radius: 4px; box-sizing: border-box;}
button { width: 100%; padding: 10px; background: var(--primary); color: white; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; }
button:hover { opacity: 0.9; }
button.logout { background: #dc2626; margin-top: 10px; }

#realtime-clock {
  position: fixed;
  top: 15px;
  right: 20px;
  background: rgba(255, 255, 255, 0.9);
  padding: 8px 15px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  color: #333;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  z-index: 1000;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  border: 1px solid #e2e8f0;
}

.app-item { padding: 15px; border: 1px solid #eee; margin-bottom: 10px; border-radius: 4px; cursor: pointer; transition: all 0.2s; background: #fff; }
.app-item:hover { background: #f8fafc; border-color: var(--primary); transform: translateY(-1px); box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
.app-title { font-weight: 700; display: block; text-align: center; font-size: 1.1em; }
.app-desc {
  display: none;
  font-size: 0.9em;
  color: #475569;
  text-align: justify;
  margin-top: 12px;
  line-height: 1.5;
  border-top: 1px dashed #cbd5e1;
  padding-top: 10px;
  animation: fadeIn 0.3s ease;
}
.app-item.expanded .app-desc { display: block; }

.app-actions { display: none; margin-top: 10px; gap: 8px; border-top: 1px solid #eee; padding-top: 10px; }
.app-item.expanded .app-actions { display: flex; }

.btn-action { flex: 1; padding: 10px; font-size: 12px; border-radius: 6px; border: none; cursor: pointer; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 5px; }
.btn-launch { background: var(--primary); color: white; }
.btn-docs { background: #ef4444; color: white; }

.app-docs-list { display: none; margin-top: 10px; background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 6px; overflow: hidden; }
.app-docs-list.show { display: block; }

.app-doc-link { display: block; padding: 10px 15px; font-size: 12px; color: #334155; border-bottom: 1px solid #e2e8f0; cursor: pointer; border-left: 4px solid transparent; transition: 0.2s; background: #fff; }
.app-doc-link:last-child { border-bottom: none; }
.app-doc-link:hover { background: #e2e8f0; font-weight: bold; padding-left: 20px; }

#msg { color: #dc2626; text-align: center; margin-bottom: 10px; font-size: 0.9em; }
h2 { text-align: center; margin-top: 0; }

.doc-section { margin-top: 20px; border-top: 1px solid #eee; padding-top: 15px; }
.doc-accordion-header { cursor: pointer; text-align: center; color: #64748b; font-size: 0.85em; font-weight: 600; padding: 10px; background: #f8fafc; border-radius: 6px; border: 1px solid #e2e8f0; transition: 0.2s; }
.doc-accordion-header:hover { background: #e2e8f0; color: #333; }
.doc-list { overflow: hidden; max-height: 0; transition: max-height 0.4s ease-out; }
.doc-list.open { max-height: 500px; overflow-y: auto; margin-top: 10px; }
.doc-item { padding: 12px; border-radius: 6px; margin-bottom: 8px; cursor: pointer; background: #fff; border: 1px solid #eee; border-left: 4px solid #ddd; transition: transform 0.1s; box-shadow: 0 1px 2px rgba(0,0,0,0.03); }
.doc-item:hover { transform: translateX(3px); background: #f8fafc; }

#docViewer { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: white; z-index: 9999; display: none; flex-direction: column; }
#docViewer iframe { flex-grow: 1; border: none; width: 100%; height: 100%; }
.close-doc { position: absolute; top: 15px; right: 25px; font-size: 35px; font-weight: bold; cursor: pointer; color: #1e293b; z-index: 10000; background: rgba(255,255,255,0.9); width: 45px; height: 45px; display: flex; align-items: center; justify-content: center; border-radius: 50%; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }

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

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary: #64748b;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg-panel: #f8fafc;
  --border: #e2e8f0;
  --text-main: #1e293b;
  --text-muted: #64748b;
}

.sso-admin-container {
  background:
    radial-gradient(circle at top left, rgba(37,99,235,0.14), transparent 28%),
    linear-gradient(180deg, #f8fbff 0%, #eef3f9 100%);
  position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 1000; display: none;
  font-family: "Inter", sans-serif; color: var(--text-main);
}
.admin-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
  padding: 24px 30px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  box-shadow: 0 18px 40px rgba(15,23,42,0.18);
}
.admin-header-copy { max-width: 720px; color: #fff; }
.admin-header-copy h3 { margin: 6px 0 8px; font-size: 28px; line-height: 1.1; color: #fff; }
.admin-header-copy p { margin: 0; color: rgba(255,255,255,0.8); line-height: 1.6; font-size: 14px; }
.admin-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  color: #bfdbfe;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.admin-header-actions { display: flex; align-items: center; gap: 12px; }
.admin-header-card {
  min-width: 160px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.82);
}
.admin-header-card span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 4px; }
.admin-header-card strong { font-size: 15px; color: #fff; }
.admin-body { padding: 24px 28px 28px; height: calc(100% - 122px); overflow-y: auto; box-sizing: border-box; }

.admin-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.admin-strip-card {
  background: rgba(255,255,255,0.86);
  border: 1px solid rgba(148,163,184,0.25);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 10px 24px rgba(15,23,42,0.06);
}
.admin-strip-card span {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #64748b;
  margin-bottom: 6px;
  font-weight: 700;
}
.admin-strip-card strong { font-size: 16px; color: #0f172a; }

.tab-nav {
  display: inline-flex;
  gap: 10px;
  margin-bottom: 22px;
  padding: 8px;
  border: 1px solid rgba(148,163,184,0.22);
  border-radius: 18px;
  background: rgba(255,255,255,0.88);
  box-shadow: 0 10px 24px rgba(15,23,42,0.05);
}
.tab-btn {
  padding: 11px 18px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 700;
  border-radius: 12px;
  width: auto;
}
.tab-btn.active {
  color: #fff;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  box-shadow: 0 8px 20px rgba(37,99,235,0.24);
}
.admin-content { display: none; animation: fadeIn 0.3s; }
.admin-content.active { display: block; }

.accordion-card {
  background: rgba(255,255,255,0.92);
  border-radius: 20px;
  box-shadow: 0 18px 40px rgba(15,23,42,0.06);
  margin-bottom: 22px;
  border: 1px solid rgba(148,163,184,0.2);
  overflow: hidden;
  backdrop-filter: blur(8px);
}
.accordion-header {
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  padding: 16px 22px;
  cursor: pointer;
  font-weight: 800;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(148,163,184,0.16);
}
.accordion-header:hover { background: #f8fbff; }
.accordion-body { padding: 22px; display: none; }
.accordion-card.open .accordion-body { display: block; }

.form-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(148,163,184,0.18);
}
.form-toolbar.compact { padding-bottom: 0; border-bottom: 0; margin-bottom: 18px; }
.form-title {
  font-size: 18px;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 4px;
}
.form-caption {
  font-size: 13px;
  line-height: 1.55;
  color: #64748b;
  max-width: 680px;
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 108px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  border: 1px solid transparent;
}
.mode-insert { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.mode-edit { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.mode-view { background: #f8fafc; color: #475569; border-color: #cbd5e1; }

.section-label {
  font-size: 11px;
  font-weight: 800;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin: 16px 0 10px;
}

.grid-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-bottom: 15px; }
.form-group label { display: block; font-size: 11px; margin-bottom: 5px; font-weight: 700; color: var(--secondary); text-transform: uppercase; }
.form-group input, .form-group select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid rgba(148,163,184,0.28);
  border-radius: 12px;
  font-size: 13px;
  box-sizing: border-box;
  background: #fff;
}
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  padding: 12px;
  border: 1px solid rgba(148,163,184,0.18);
  border-radius: 14px;
}

.cb-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  cursor: pointer;
  background: #fff;
  padding: 4px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
}
.cb-item:hover { background: #f1f5f9; }

.audit-filter-box {
  background: linear-gradient(180deg, rgba(255,255,255,0.96) 0%, #eff6ff 100%);
  border: 1px solid rgba(37,99,235,0.18);
  padding: 18px;
  border-radius: 18px;
  margin-bottom: 22px;
  box-shadow: 0 16px 34px rgba(37,99,235,0.08);
}

.form-actions { margin-top: 18px; display: flex; justify-content: flex-end; }
.form-actions .btn-save { width: auto; min-width: 180px; }

.btn-save {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  width: 100%;
  padding: 12px 18px;
  border: none;
  border-radius: 12px;
  font-weight: 800;
  cursor: pointer;
  font-size: 13px;
  transition: 0.2s;
  letter-spacing: 0.05em;
}
.btn-save:hover { filter: brightness(90%); }
.btn-save:disabled { background: #cbd5e1; cursor: not-allowed; }

.btn-sm { padding: 7px 12px; border-radius: 10px; border:none; cursor:pointer; font-size:12px; font-weight: 700; }
.btn-edit { background: var(--primary); color: white; margin-right: 5px; }
.btn-del { background: #fee2e2; color: var(--danger); }
.btn-back {
  background: rgba(255,255,255,0.12);
  color: white;
  padding: 10px 16px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
  width: auto;
  border: 1px solid rgba(255,255,255,0.14);
}

.btn-new { background: var(--warning); color: #fff; margin-left: auto; margin-right: 10px; padding: 7px 15px; border-radius: 999px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; border: none; cursor: pointer; box-shadow: 0 6px 16px rgba(245,158,11,0.24); width: auto; }
.btn-new:hover { background: #d97706; }

.table-wrapper { max-height: 520px; overflow: auto; border: 1px solid rgba(148,163,184,0.16); border-radius: 16px; background: white; box-shadow: inset 0 1px 0 rgba(255,255,255,0.8); }
table { width: 100%; border-collapse: collapse; font-size: 13px; white-space: nowrap; }
th { background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%); color: var(--secondary); font-weight: 700; text-transform: uppercase; font-size: 11px; padding: 13px 15px; text-align: left; position: sticky; top: 0; z-index: 5; border-bottom: 1px solid rgba(148,163,184,0.18); }
td { padding: 11px 15px; border-bottom: 1px solid rgba(148,163,184,0.14); color: var(--text-main); }
tbody tr:nth-child(even) { background-color: #fbfdff; }
tbody tr:hover { background-color: #eef5ff; }
.tbl-link { color: var(--primary); text-decoration: none; font-weight: 500; }
.tbl-link:hover { text-decoration: underline; }

@media (max-width: 900px) {
  .admin-header {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-header-actions {
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .tab-nav {
    display: flex;
    width: 100%;
    overflow-x: auto;
  }

  .form-toolbar {
    flex-direction: column;
  }

  .form-actions {
    justify-content: stretch;
  }

  .form-actions .btn-save {
    width: 100%;
  }
}
