/* ============================================================
 *  工地工具集 · Portal 入口页
 *  落地页风格:渐变 hero + 大号工具卡片
 *  mobile-first · 与 worker / admin 共用同一组设计令牌
 * ============================================================ */

:root {
  /* —— 与 worker / admin 完全一致的品牌 —— */
  --brand:        #0E4DA4;
  --brand-press:  #0A3A82;
  --brand-soft:   #E8F0FE;
  --accent:       #F97316;
  --accent-soft:  #FFF2E5;

  --primary:      var(--brand);
  --primary-press: var(--brand-press);
  --danger:       #DC2626;
  --success:      #10B981;
  --warning:      #F59E0B;

  --bg:           #F6F8FB;
  --surface:      #FFFFFF;
  --surface-2:    #F1F5F9;
  --surface-3:    #E2E8F0;

  --text:         #0F172A;
  --text-2:       #334155;
  --text-muted:   #64748B;
  --text-soft:    #94A3B8;
  --text-on-brand: #FFFFFF;

  --line:         #E2E8F0;
  --line-soft:    #F1F5F9;

  --shadow-sm:    0 1px 2px rgba(15,23,42,.05);
  --shadow:       0 1px 3px rgba(15,23,42,.06), 0 4px 12px rgba(15,23,42,.04);
  --shadow-md:    0 4px 6px rgba(15,23,42,.07), 0 12px 24px rgba(15,23,42,.06);
  --shadow-lg:    0 10px 30px rgba(15,23,42,.10);
  --shadow-brand: 0 6px 16px rgba(14,77,164,.30);

  --r-sm: 10px;
  --r:    14px;
  --r-md: 18px;
  --r-lg: 24px;
  --r-pill: 999px;

  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
          "Helvetica Neue", "Hiragino Sans GB", sans-serif;

  --ease: cubic-bezier(.2, .7, .2, 1);
  --t:    .18s;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

/* 子页面通用：返回首页 */
.back-portal {
  display: inline-block;
  color: var(--brand);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 10px;
  margin: 8px 14px 0;
  border-radius: var(--r-sm);
  transition: background var(--t) var(--ease), transform var(--t-fast) var(--ease);
}
.back-portal:hover { background: var(--brand-soft); }
.back-portal:active { transform: scale(.98); }

html, body {
  margin: 0; padding: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 15px;
  line-height: 1.55;
  overflow-x: hidden;
}

/* ============ Hero ============ */
.hero {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse at top left, rgba(14,77,164,.18), transparent 60%),
    radial-gradient(ellipse at bottom right, rgba(249,115,22,.14), transparent 60%),
    linear-gradient(135deg, #0E4DA4 0%, #1e6fd0 50%, #2c8df0 100%);
  color: #fff;
  padding: 56px 24px 72px;
  text-align: center;
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,.06) 1px, transparent 1px),
    radial-gradient(circle at 60% 70%, rgba(255,255,255,.06) 1px, transparent 1px),
    radial-gradient(circle at 80% 20%, rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 60px 60px, 50px 50px, 80px 80px;
  opacity: .8;
  pointer-events: none;
}
.hero-inner {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
}
.brand-mark {
  display: inline-block;
  width: 64px; height: 64px;
  background: rgba(255,255,255,.15);
  border-radius: 20px;
  padding: 4px;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.18);
  margin-bottom: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
.hero-title {
  margin: 0 0 6px;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -.5px;
}
.hero-subtitle {
  margin: 0 0 18px;
  font-size: 15px;
  font-weight: 400;
  opacity: .85;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.20);
  border-radius: var(--r-pill);
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 500;
  backdrop-filter: blur(8px);
}
.status-dot {
  width: 8px; height: 8px;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(16,185,129,.30);
  animation: pulse 2s ease-in-out infinite;
}
.status-dot.off { background: var(--danger); box-shadow: 0 0 0 3px rgba(220,38,38,.30); }
@keyframes pulse {
  0%, 100% { opacity: 1 }
  50% { opacity: .55 }
}

/* ============ Main / Section ============ */
.main {
  max-width: 920px;
  margin: -28px auto 0;
  padding: 0 18px 60px;
  position: relative;
  z-index: 2;
}
.section { margin-top: 26px; }
.section-header { padding: 4px 10px 12px; }
.section-heading {
  margin: 0 0 2px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.2px;
  display: flex; align-items: center; gap: 8px;
}
.section-heading::before {
  content: "";
  width: 4px;
  height: 16px;
  background: var(--brand);
  border-radius: 2px;
}
.section-sub {
  margin: 0;
  padding-left: 12px;
  font-size: 12.5px;
  color: var(--text-muted);
}

/* ============ Cards ============ */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}
.card {
  display: flex;
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: 18px 18px 16px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease);
  box-shadow: var(--shadow);
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--brand);
}
.card:active { transform: scale(.985); }

