:root {
  --navy: #15243a;
  --navy-light: #213653;
  --blue: #337ab7;
  --green: #2f9d71;
  --yellow: #e0a13a;
  --red: #d45d57;
  --surface: #ffffff;
  --background: #f3f6f9;
  --border: #dce3ea;
  --text: #25364a;
  --muted: #708095;
  --sidebar-width: 260px;
  --topbar-height: 64px;
}

* { box-sizing: border-box; }
html { min-height: 100%; font-size: 16px; }
body { min-height: 100vh; margin: 0; color: var(--text); background: var(--background); font-family: "Segoe UI", "Noto Sans TC", sans-serif; }
button, input { font: inherit; }

.topbar {
  position: fixed;
  z-index: 1000;
  inset: 0 0 auto 0;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  color: #fff;
  background: var(--navy);
  box-shadow: 0 2px 10px rgb(15 31 50 / 18%);
}

.topbar-brand { display: flex; gap: .7rem; align-items: center; padding: 0 1.25rem; color: #fff; text-decoration: none; font-size: 1.08rem; font-weight: 600; }
.topbar-brand:hover { color: #fff; }
.brand-mark { display: grid; place-items: center; width: 52px; height: 52px; color: #fff; background: linear-gradient(135deg, #4ca9e9, #3173ba); border-radius: 16px; font-size: 1.8rem; box-shadow: 0 8px 24px rgb(37 113 181 / 24%); }
.brand-mark.small { width: 34px; height: 34px; border-radius: 10px; font-size: 1.2rem; box-shadow: none; }
.menu-toggle { display: none; margin-left: .75rem; color: #fff; border: 0; background: transparent; font-size: 1.4rem; }
.topbar-actions { display: flex; align-items: stretch; margin-left: auto; height: 100%; }
.topbar-actions > .dropdown { height: 100%; }
.topbar-icon, .user-menu { border: 0; color: #dbe6f3; background: transparent; }
.topbar-icon { width: 48px; font-weight: 700; }
.topbar-icon:hover, .user-menu:hover { color: #fff; background: rgb(255 255 255 / 7%); }
.user-menu { display: flex; gap: .55rem; align-items: center; height: 100%; padding: 0 1rem; }
.avatar { display: grid; flex: 0 0 34px; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: var(--navy); background: #fff; font-weight: 700; }

.sidebar { position: fixed; z-index: 900; inset: var(--topbar-height) auto 0 0; width: var(--sidebar-width); overflow-y: auto; color: #c9d4e1; background: var(--navy-light); }
.sidebar-search { display: flex; margin: 1rem; overflow: hidden; border-radius: 7px; background: #fff; }
.sidebar-search input { min-width: 0; width: 100%; padding: .65rem .75rem; border: 0; outline: 0; }
.sidebar-search button { padding: 0 .8rem; border: 0; color: var(--muted); background: #fff; }
.sidebar nav > a, .sidebar details a, .sidebar summary { display: flex; gap: .75rem; align-items: center; min-height: 46px; padding: .7rem 1.25rem; color: #c9d4e1; text-decoration: none; cursor: pointer; border-left: 3px solid transparent; }
.sidebar nav > a:hover, .sidebar details a:hover, .sidebar summary:hover, .sidebar a.active { color: #fff; background: rgb(255 255 255 / 6%); border-left-color: #4ca9e9; }
.sidebar summary { list-style: none; }
.sidebar summary::-webkit-details-marker { display: none; }
.sidebar summary::after { content: "›"; margin-left: auto; transition: transform .2s; }
.sidebar details[open] summary::after { transform: rotate(90deg); }
.sidebar details a { min-height: 40px; padding-left: 3.3rem; font-size: .9rem; background: rgb(8 22 38 / 22%); }
.sidebar nav span { width: 20px; text-align: center; }

.main-content { min-height: 100vh; margin-left: var(--sidebar-width); padding: calc(var(--topbar-height) + 2rem) 2rem 3rem; }
.page-heading { display: flex; justify-content: space-between; align-items: end; margin-bottom: 1.5rem; }
.page-heading h1 { margin: 0; font-size: 1.8rem; font-weight: 650; }
.page-heading p:not(.eyebrow) { margin: .35rem 0 0; color: var(--muted); }
.eyebrow { margin: 0 0 .4rem; color: var(--blue); font-size: .73rem; font-weight: 800; letter-spacing: .16em; }
.dashboard-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.2rem; }
.stat-card { display: grid; grid-template-columns: auto 1fr; gap: .15rem 1rem; padding: 1.2rem; overflow: hidden; border: 0; border-radius: 10px; color: #fff; text-align: left; box-shadow: 0 7px 20px rgb(23 44 68 / 10%); transition: transform .2s, box-shadow .2s; }
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 10px 25px rgb(23 44 68 / 16%); }
.stat-card.primary { background: var(--blue); }
.stat-card.success { background: var(--green); }
.stat-card.warning { background: var(--yellow); }
.stat-card.danger { background: var(--red); }
.stat-icon { grid-row: span 2; align-self: center; width: 54px; font-size: 2.5rem; text-align: center; opacity: .88; }
.stat-value { justify-self: end; font-size: 2rem; line-height: 1; }
.stat-label { justify-self: end; }
.stat-link { grid-column: 1 / -1; margin: 1rem -1.2rem -1.2rem; padding: .65rem 1.2rem; color: var(--text); background: rgb(255 255 255 / 94%); font-size: .85rem; }
.content-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1.2rem; margin-top: 1.2rem; }
.content-card { overflow: hidden; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: 0 4px 15px rgb(23 44 68 / 5%); }
.content-card > header { padding: .9rem 1.1rem; border-bottom: 1px solid var(--border); font-weight: 650; }
.content-card > header span { color: var(--blue); margin-right: .35rem; }
.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; padding: 1.2rem; }
.quick-actions button { display: flex; flex-direction: column; gap: .45rem; align-items: center; padding: 1rem .5rem; border: 1px solid #d4e5f2; border-radius: 8px; color: #33708f; background: #f3faff; font-weight: 600; }
.quick-actions button:hover { border-color: #8ec3df; background: #e8f6fd; }
.quick-actions span { font-size: 1.55rem; }
.welcome-body { padding: 1.3rem; }
.welcome-body h2 { font-size: 1.1rem; }
.welcome-body p { color: var(--muted); }
.status-pill { display: inline-flex; gap: .45rem; align-items: center; padding: .4rem .7rem; border-radius: 999px; color: #237151; background: #e7f6ef; font-size: .82rem; font-weight: 650; }
.status-pill span { width: 8px; height: 8px; border-radius: 50%; background: #35a574; }
.coming-soon-toast { position: fixed; z-index: 1500; right: 1.5rem; bottom: 1.5rem; padding: .85rem 1.15rem; border-radius: 8px; color: #fff; background: #26384d; box-shadow: 0 8px 30px rgb(0 0 0 / 20%); opacity: 0; transform: translateY(15px); pointer-events: none; transition: .2s; }
.coming-soon-toast.show { opacity: 1; transform: translateY(0); }

.login-page { display: grid; min-height: 100vh; place-items: center; padding: 1.5rem; background: radial-gradient(circle at top left, #eef8ff 0, transparent 38%), linear-gradient(145deg, #edf2f7, #f9fbfd); }
.login-shell { width: min(100%, 920px); }
.login-card { display: grid; grid-template-columns: .9fr 1.1fr; min-height: 520px; overflow: hidden; border-radius: 18px; background: #fff; box-shadow: 0 24px 70px rgb(24 48 76 / 16%); }
.login-brand { display: flex; flex-direction: column; justify-content: end; align-items: flex-start; gap: 1.2rem; padding: 3rem; color: #fff; background: linear-gradient(155deg, rgb(24 47 76 / 88%), rgb(24 47 76 / 98%)), radial-gradient(circle at top, #4ca9e9, #18304d); }
.brand-name { font-size: 1.8rem; font-weight: 700; }
.brand-subtitle { margin-top: .3rem; color: #b8c9db; }
.login-content { display: flex; flex-direction: column; justify-content: center; padding: 3rem; }
.login-content h1 { margin: 0 0 .7rem; font-size: 2rem; font-weight: 700; }
.login-intro { margin-bottom: 1.8rem; color: var(--muted); }
.sso-button { display: flex; justify-content: center; align-items: center; gap: .8rem; width: 100%; margin-top: .8rem; padding: .8rem 1rem; border-radius: 8px; font-weight: 650; transition: transform .15s, box-shadow .15s; }
.sso-button:not(:disabled):hover { transform: translateY(-1px); box-shadow: 0 5px 14px rgb(20 40 65 / 12%); }
.sso-button.google { border: 1px solid #d8e0e8; color: #33475d; background: #fff; }
.sso-button.line { border: 1px solid #06c755; color: #fff; background: #06c755; }
.sso-button:disabled { cursor: not-allowed; opacity: .5; }
.provider-icon { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 50%; background: rgb(255 255 255 / 90%); color: #33475d; font-weight: 800; }
.configuration-note { display: block; margin: .35rem 0 0; color: var(--red); text-align: center; }
.login-help { margin: 1.5rem 0 0; color: var(--muted); font-size: .82rem; line-height: 1.6; }
.login-footer { margin: 1rem 0 0; color: var(--muted); font-size: .78rem; text-align: center; }

@media (max-width: 1050px) {
  .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .menu-toggle { display: block; }
  .user-name, .topbar-icon { display: none; }
  .topbar-brand { padding-left: .65rem; font-size: .95rem; }
  .sidebar { transform: translateX(-100%); transition: transform .2s; box-shadow: 8px 0 25px rgb(0 0 0 / 15%); }
  .menu-open .sidebar { transform: translateX(0); }
  .main-content { margin-left: 0; padding: calc(var(--topbar-height) + 1.2rem) 1rem 2rem; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .quick-actions { grid-template-columns: repeat(2, 1fr); }
  .login-card { grid-template-columns: 1fr; }
  .login-brand { min-height: 180px; padding: 1.8rem; }
  .login-content { padding: 2rem 1.5rem; }
}
