/* ===========================================================
   集團 EIP Portal — 企業識別配色
   主色 #F07F09（聖東品牌主色）／淺色背景／dk1・dk2 文字
   =========================================================== */
:root {
  --brand:        #F07F09;
  --brand-dark:   #C96A07;
  --brand-soft:   #FEF3E6;
  --danger:       #9F2936;
  --info:         #1B587C;
  --success:      #4E8542;
  --purple:       #604878;
  --gold:         #C19859;

  --text:         #000000;
  --text-2:       #323232;
  --text-muted:   #6B6B6B;

  --bg:           #F7F6F3;
  --surface:      #FFFFFF;
  --surface-2:    #E3DED1;
  --border:       #E2DFD8;
  --border-soft:  #EFEDE8;

  --radius:       10px;
  --shadow-sm:    0 1px 2px rgba(0,0,0,.05);
  --shadow:       0 2px 8px rgba(0,0,0,.06);
  --shadow-lg:    0 8px 28px rgba(0,0,0,.12);
  --header-h:     64px;
}

* { box-sizing: border-box; }

/* 有些元件用 display:flex/inline-flex，會蓋掉 hidden 屬性，這裡統一修正 */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
               "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.35; }

/* ===================== 登入頁 ===================== */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
}

.login-brand {
  background: linear-gradient(150deg, #2A2A2A 0%, #1A1A1A 55%, #111 100%);
  color: #fff;
  padding: 64px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.login-brand::after {
  content: '';
  position: absolute;
  right: -140px; bottom: -140px;
  width: 420px; height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(240,127,9,.28), transparent 68%);
}

.login-brand-logo {
  width: 96px; height: 96px;
  object-fit: contain;
  margin-bottom: 26px;
  position: relative; z-index: 1;
}

.login-brand h1 {
  font-size: 34px;
  letter-spacing: 1px;
  margin-bottom: 14px;
}

.login-brand p {
  color: rgba(255,255,255,.72);
  max-width: 30ch;
  margin: 0 0 36px;
}

.login-brand ul {
  list-style: none;
  padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 12px;
  position: relative; z-index: 1;
}

.login-brand li {
  color: rgba(255,255,255,.85);
  font-size: 14px;
  display: flex; align-items: center; gap: 10px;
}

.login-brand li::before {
  content: '';
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--brand);
  flex: none;
}

.login-panel {
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}

.login-card { width: 100%; max-width: 340px; }

.login-card h2 { font-size: 22px; margin-bottom: 6px; }

.login-card .subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 32px;
}

#g_id_signin_container { display: flex; justify-content: center; margin-bottom: 14px; }

.login-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 20px;
  margin: 0;
}

.domain-hint {
  color: var(--text-muted);
  font-size: 12.5px;
  text-align: center;
  margin: 4px 0 0;
}

.dev-login-box {
  margin-top: 28px;
  padding: 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--brand-soft);
}

.dev-login-title {
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 600;
  margin: 0 0 12px;
  text-align: center;
}

.dev-login-actions { display: flex; gap: 8px; }
.dev-login-actions .btn { flex: 1; font-size: 13px; padding: 7px 10px; }

/* ===================== 通用元件 ===================== */
.btn {
  display: inline-flex;
  align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 8px 16px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }

.btn-outline { background: var(--surface); border-color: var(--border); color: var(--text-2); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand-dark); }

.btn-danger { background: var(--surface); border-color: var(--border); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.btn-sm { padding: 5px 11px; font-size: 13px; }

.link { color: var(--brand-dark); cursor: pointer; background: none; border: none;
        font-size: 13.5px; font-family: inherit; padding: 0; }
.link:hover { text-decoration: underline; }
.link-danger { color: var(--danger); }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--text-2);
  white-space: nowrap;
}

