:root {
  --color-nav: #1e3a5f;
  --color-btn-primary: #1a5276;
  --color-btn-secondary: #2980b9;
  --color-form-label: #7f8c8d;
  --color-bg: #f5f6fa;
  --color-tab: #2f6ea2;
  --color-tab-border: #2a5d8d;
  --color-border: #bdc3c7;
  --color-panel: #ffffff;
  --color-text: #1f2d3d;
  --shell-width: 1440px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: radial-gradient(circle at 12% -18%, #d8e6f2 0, transparent 38%),
    radial-gradient(circle at 85% -35%, #b9d2e8 0, transparent 42%),
    var(--color-bg);
  color: var(--color-text);
  font-family: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", sans-serif;
  line-height: 1.45;
}

.layout-shell {
  width: min(100%, var(--shell-width));
  margin: 0 auto;
}

/* ── Top Navigation ── */

.top-nav {
  width: 100%;
  background: linear-gradient(180deg, #22486f 0%, #173451 100%);
  border-bottom: 1px solid #0f2439;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.05);
  position: relative;
  z-index: 1000;
}

.nav-inner {
  display: flex;
  align-items: stretch;
  min-height: 70px;
}

/* ── Brand / LOGO ── */

.brand {
  flex: 0 0 auto;
  width: 200px;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  text-decoration: none;
  border-right: 1px solid rgba(16, 43, 68, 0.3);
  transition: background 0.15s;
}

.brand:hover {
  background: #f5f9fc;
}

.brand-logo {
  max-width: 172px;
  max-height: 54px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

/* fallback: brand text (if logo fails to load) */
.brand-mark {
  width: 38px;
  height: 38px;
  background: linear-gradient(145deg, #1b759f 0%, #29b0c9 100%);
  clip-path: polygon(0 0, 68% 0, 100% 36%, 100% 100%, 30% 100%, 0 62%);
  flex-shrink: 0;
}

/* ── Main Menu with Dropdowns ── */

.main-menu {
  display: flex;
  align-items: stretch;
  flex: 1;
  overflow-x: auto;
  gap: 0;
  padding: 0 4px;
  scrollbar-width: none;
}

.main-menu::-webkit-scrollbar {
  display: none;
}

/* Each top-level group: label + dropdown */
.menu-group {
  position: relative;
  display: flex;
  align-items: stretch;
}

.menu-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 0 11px;
  color: #e8f0f8;
  font-size: 14.5px;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  user-select: none;
}

.menu-item:hover,
.menu-group:hover .menu-item {
  background: rgba(255, 255, 255, 0.12);
  border-bottom-color: rgba(119, 181, 222, 0.5);
}

.menu-item.is-active {
  border-bottom-color: #77b5de;
  background: rgba(255, 255, 255, 0.08);
}

.nav-arrow {
  font-size: 0.8em;
  opacity: 0.75;
  transition: transform 0.2s;
}

.menu-group:hover .nav-arrow {
  transform: rotate(180deg);
}

/* ── Dropdown panel ── */

.dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 240px;
  background: #ffffff;
  border: 1px solid #c5d5e5;
  border-top: 3px solid #2f6ea2;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 8px 24px rgba(19, 53, 82, 0.18);
  z-index: 9999;
  padding: 4px 0;
}

.dropdown-right {
  left: auto;
  right: 0;
}

.menu-group:hover .dropdown {
  display: block;
}

.dropdown-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 14px;
  color: #1f3d5a;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  transition: background 0.1s;
  border-left: 3px solid transparent;
}

.dropdown-item:hover {
  background: #eaf4fb;
  border-left-color: #2f6ea2;
  color: #1a4f78;
}

.dropdown-icon {
  display: inline-block;
  margin-right: 4px;
  font-style: normal;
}

.dropdown-desc {
  font-size: 11.5px;
  font-weight: 400;
  color: #607484;
  margin-top: 1px;
}

.dropdown-divider {
  height: 1px;
  background: #dce8f0;
  margin: 4px 0;
}

/* ── Right-side user info ── */

.nav-user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  padding: 0 16px;
  gap: 2px;
  flex-shrink: 0;
}

.nav-user-label {
  color: #d0e5f5;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.nav-user-badge {
  background: rgba(119, 181, 222, 0.25);
  color: #9fc8e4;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ── Tab bar ── */

.tab-bar {
  background: linear-gradient(180deg, #347cb6 0%, #2d6999 100%);
  border-bottom: 1px solid var(--color-tab-border);
}

.tab-inner {
  min-height: 50px;
  display: flex;
  align-items: flex-end;
  padding: 0 16px;
}

.active-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 110px;
  min-height: 40px;
  padding: 0 20px;
  margin-top: 10px;
  border-radius: 5px 5px 0 0;
  background: #ffffff;
  color: #2e6694;
  font-size: 22px;
  font-weight: 700;
  border: 1px solid #7ea7c8;
  border-bottom: none;
}

/* ── Main content ── */

.main-content {
  padding: 20px;
}

.content-panel {
  background: var(--color-panel);
  border: 1px solid #7ea7c8;
  border-radius: 0 0 4px 4px;
  min-height: calc(100vh - 180px);
  padding: 18px;
  box-shadow: 0 2px 10px rgba(19, 53, 82, 0.08);
}

/* ── Form grid ── */

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

.form-row {
  min-width: 0;
  display: flex;
  align-items: stretch;
  min-height: 42px;
}

.form-row.wide {
  grid-column: 1 / -1;
}

.form-label {
  flex: 0 0 108px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  background: linear-gradient(180deg, #d5dde2 0%, #c8d2d8 100%);
  border: 1px solid #aeb9bf;
  border-right: none;
  color: #445664;
  font-size: 15px;
  letter-spacing: 0.01em;
  text-align: center;
}

.form-control {
  width: 100%;
  min-width: 0;
  border: 1px solid #b7c1c8;
  border-left: none;
  border-radius: 0 4px 4px 0;
  padding: 8px 10px;
  font: inherit;
  font-size: 15px;
  color: #243747;
  background: #ffffff;
}

.form-control:focus {
  outline: 2px solid rgba(41, 128, 185, 0.28);
  outline-offset: 0;
  border-color: #5e95be;
}

textarea.form-control {
  resize: vertical;
  min-height: 74px;
}

/* ── Buttons ── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #ffffff;
  font-family: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", sans-serif;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  padding: 8px 16px;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
  user-select: none;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.btn:active {
  transform: translateY(1px);
  box-shadow: none;
}

.btn-primary {
  background: linear-gradient(180deg, #3f82ba 0%, var(--color-btn-primary) 100%);
  border-color: #1b4a6a;
  box-shadow: 0 3px 8px rgba(19, 66, 97, 0.2);
}

.btn-primary:hover {
  background: linear-gradient(180deg, #4a8fc8 0%, #20608a 100%);
}

.btn-secondary {
  background: linear-gradient(180deg, #3f89c0 0%, var(--color-btn-secondary) 100%);
  border-color: #2f6f99;
}

.btn-secondary:hover {
  background: linear-gradient(180deg, #4a96ce 0%, #358ec8 100%);
}

.btn-success {
  background: linear-gradient(180deg, #27ae60 0%, #1e8449 100%);
  border-color: #186037;
}

.btn-danger {
  background: linear-gradient(180deg, #e74c3c 0%, #c0392b 100%);
  border-color: #9b2b20;
}

.btn-warn {
  background: linear-gradient(180deg, #f39c12 0%, #d68910 100%);
  border-color: #b7770d;
  color: #ffffff;
}

/* ── Status badges ── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.badge-pass   { background: #d4f4e2; color: #196f3d; }
.badge-fail   { background: #fde8e6; color: #922b21; }
.badge-warn   { background: #fef3cd; color: #9a6700; }
.badge-info   { background: #d6eaf8; color: #1a5276; }

/* ── Placeholder panels ── */

.placeholder-panel {
  border: 1px solid #cfdae2;
  border-radius: 6px;
  padding: 20px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbfd 100%);
}

.page-heading {
  margin: 0;
  color: #214d72;
  font-size: 28px;
  font-weight: 700;
}

.page-note {
  margin-top: 10px;
  color: #607484;
  font-size: 15px;
}

/* ── Alert / info boxes ── */

.alert {
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.alert-warn  { background: #fff8e1; border: 1px solid #f9c74f; color: #7a5800; }
.alert-error { background: #fff0ee; border: 1px solid #f4a09a; color: #7a1a14; }
.alert-ok    { background: #e8f8f0; border: 1px solid #6dcf9e; color: #1a5c39; }
.alert-info  { background: #e8f4fb; border: 1px solid #7bc3e0; color: #1a4d72; }

/* ── Responsive ── */

@media (max-width: 1280px) {
  .brand {
    width: 168px;
  }

  .menu-item {
    font-size: 13.5px;
    padding: 0 9px;
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .main-content {
    padding: 12px;
  }

  .content-panel {
    padding: 14px;
  }

  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .tab-inner {
    padding: 0 10px;
  }

  .nav-user {
    display: none;
  }
}