.card-icon {
  flex-shrink: 0;
  width: 48px; height: 48px;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  margin-right: 14px;
  background: linear-gradient(135deg, var(--brand) 0%, #1e6fd0 100%);
  color: #fff;
  box-shadow: var(--shadow-brand);
}
.card-icon.accent {
  background: linear-gradient(135deg, var(--accent) 0%, #EA580C 100%);
  box-shadow: 0 6px 16px rgba(249,115,22,.30);
}
.card-icon.gray {
  background: linear-gradient(135deg, #475569 0%, #334155 100%);
  box-shadow: 0 6px 16px rgba(15,23,42,.20);
}
.card-body { flex: 1; min-width: 0; }
.card-title {
  margin: 2px 0 4px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.2px;
}
.card-desc {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

.card-arrow {
  position: absolute;
  top: 14px; right: 14px;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 13px;
  transition: background var(--t) var(--ease), color var(--t) var(--ease), transform var(--t) var(--ease);
}
.card:hover .card-arrow {
  background: var(--brand);
  color: #fff;
  transform: translateX(2px);
}

.card.placeholder {
  border-style: dashed;
  background: transparent;
  box-shadow: none;
  color: var(--text-soft);
}
.card.placeholder .card-icon { background: var(--surface-2); color: var(--text-soft); box-shadow: none; }

/* ============ Footer ============ */
.footer {
  text-align: center;
  padding: 32px 16px;
  font-size: 12.5px;
  color: var(--text-muted);
}
.footer-line { margin: 0 0 4px; font-weight: 500; }
.footer-sub { margin: 0; font-size: 11.5px; color: var(--text-soft); }

/* ============ 启动占位(避免闪烁) ============ */
.boot-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
  padding: 20px;
}
.boot-card {
  background: var(--surface);
  border-radius: var(--r-md);
  padding: 32px 40px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  min-width: 200px;
}
.boot-spinner {
  width: 32px; height: 32px;
  border: 3px solid rgba(14,77,164,.18);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: bootSpin .9s linear infinite;
}
@keyframes bootSpin { to { transform: rotate(360deg); } }
.boot-text {
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 1px;
}

/* ============ 登录页(未登录) ============ */
.login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background:
    radial-gradient(circle at 20% 0%, rgba(14,77,164,.10), transparent 50%),
    radial-gradient(circle at 80% 100%, rgba(249,115,22,.06), transparent 50%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: var(--r-md);
  padding: 36px 30px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}
.login-card .brand-mark { margin-bottom: 12px; }
.login-title {
  margin: 0 0 4px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.4px;
}
.login-sub {
  margin: 0 0 22px;
  font-size: 13px;
  color: var(--text-muted);
}
.login-card .lbl {
  display: block;
  width: 100%;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  margin: 12px 0 6px;
  text-align: left;
}
.login-card .ipt {
  width: 100%;
  font-size: 15px;
  padding: 12px 14px;
  min-height: 44px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  outline: none;
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.login-card .ipt:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(14,77,164,.12);
}
.login-card .btn-primary {
  width: 100%;
  min-height: 44px;
  margin-top: 22px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--r-sm);
  background: linear-gradient(135deg, var(--brand) 0%, #1665C9 100%);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-brand);
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t) var(--ease);
}
.login-card .btn-primary:hover { box-shadow: 0 8px 20px rgba(14,77,164,.40); }
.login-card .btn-primary:active { transform: scale(.985); }
.login-card .err {
  width: 100%;
  margin-top: 12px;
  font-size: 13px;
  color: var(--danger);
  text-align: center;
  min-height: 18px;
  font-weight: 500;
}
.login-foot {
  width: 100%;
  margin: 20px 0 0;
  font-size: 11.5px;
  color: var(--text-soft);
  text-align: center;
}

/* ============ 工具页头部用户信息 ============ */
.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
}
.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.22);
  border-radius: var(--r-pill);
  padding: 6px 6px 6px 14px;
  font-size: 13px;
  color: #fff;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.user-name { font-weight: 600; }
.user-role {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-weight: 600;
}
.user-role.role-super {
  background: linear-gradient(135deg, var(--accent), #EA580C);
  color: #fff;
}
.user-role.role-admin {
  background: rgba(255,255,255,.18);
  color: #fff;
}
.btn-logout {
  background: rgba(0,0,0,.25);
  color: #fff;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: var(--r-pill);
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.btn-logout:active { background: rgba(0,0,0,.45); }

/* ============ Mobile ============ */
@media (max-width: 480px) {
  .hero { padding: 40px 18px 60px; }
  .hero-title { font-size: 28px; }
  .hero-subtitle { font-size: 14px; }
  .brand-mark { width: 56px; height: 56px; }
  .main { padding: 0 14px 48px; }
  .cards { gap: 11px; }
  .card { padding: 16px 14px; }
  .card-icon { width: 42px; height: 42px; font-size: 20px; margin-right: 12px; }
}