.badge-brand   { background: var(--brand-soft); color: var(--brand-dark); }
.badge-success { background: #EDF4EA; color: var(--success); }
.badge-danger  { background: #F7ECEE; color: var(--danger); }
.badge-info    { background: #E9F0F5; color: var(--info); }
.badge-muted   { background: #F0EFEC; color: var(--text-muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  padding: 36px 16px;
}

/* ===================== 頁首 ===================== */
.topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky; top: 0; z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 28px; min-width: 0; }

.brand-mark {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 16px;
  white-space: nowrap;
}

.brand-logo {
  width: 34px; height: 34px;
  object-fit: contain;
  flex: none;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 15px; font-weight: 700; letter-spacing: .5px; }
.brand-text small { font-size: 11px; color: var(--text-muted); font-weight: 400; }

.main-nav { display: flex; gap: 4px; }

.main-nav a {
  padding: 7px 13px;
  border-radius: 7px;
  font-size: 14px;
  color: var(--text-2);
  position: relative;
  white-space: nowrap;
}

.main-nav a:hover { background: var(--border-soft); }
.main-nav a.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }

.nav-dot {
  display: inline-block;
  min-width: 17px; height: 17px;
  padding: 0 5px;
  margin-left: 6px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  line-height: 17px;
  text-align: center;
  vertical-align: middle;
}

.topbar-right { display: flex; align-items: center; gap: 14px; }

.user-chip { display: flex; align-items: center; gap: 9px; }

.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 600;
  flex: none;
}

.user-meta { display: flex; flex-direction: column; line-height: 1.25; }
.user-meta strong { font-size: 13.5px; font-weight: 600; }
.user-meta span { font-size: 11.5px; color: var(--text-muted); }

/* ===================== 頁面容器 ===================== */
.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px;
}

.page-head { margin-bottom: 22px; }
.page-head h2 { font-size: 22px; }
.page-head p { color: var(--text-muted); font-size: 14px; margin: 4px 0 0; }

.section { margin-bottom: 34px; }

.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 16px;
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  display: flex; align-items: center; gap: 9px;
}

.section-title::before {
  content: '';
  width: 3px; height: 14px;
  background: var(--brand);
  border-radius: 2px;
}

/* ===================== 首頁 Hero ===================== */
.hero {
  background: linear-gradient(120deg, #262626 0%, #1B1B1B 100%);
  border-radius: 14px;
  padding: 26px 30px;
  color: #fff;
  margin-bottom: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 26px;
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: '';
  position: absolute; right: -90px; top: -90px;
  width: 280px; height: 280px; border-radius: 50%;
  background: radial-gradient(circle, rgba(240,127,9,.3), transparent 70%);
}

.hero-text { position: relative; z-index: 1; }
.hero-text h2 { font-size: 24px; margin-bottom: 5px; }
.hero-text p { margin: 0; color: rgba(255,255,255,.7); font-size: 13.5px; }

.hero-stats { display: flex; gap: 12px; position: relative; z-index: 1; }

.hero-stat {
  background: rgba(255,255,255,.09);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 10px;
  padding: 12px 20px;
  text-align: center;
  min-width: 92px;
}

.hero-stat b { display: block; font-size: 24px; line-height: 1.2; }
.hero-stat span { font-size: 11.5px; color: rgba(255,255,255,.72); white-space: nowrap; }
.hero-stat.is-alert b { color: var(--brand); }

/* ===================== 應用卡片 ===================== */
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 14px;
}

.app-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 17px 18px;
  display: flex;
  align-items: flex-start;
  gap: 13px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .18s, transform .18s, border-color .18s;
}

.app-card:hover {
  border-color: var(--brand);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.app-card-icon {
  width: 40px; height: 40px;
  border-radius: 9px;
  background: var(--brand-soft);
  display: grid; place-items: center;
  font-size: 19px;
  flex: none;
}

.app-card-body { min-width: 0; }
.app-card-body strong { display: block; font-size: 14.5px; font-weight: 600; }
.app-card-body span {
  display: block;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ===================== 首頁雙欄 ===================== */
.dash-cols {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 18px;
  margin-bottom: 34px;
}

.panel { padding: 18px 20px; }

.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 12px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border-soft);
}

.panel-head h3 { font-size: 15px; }

/* 公告列表 */
.ann-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
}

.ann-item:last-child { border-bottom: none; }
.ann-item:hover .ann-title { color: var(--brand-dark); }

.ann-title {
  flex: 1;
  font-size: 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.ann-item.unread .ann-title { font-weight: 600; }

.ann-item.unread .ann-title::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--brand);
  margin-right: 7px;
  vertical-align: middle;
}

.ann-date, .ann-author { font-size: 12px; color: var(--text-muted); flex: none; }

/* 申請進度列表 */
.sub-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border-soft);
}

.sub-item:last-child { border-bottom: none; }
.sub-item-body { flex: 1; min-width: 0; }
.sub-item-body strong { display: block; font-size: 13.5px; font-weight: 600; }
.sub-item-body > span {
  display: flex; flex-wrap: wrap; gap: 4px 12px;
  font-size: 11.5px; color: var(--text-muted);
}
.sub-serial, .sub-time { white-space: nowrap; }

