*{box-sizing:border-box}
html,body{margin:0;min-height:100%;font-family:"Segoe UI","Microsoft JhengHei",Arial,sans-serif;color:#0f172a;background:#dfe5ec}
a{text-decoration:none;color:inherit}
input,select,textarea,button{font:inherit}
body{line-height:1.45}

/* layout */
.app-shell{display:grid;grid-template-columns:270px 1fr;min-height:100vh}
.desktop-sidebar{background:#d7e0ea;border-right:1px solid #b8c4d3;color:#233045;padding:12px 10px;display:flex;flex-direction:column;position:sticky;top:0;height:100vh;overflow:auto}
.brand-block{background:#0f2342;color:#fff;border-radius:12px;padding:18px 16px;margin:4px 4px 12px;box-shadow:0 8px 20px rgba(15,35,66,.18)}
.brand-title{font-size:28px;font-weight:900;letter-spacing:.02em}
.brand-subtitle{margin-top:6px;font-size:15px;color:#d8e4ff}
.desktop-nav{display:grid;gap:10px}
.nav-group{background:#cfd8e3;border:1px solid #bcc9d7;border-radius:10px;padding:10px}
.nav-group-title{font-size:14px;font-weight:900;color:#475569;margin-bottom:8px;letter-spacing:.02em}
.nav-link{display:block;padding:11px 14px;border-radius:10px;color:#0f172a;background:#eef2f6;border:1px solid #cbd5e1;font-weight:700;margin-bottom:6px;transition:.15s ease}
.nav-link:last-child{margin-bottom:0}
.nav-link:hover{background:#fff;border-color:#94a3b8;transform:translateY(-1px)}
.nav-link.active{background:#0f2342;color:#fff;border-color:#0f2342;box-shadow:inset 0 0 0 1px rgba(255,255,255,.08)}
.desktop-user-panel{margin-top:auto;background:#cfd8e3;border:1px solid #bcc9d7;border-radius:10px;padding:12px;margin-left:4px;margin-right:4px}
.user-card-name{font-weight:900;font-size:18px}
.user-card-role{font-size:13px;color:#475569;margin-top:4px;margin-bottom:10px}
.utility-link{background:#f8fafc}

.desktop-main{min-width:0;background:#e9edf2}
.desktop-topbar{height:74px;background:#081834;color:#fff;border-bottom:1px solid #142a4f;padding:0 20px;display:flex;align-items:center;justify-content:space-between;position:sticky;top:0;z-index:10;box-shadow:0 2px 10px rgba(2,6,23,.2)}
.top-left,.top-right{display:flex;align-items:center;gap:10px}
.top-title{font-size:24px;font-weight:900;line-height:1.1}
.top-subtitle{font-size:13px;color:#bfdbfe;margin-top:4px}
.top-status-group{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:8px}
.status-chip{display:inline-flex;align-items:center;padding:7px 12px;border-radius:999px;background:rgba(255,255,255,.1);border:1px solid rgba(255,255,255,.12);color:#e2e8f0;font-size:13px}
.status-chip.strong{background:#14532d;color:#dcfce7;border-color:#166534;font-weight:800}
.shell-info-bar{display:flex;flex-wrap:wrap;gap:16px;padding:10px 22px;background:#f8fafc;border-bottom:1px solid #d7dee8;color:#475569;font-size:13px}
.desktop-content{padding:18px 18px 28px;max-width:1800px}
.sidebar-overlay{display:none}
.menu-toggle{display:none;background:#f1f5f9;border:1px solid #cbd5e1;font-size:20px;padding:6px 12px;color:#0f172a}

/* generic cards */
.card,.desktop-panel,.stat{background:#f7fafc;border:1px solid #cdd7e3;border-radius:14px;box-shadow:0 1px 2px rgba(15,23,42,.03),0 8px 18px rgba(15,23,42,.03)}
.card,.desktop-panel{padding:18px;margin-bottom:16px}
.page-head{display:flex;flex-wrap:wrap;align-items:flex-end;justify-content:space-between;gap:14px;margin-bottom:14px}
.page-title-block h1,.page-title-block h2{margin:0;font-size:22px;line-height:1.2;color:#172554}
.page-title-block p{margin:4px 0 0;color:#64748b}
.page-actions{display:flex;flex-wrap:wrap;gap:8px}
.section-header{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:12px;padding-bottom:10px;border-bottom:1px solid #dbe3ee}
.section-header h2,.section-header h3{margin:0;font-size:18px;color:#0f2342}
.section-header p{margin:3px 0 0;color:#64748b;font-size:13px}
.desktop-caption{font-size:13px;color:#64748b}
.narrow{max-width:760px}.muted{color:#64748b}

/* forms */
.form-row,.filter,.inline{display:flex;gap:10px;flex-wrap:wrap;align-items:center}
.form-grid{display:grid;grid-template-columns:repeat(4,minmax(170px,1fr));gap:10px}
.form-grid.compact{grid-template-columns:repeat(3,minmax(180px,1fr))}
.field{display:grid;gap:6px}
.field label,.login-card label{font-weight:800;color:#334155;font-size:14px}
input,select,textarea{padding:11px 12px;border:1px solid #bfcbd9;border-radius:10px;background:white;min-height:42px;outline:none;transition:border-color .15s ease, box-shadow .15s ease;width:100%}
textarea{min-height:96px;resize:vertical}
input:focus,select:focus,textarea:focus{border-color:#2563eb;box-shadow:0 0 0 3px rgba(37,99,235,.12)}
button,.button{padding:10px 14px;border:1px solid #c5cfdb;border-radius:10px;background:linear-gradient(#fbfdff,#edf2f7);font-weight:900;color:#1e293b;cursor:pointer;transition:.15s ease;min-height:42px}
button:hover,.button:hover{transform:translateY(-1px);box-shadow:0 6px 16px rgba(15,23,42,.08)}
button.primary,.button.primary,.primary{background:linear-gradient(#2f66dd,#2457c8);border-color:#1e4fb8;color:#fff}
button.soft,.button.soft{background:#f1f5f9}
.full{width:100%;margin-top:12px}
.check{display:flex;align-items:center;gap:7px;font-weight:700;color:#334155}
.check input{min-height:auto;width:auto}
.inline input,.inline select,.inline button{width:auto}
.inline input[type="date"]{min-width:146px}

/* tables */
.table-wrap{overflow:auto;border:1px solid #d7dee8;border-radius:12px;background:#fff}
table{width:100%;border-collapse:collapse;white-space:nowrap}
th,td{padding:12px 10px;border-bottom:1px solid #e2e8f0;text-align:left;vertical-align:top}
th{background:#eef3f8;color:#334155;font-weight:900;position:sticky;top:0;z-index:1}
tbody tr:nth-child(even){background:#fafcff}
tbody tr:hover{background:#eef6ff}
.money{text-align:right;font-variant-numeric:tabular-nums}
.pill{padding:5px 10px;border-radius:999px;font-weight:800;font-size:12px;display:inline-flex}
.pill.ok{background:#dcfce7;color:#166534}

/* dashboard */
.stats{display:grid;grid-template-columns:repeat(5,1fr);gap:14px;margin-bottom:16px}
.stat{padding:18px}
.stat b{font-size:38px;line-height:1;color:#0f172a}
.stat span{margin-top:8px;color:#64748b;font-weight:700}
.flow{padding:14px 16px;background:#eef3f8;border:1px solid #d7dee8;border-radius:12px;margin:10px 0;font-weight:700}
.flow span{color:#2563eb;font-weight:900;margin:0 8px}

/* alerts */
.alert{padding:12px 14px;border-radius:10px;background:#dbeafe;color:#1d4ed8;margin-bottom:12px;border:1px solid #bfdbfe}
.alert.error{background:#fee2e2;color:#991b1b;border-color:#fecaca}
.group-title{background:#dbeafe;color:#1e40af;padding:10px 12px;border-radius:10px;margin:14px 0 8px;font-weight:900;border:1px solid #bfdbfe}

/* role page */
.role-layout{display:grid;grid-template-columns:300px 1fr;gap:16px}
.role-list{display:grid;margin-top:12px;gap:6px}
.role-list a{padding:10px 12px;border-radius:10px;background:#eef3f8;border:1px solid #d7dee8;font-weight:700}
.role-list a.active{background:#0f2342;color:#fff;border-color:#0f2342}
.perm-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}
.check-card{border:1px solid #d7dee8;border-radius:12px;padding:12px;display:flex;gap:8px;background:#fbfdff}
.check-card input{width:auto;min-height:auto;margin-top:3px}
.check-card span{display:grid}
.check-card small{color:#64748b}

/* photos */
.photo-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:14px}
.photo-card{background:white;border:1px solid #d7dee8;border-radius:14px;overflow:hidden;box-shadow:0 4px 12px rgba(15,23,42,.05)}
.photo-card img{width:100%;aspect-ratio:4/3;object-fit:cover;background:#111827}
.photo-card div{padding:12px;display:grid;gap:4px}
.photo-card span{color:#64748b;font-size:13px}

/* login */
.login-bg{min-height:100vh;display:grid;place-items:center;background:radial-gradient(circle at 20% 10%,#1d4ed855,transparent 35%),linear-gradient(135deg,#020617,#0f172a)}
.login-card{width:min(460px,calc(100% - 30px));background:white;padding:30px;border-radius:20px;box-shadow:0 24px 70px #0007}
.web-login-card{position:relative;overflow:hidden;border:1px solid rgba(255,255,255,.12)}
.web-login-card:before{content:"";position:absolute;inset:0 0 auto 0;height:5px;background:linear-gradient(90deg,#2563eb,#38bdf8,#2563eb)}
.login-kicker{font-size:12px;letter-spacing:.15em;color:#2563eb;font-weight:900}.login-card h1{text-align:center;margin:12px 0 0}.login-card h2{text-align:center;margin:4px 0 4px}.login-card p{text-align:center;color:#64748b}
.login-badge{display:inline-flex;margin-top:12px;padding:5px 10px;border-radius:999px;background:#dbeafe;color:#1d4ed8;font-weight:800;font-size:13px}
.login-subtitle{margin:10px 0 18px!important}.login-form{display:grid}.password-wrap{position:relative}.password-wrap input{padding-right:70px}.password-toggle{position:absolute;right:6px;top:6px;bottom:6px;padding:0 11px;background:#f1f5f9;color:#334155;font-size:13px}.login-button{min-height:46px;font-size:16px}.login-help{margin-top:18px;padding:12px;border:1px solid #e2e8f0;border-radius:10px;background:#f8fafc;display:grid;gap:4px}.login-help span{color:#64748b;font-size:13px}.login-footer{text-align:center;color:#94a3b8;font-size:12px;margin-top:18px}

/* helpers */
.desktop-list{display:grid;gap:10px}
.summary-box{background:#eef3f8;border:1px solid #d7dee8;border-radius:12px;padding:14px}
.empty-hint{padding:24px;text-align:center;color:#64748b;background:#f8fafc;border:1px dashed #cbd5e1;border-radius:12px}

@media(max-width:1280px){
  .stats{grid-template-columns:repeat(3,1fr)}
  .form-grid{grid-template-columns:repeat(3,minmax(160px,1fr))}
  .perm-grid{grid-template-columns:repeat(2,1fr)}
  .photo-grid{grid-template-columns:repeat(3,1fr)}
}

@media(max-width:980px){
  .app-shell{display:block}
  .desktop-sidebar{position:fixed;left:-286px;top:0;width:278px;height:100vh;z-index:100;transition:left .22s ease;box-shadow:10px 0 30px rgba(0,0,0,.25)}
  .sidebar-open .desktop-sidebar{left:0}
  .sidebar-overlay{display:block;position:fixed;inset:0;background:rgba(15,23,42,.52);z-index:90;opacity:0;pointer-events:none;transition:opacity .22s}
  .sidebar-open .sidebar-overlay{opacity:1;pointer-events:auto}
  .menu-toggle{display:inline-flex}
  .desktop-topbar{padding:0 12px}
  .top-title{font-size:20px}
  .top-status-group span:first-child{display:none}
  .form-grid,.form-grid.compact{grid-template-columns:1fr 1fr}
  .role-layout{grid-template-columns:1fr}
  .stats{grid-template-columns:1fr 1fr}
  .photo-grid{grid-template-columns:1fr 1fr}
}

@media(max-width:700px){
  .desktop-content{padding:12px}
  .shell-info-bar{padding:10px 12px}
  .form-grid,.form-grid.compact{grid-template-columns:1fr}
  .stats{grid-template-columns:1fr}
  .photo-grid{grid-template-columns:1fr}
  .perm-grid{grid-template-columns:1fr}
  .page-head{align-items:flex-start}
  .login-card{padding:24px 20px}
}

/* ===== v1.2.1 Dashboard: match Windows desktop summary ===== */
.desktop-dashboard-head{margin:0 0 18px 0}
.desktop-dashboard-head h1{margin:0;font-size:30px;line-height:1.2;font-weight:900;color:#111827}
.desktop-welcome{margin-top:4px;font-size:18px;color:#64748b}
.dashboard-kpis{display:flex;flex-wrap:wrap;gap:12px;margin-bottom:12px}
.dashboard-kpi{width:220px;min-height:108px;background:#fff;border:1px solid #cbd5e1;border-radius:10px;padding:18px;display:flex;flex-direction:column;justify-content:center;box-shadow:0 1px 2px rgba(15,23,42,.03)}
.dashboard-kpi-wide{width:250px}
.dashboard-kpi span{font-size:15px;color:#64748b;margin-bottom:4px}
.dashboard-kpi b{font-size:30px;line-height:1.15;color:#111827;font-weight:900}
.desktop-core-flow{background:#eff6ff;border:1px solid #bfdbfe;border-radius:10px;padding:20px;margin-top:12px;color:#0f172a}
.desktop-core-flow h2{font-size:20px;margin:0 0 8px 0}
.desktop-core-flow div{margin-top:6px;font-size:15px}
@media(max-width:980px){.dashboard-kpi,.dashboard-kpi-wide{width:calc(50% - 6px)}.desktop-welcome{font-size:15px}}
@media(max-width:620px){.dashboard-kpi,.dashboard-kpi-wide{width:100%}.desktop-dashboard-head h1{font-size:24px}}

/* ===== v1.3 Web + Windows 即時同步 ===== */
.realtime-sync-badge{position:fixed;right:22px;bottom:22px;z-index:250;background:#0f766e;color:#fff;border:1px solid #115e59;border-radius:999px;padding:11px 16px;font-weight:900;box-shadow:0 10px 28px rgba(15,23,42,.24);cursor:pointer}
.realtime-sync-badge[hidden]{display:none!important}
@media(max-width:700px){.realtime-sync-badge{right:12px;bottom:12px;max-width:calc(100% - 24px)}}

/* ===== v1.3.1 網路狀態 / 功能使用流程圖 ===== */
.network-status{gap:7px;font-weight:900;transition:.2s ease}
.network-dot{width:9px;height:9px;border-radius:999px;display:inline-block;background:#fbbf24;box-shadow:0 0 0 3px rgba(251,191,36,.12)}
.network-status.online{background:#14532d;color:#dcfce7;border-color:#166534}
.network-status.online .network-dot{background:#4ade80;box-shadow:0 0 0 3px rgba(74,222,128,.15)}
.network-status.offline{background:#7f1d1d;color:#fee2e2;border-color:#991b1b}
.network-status.offline .network-dot{background:#f87171;box-shadow:0 0 0 3px rgba(248,113,113,.15)}
.network-status.checking{background:#78350f;color:#fef3c7;border-color:#92400e}
.network-status.checking .network-dot{background:#fbbf24;box-shadow:0 0 0 3px rgba(251,191,36,.15)}
.workflow-board{display:grid;gap:16px;margin-bottom:16px}
.workflow-section{background:#fff;border:1px solid #cbd5e1;border-radius:14px;padding:18px;box-shadow:0 4px 12px rgba(15,23,42,.04)}
.workflow-section-title{display:flex;align-items:flex-start;gap:12px;margin-bottom:14px}
.workflow-section-title>span{width:34px;height:34px;flex:0 0 34px;border-radius:999px;background:#0f2342;color:#fff;display:grid;place-items:center;font-weight:900}
.workflow-section-title b{display:block;font-size:19px;color:#0f172a}
.workflow-section-title small{display:block;color:#64748b;margin-top:3px;font-size:13px}
.workflow-line{display:flex;align-items:center;flex-wrap:wrap;gap:8px}
.workflow-node{display:inline-flex;align-items:center;justify-content:center;min-height:48px;padding:10px 14px;border:1px solid #cbd5e1;border-radius:10px;font-weight:900;text-align:center;background:#f8fafc;color:#1e293b}
a.workflow-node:hover{transform:translateY(-1px);box-shadow:0 6px 14px rgba(15,23,42,.08)}
.workflow-node.blue{background:#eff6ff;border-color:#93c5fd;color:#1e3a8a}
.workflow-node.green{background:#ecfdf5;border-color:#6ee7b7;color:#065f46}
.workflow-node.orange{background:#fff7ed;border-color:#fdba74;color:#9a3412}
.workflow-node.slate{background:#f1f5f9;border-color:#cbd5e1;color:#334155}
.workflow-node.strong{box-shadow:inset 0 0 0 2px rgba(15,23,42,.05)}
.workflow-arrow{font-size:24px;font-weight:900;color:#64748b}
.workflow-tips{display:grid;gap:9px;color:#334155}
.workflow-note{margin-top:0}
@media(max-width:980px){.network-status{display:inline-flex}.workflow-arrow{transform:rotate(90deg)}.workflow-line{align-items:stretch}.workflow-node{flex:1 1 180px}}
@media(max-width:700px){.workflow-line{display:grid;grid-template-columns:1fr}.workflow-arrow{text-align:center;transform:rotate(90deg);line-height:1}.workflow-node{width:100%}}

/* v1.3.2 - 檔案備份管理 */
.backup-message{padding:12px 14px;border-radius:10px;margin-bottom:14px;font-weight:700}
.backup-message.ok{background:#ecfdf5;border:1px solid #86efac;color:#166534}
.backup-message.error{background:#fef2f2;border:1px solid #fca5a5;color:#991b1b}
.backup-destination-grid{display:grid;grid-template-columns:1fr 1fr;gap:14px}
.backup-box{border:1px solid #d7dee8;border-radius:12px;background:#fff;padding:14px}
.backup-box label,.backup-time-row label{display:block;margin:8px 0 5px;font-weight:700}
.backup-box small,.backup-option small,.desktop-panel small{display:block;color:#64748b;margin-top:7px}
.backup-check{display:flex!important;align-items:center;gap:8px;margin-bottom:10px!important}
.wide-input{width:100%;box-sizing:border-box}
.backup-option-row{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.backup-option{display:flex;align-items:flex-start;gap:10px;padding:14px}
.weekday-grid{display:flex;flex-wrap:wrap;gap:8px;margin:14px 0}
.weekday-grid label{background:#fff;border:1px solid #d7dee8;border-radius:9px;padding:9px 12px}
.backup-time-row{max-width:280px}
.backup-time-row input{width:160px}
.backup-restore-row{display:grid;grid-template-columns:1fr auto;gap:10px;margin-top:12px;align-items:center}
.backup-actions{display:flex;gap:10px;align-items:center;flex-wrap:wrap}
.button-link{display:inline-flex;text-decoration:none;align-items:center;justify-content:center}
.path-cell{max-width:420px;overflow:hidden;text-overflow:ellipsis}
@media(max-width:900px){.backup-destination-grid,.backup-option-row,.backup-restore-row{grid-template-columns:1fr}.backup-time-row{max-width:none}}