/* ===================== 表格 ===================== */
.table-wrap { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.table th, .table td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13.5px;
  vertical-align: middle;
}

.table th {
  background: #FAF9F7;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  white-space: nowrap;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #FCFBF9; }
.table .truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table .nowrap { white-space: nowrap; }

/* ===================== 表單元件 ===================== */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 15px; }

.field > label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

.field .req { color: var(--danger); margin-left: 3px; }

.input, .field input[type="text"], .field input[type="number"],
.field input[type="date"], .field select, .field textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 9px 11px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}

.input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(240,127,9,.13);
}

.field textarea { min-height: 92px; resize: vertical; }

.check-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 13.5px; color: var(--text-2);
  margin-bottom: 15px;
}

.check-row input { width: 15px; height: 15px; accent-color: var(--brand); }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }

.filter-chip {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

.filter-chip:hover { border-color: var(--brand); }
.filter-chip.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 500; }

.search-box { position: relative; flex: 1; min-width: 180px; max-width: 320px; }
.search-box input { padding-left: 34px; }
.search-box::before {
  content: '🔍';
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  font-size: 13px; opacity: .5;
}

/* ===================== 彈窗 ===================== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}

.modal {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  display: flex; flex-direction: column;
}

.modal-lg { max-width: 640px; }

.modal-head {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; justify-content: space-between;
}

.modal-head h3 { font-size: 17px; }

.modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 22px; line-height: 1; color: var(--text-muted); padding: 0;
}

.modal-close:hover { color: var(--text); }

.modal-body { padding: 22px 24px; overflow-y: auto; }

.modal-foot {
  padding: 15px 24px;
  border-top: 1px solid var(--border-soft);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* 公告內文 */
.ann-detail-meta {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-muted); font-size: 12.5px;
  margin-bottom: 16px;
}

.ann-detail-content { white-space: pre-wrap; font-size: 14.5px; line-height: 1.85; color: var(--text-2); }

/* 申請單明細 */
.detail-list { display: flex; flex-direction: column; gap: 0; }

.detail-row {
  display: flex; gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 14px;
}

.detail-row:last-child { border-bottom: none; }
.detail-row dt { width: 108px; flex: none; color: var(--text-muted); font-size: 13px; }
.detail-row dd { margin: 0; flex: 1; white-space: pre-wrap; }

/* 提示訊息 */
.toast {
  position: fixed;
  bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff;
  padding: 11px 22px; border-radius: 8px;
  font-size: 14px; box-shadow: var(--shadow-lg);
  z-index: 200;
}

.toast.is-error { background: var(--danger); }

/* ===================== RWD ===================== */
@media (max-width: 1024px) {
  /* 空間不足時只留頭像，避免導覽列與使用者資訊重疊 */
  .user-meta { display: none; }
  .topbar { padding: 0 18px; }
  .topbar-left { gap: 18px; overflow-x: auto; }
}

@media (max-width: 900px) {
  .login-page { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .dash-cols { grid-template-columns: 1fr; }
  .hero { flex-direction: column; align-items: flex-start; }
  .hero-stats { width: 100%; overflow-x: auto; padding-bottom: 2px; }
  .hero-stat { flex: 1 0 auto; padding: 10px 16px; }
}

@media (max-width: 640px) {
  .page { padding: 18px 16px; }
  .topbar { padding: 0 16px; height: auto; min-height: var(--header-h); flex-wrap: wrap; gap: 10px; }
  .topbar-left { width: 100%; gap: 14px; overflow-x: auto; }
  .main-nav { gap: 2px; }
  .main-nav a { padding: 6px 10px; font-size: 13px; }
  .user-meta { display: none; }
  .app-grid { grid-template-columns: 1fr; }
  .hero { padding: 20px; }
  .hero-text h2 { font-size: 20px; }
  .detail-row { flex-direction: column; gap: 3px; }
  .detail-row dt { width: auto; }

  /* 公告列表：標題獨占一行完整顯示，分類與日期移到下一行 */
  .ann-item { flex-wrap: wrap; gap: 8px; padding: 13px 0; }
  .ann-title {
    flex: 1 0 100%;
    order: -1;
    white-space: normal;
    line-height: 1.5;
  }
  .ann-author { display: none; }

  /* 申請進度：狀態標籤換到下一行，避免擠壓單號 */
  .sub-item { flex-wrap: wrap; }
  .sub-item-body { flex: 1 0 60%; }
}
