/* ===== Hanlin Admin – iOS-style Premium Design ===== */
/* Color system from Mini Program: #2F54EB primary, iOS semantics */
:root {
  --brand: #2F54EB;
  --brand-dark: #1E3FBD;
  --brand-weak: rgba(47, 84, 235, 0.08);
  --brand-line: rgba(47, 84, 235, 0.18);
  --brand-light: rgba(47, 84, 235, 0.12);
  --success: #34C759;
  --warning: #FF9500;
  --danger: #FF3B30;
  --bg: #F2F2F7;
  --surface: #FFFFFF;
  --surface-2: #FAFAFC;
  --ink: #1C1E22;
  --ink-2: #3C3F46;
  --ink-3: #6E7078;
  --ink-4: #A1A3AB;
  --border: rgba(60, 60, 67, 0.06);
  --border-solid: #E5E5EA;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.06);
  --transition: .2s ease;
  --sidebar-w: 240px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--ink); line-height: 1.6; font-size: 14px; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
button { cursor: pointer; border: none; font-family: inherit; font-size: inherit; transition: var(--transition); }
input, select, textarea { font-family: inherit; font-size: 14px; border: 1px solid var(--border-solid); border-radius: var(--radius-sm); padding: 8px 12px; outline: none; transition: var(--transition); width: 100%; background: var(--surface); color: var(--ink); }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-weak); }
select { cursor: pointer; }

/* ===== SVG Icon system ===== */
.icon-svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.icon-svg.sm { width: 16px; height: 16px; }
.icon-svg.lg { width: 24px; height: 24px; }

/* ===== Login ===== */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(160deg, #1a2a52 0%, #2F54EB 60%, #597EF7 100%); }
.login-card { background: var(--surface); border-radius: 20px; padding: 48px 40px 40px; width: 400px; max-width: 92vw; box-shadow: 0 20px 60px rgba(0,0,0,.15); text-align: center; }
.login-logo { width: 64px; height: 64px; border-radius: 14px; object-fit: cover; margin-bottom: 16px; box-shadow: 0 4px 12px rgba(47,84,235,.2); }
.login-card h2 { font-size: 22px; margin-bottom: 4px; color: var(--ink); font-weight: 700; }
.login-card p { color: var(--ink-3); font-size: 13px; margin-bottom: 28px; }
.login-card .field { margin-bottom: 16px; text-align: left; }
.login-card .field label { display: block; font-size: 13px; color: var(--ink-3); margin-bottom: 4px; font-weight: 500; }
.login-card .field input { height: 44px; font-size: 15px; border-radius: 10px; }

/* ===== Buttons ===== */
.btn-primary { background: var(--brand); color: #fff; border-radius: 10px; padding: 10px 24px; font-weight: 600; width: 100%; height: 44px; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-sm { padding: 5px 12px; font-size: 13px; border-radius: 6px; }
.btn-outline { background: transparent; color: var(--brand); border: 1px solid var(--brand-line); border-radius: 6px; padding: 5px 12px; font-weight: 500; }
.btn-outline:hover { background: var(--brand-weak); }
.btn-danger { background: rgba(255,59,48,.08); color: var(--danger); border: 1px solid rgba(255,59,48,.15); border-radius: 6px; padding: 5px 12px; font-weight: 500; }
.btn-danger:hover { background: rgba(255,59,48,.15); }
.btn-success { background: rgba(52,199,89,.08); color: #247D3B; border: 1px solid rgba(52,199,89,.15); border-radius: 6px; padding: 5px 12px; font-weight: 500; }
.btn-warn { background: rgba(255,149,0,.08); color: #A15A00; border: 1px solid rgba(255,149,0,.15); border-radius: 6px; padding: 5px 12px; font-weight: 500; }
.btn-ghost { background: transparent; color: var(--ink-3); padding: 5px 12px; border-radius: 6px; }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }

/* ===== Layout ===== */
#app { display: none; min-height: 100vh; }
.layout { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border-solid); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; z-index: 100; }
.sidebar-brand { padding: 20px 20px 16px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); }
.sidebar-brand img { width: 36px; height: 36px; border-radius: 8px; }
.sidebar-brand span { font-size: 16px; font-weight: 700; color: var(--ink); letter-spacing: .3px; }
.sidebar-user { padding: 14px 20px; font-size: 13px; color: var(--ink-4); border-bottom: 1px solid var(--border); }
.sidebar-user strong { color: var(--ink-2); font-weight: 600; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.nav-section { padding: 16px 20px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--ink-4); font-weight: 600; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 16px; margin: 1px 8px; color: var(--ink-3); cursor: pointer; transition: var(--transition); border-radius: var(--radius-sm); font-size: 14px; }
.nav-item:hover { background: var(--brand-weak); color: var(--brand); }
.nav-item.active { background: var(--brand-weak); color: var(--brand); font-weight: 600; }
.nav-item .nav-icon { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.nav-item .nav-icon svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-item .badge { background: var(--danger); color: #fff; font-size: 11px; border-radius: 10px; padding: 0 6px; margin-left: auto; font-weight: 600; min-width: 18px; text-align: center; line-height: 18px; }
.nav-badge { display: inline-flex; align-items: center; justify-content: center; background: var(--danger); color: #fff; font-size: 11px; border-radius: 10px; padding: 0 6px; margin-left: auto; font-weight: 600; min-width: 18px; line-height: 18px; }
.nav-badge--dot { width: 8px; height: 8px; min-width: 8px; padding: 0; border-radius: 50%; margin-left: auto; }
.sidebar-footer { padding: 8px 0; border-top: 1px solid var(--border); }

.main-area { margin-left: var(--sidebar-w); flex: 1; min-height: 100vh; display: flex; flex-direction: column; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 32px; height: 52px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50; }
.topbar h1 { font-size: 16px; font-weight: 700; color: var(--ink); }
.topbar-actions { display: flex; gap: 12px; align-items: center; }
.content { flex: 1; padding: 24px 32px; }

/* ===== Cards (iOS grouped style) ===== */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-header h3 { font-size: 15px; font-weight: 700; color: var(--ink); }
.card-grid { display: grid; gap: 16px; }
.card-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.card-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.card-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

/* ===== Stat Cards ===== */
.stat-card { background: var(--surface); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 14px; }
.stat-icon { width: 44px; height: 44px; border-radius: 11px; display: flex; align-items: center; justify-content: center; }
.stat-icon svg { width: 22px; height: 22px; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.stat-icon.blue { background: var(--brand-weak); }
.stat-icon.blue svg { stroke: var(--brand); }
.stat-icon.green { background: rgba(52,199,89,.1); }
.stat-icon.green svg { stroke: var(--success); }
.stat-icon.amber { background: rgba(255,149,0,.1); }
.stat-icon.amber svg { stroke: var(--warning); }
.stat-icon.red { background: rgba(255,59,48,.08); }
.stat-icon.red svg { stroke: var(--danger); }
.stat-info .num { font-size: 26px; font-weight: 800; line-height: 1.2; color: var(--ink); }
.stat-info .label { font-size: 13px; color: var(--ink-3); margin-top: 1px; }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead { background: var(--surface-2); }
th { text-align: left; padding: 9px 14px; font-size: 12px; font-weight: 600; color: var(--ink-3); letter-spacing: .3px; white-space: nowrap; border-bottom: 1px solid var(--border-solid); }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; color: var(--ink-2); }
tr:hover td { background: var(--surface-2); }

/* ===== Tags ===== */
.tag { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; line-height: 18px; }
.tag-blue { background: var(--brand-weak); color: var(--brand); }
.tag-green { background: rgba(52,199,89,.12); color: #247D3B; }
.tag-amber { background: rgba(255,149,0,.08); color: #A15A00; }
.tag-red { background: rgba(255,59,48,.1); color: #B3261E; }
.tag-gray { background: rgba(60,60,67,.06); color: var(--ink-3); }

/* ===== Toolbar ===== */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type="text"], .toolbar select { width: auto; min-width: 150px; height: 34px; font-size: 13px; border-radius: 8px; }
.toolbar .spacer { flex: 1; }

/* ===== Progress bar ===== */
.progress-bar { height: 6px; background: #F0F0F0; border-radius: 3px; overflow: hidden; }
.progress-bar .fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--brand), #597EF7); transition: width .4s ease; }

/* ===== Detail blocks ===== */
.detail-section { margin-bottom: 20px; }
.detail-section h4 { font-size: 14px; font-weight: 700; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1.5px solid var(--brand-weak); color: var(--brand-dark); display: flex; align-items: center; gap: 6px; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px 20px; }
.detail-item { display: flex; font-size: 13px; line-height: 1.8; }
.detail-item .dk { color: var(--ink-4); min-width: 76px; flex-shrink: 0; }
.detail-item .dv { font-weight: 500; color: var(--ink-2); word-break: break-all; }

/* ===== Modal ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; z-index: 1000; backdrop-filter: blur(2px); }
.modal { background: var(--surface); border-radius: 16px; padding: 28px; width: 500px; max-width: 94vw; max-height: 85vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.12); }
.modal h3 { font-size: 17px; font-weight: 700; margin-bottom: 18px; color: var(--ink); }
.modal .field { margin-bottom: 14px; }
.modal .field label { display: block; font-size: 13px; font-weight: 500; color: var(--ink-3); margin-bottom: 4px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* ===== Ring chart ===== */
.ring-chart { position: relative; width: 110px; height: 110px; }
.ring-chart svg { transform: rotate(-90deg); }
.ring-chart circle { fill: none; stroke-width: 10; }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-center .pct { font-size: 22px; font-weight: 800; color: var(--brand); }
.ring-center .sub { font-size: 11px; color: var(--ink-4); }

/* ===== Pie ===== */
.pie-chart-wrap { display: flex; align-items: center; gap: 24px; justify-content: center; }
.pie-ring { width: 130px; height: 130px; border-radius: 50%; position: relative; }
.pie-legend { display: flex; flex-direction: column; gap: 6px; }
.pie-legend-item { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.pie-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* ===== Tabs ===== */
.tab-bar { display: flex; gap: 0; border-bottom: 1.5px solid var(--border-solid); margin-bottom: 18px; }
.tab-item { padding: 9px 18px; font-size: 14px; font-weight: 500; color: var(--ink-3); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1.5px; transition: var(--transition); }
.tab-item:hover { color: var(--ink); }
.tab-item.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 700; }

/* ===== Empty / Loading ===== */
.empty { text-align: center; padding: 40px 16px; color: var(--ink-4); }
.empty svg { margin-bottom: 8px; }
.empty p { font-size: 14px; }
.loading-spinner { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--border-solid); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-spinner p { margin-top: 12px; font-size: 13px; color: var(--ink-4); }

/* ===== Node list ===== */
.node-list { display: flex; flex-direction: column; gap: 10px; }
.node-card { display: flex; align-items: center; gap: 14px; padding: 12px 16px; background: var(--surface-2); border-radius: var(--radius-sm); border-left: 3px solid var(--brand); }
.node-card.fixed { border-left-color: var(--ink-4); }
.node-card .node-name { flex: 1; font-weight: 600; color: var(--ink); font-size: 14px; }
.node-card .node-desc { flex: 2; font-size: 13px; color: var(--ink-3); }
.node-actions { display: flex; gap: 6px; }

/* ===== Notification / Todo cards ===== */
.noti-card { padding: 12px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border-solid); margin-bottom: 8px; display: flex; align-items: flex-start; gap: 12px; transition: var(--transition); background: var(--surface); }
.noti-card:hover { box-shadow: var(--shadow-md); }
.noti-card.unread { border-left: 3px solid var(--brand); background: rgba(47,84,235,.03); }
.noti-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); margin-top: 6px; flex-shrink: 0; }
.noti-body { flex: 1; }
.noti-title { font-weight: 600; font-size: 14px; margin-bottom: 2px; color: var(--ink); }
.noti-sub { font-size: 12px; color: var(--ink-3); }
.noti-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

/* ===== Breadcrumb ===== */
.breadcrumb { font-size: 13px; color: var(--ink-3); margin-bottom: 14px; }
.breadcrumb a { color: var(--brand); }
.breadcrumb span { margin: 0 6px; color: var(--ink-4); }

/* ===== Todo Calendar Columns (Apple-style) ===== */
.td-scroll-wrap { overflow-x: auto; max-height: calc(100vh - 240px); border: 1px solid var(--border-soft); border-radius: 10px; }
.td-col { border-right: 1px solid var(--border-soft); flex-shrink: 0; }
.td-col:last-child { border-right: none; }
.td-col--today { background: rgba(47, 84, 235, .04); }
.td-col__head { padding: 10px 8px; text-align: center; border-bottom: 1px solid var(--border-soft); position: sticky; top: 0; background: var(--bg); z-index: 2; }
.td-col__name { font-weight: 600; font-size: 13px; display: block; }
.td-col__date { font-size: 12px; color: var(--ink-3); }
.td-col__body { padding: 6px; min-height: 200px; }
.td-event { padding: 6px 8px; margin-bottom: 6px; border-radius: 8px; background: var(--bg); border: 1px solid var(--border-soft); }
.td-event--done { opacity: .5; }
.td-event--past { border-left: 3px solid var(--warning); }
.td-event__time { font-size: 11px; color: var(--brand); font-weight: 600; }
.td-event__title { font-size: 13px; margin: 2px 0; }
.td-event__actions { display: flex; gap: 3px; margin-top: 4px; }

/* ===== Plan Editor ===== */
.pe-item { padding: 12px 0; border-bottom: 1px solid var(--border-soft); }
.pe-item-header { display: flex; align-items: center; margin-bottom: 8px; }
.pe-item-num { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 12px; font-weight: 600; }
.pe-field-row { display: flex; gap: 8px; margin-bottom: 6px; align-items: center; }
.pe-field { flex: 1; min-width: 0; padding: 8px 12px; border: 1px solid var(--border-solid); border-radius: 8px; font-size: 13px; outline: none; transition: var(--transition); }
.pe-field:focus { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(47,84,235,.1); }
.pe-item-actions { margin-top: 4px; }
.pe-action-btn { flex: 1; padding: 7px 0; border: none; border-radius: 8px; font-size: 13px; cursor: pointer; transition: var(--transition); }
.pe-action-clear { background: var(--bg-1); color: var(--ink-2); }
.pe-action-clear:hover { background: #e0e0e0; }
.pe-action-delete { background: rgba(227,77,89,.08); color: var(--danger); }
.pe-action-delete:hover { background: rgba(227,77,89,.15); }
.pe-dropdown { display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 20; background: #fff; border: 1px solid var(--border-solid); border-radius: 8px; max-height: 200px; overflow-y: auto; box-shadow: 0 4px 16px rgba(0,0,0,.12); margin-top: 2px; }
.pe-dd-item { padding: 8px 12px; font-size: 13px; cursor: pointer; transition: background .15s; }
.pe-dd-item:hover { background: var(--bg-1); }
.pe-sticky-bar { position: fixed; bottom: 0; left: var(--sidebar-w, 260px); right: 0; display: flex; gap: 10px; padding: 12px 24px; background: #fff; border-top: 1px solid var(--border-soft); box-shadow: 0 -2px 8px rgba(0,0,0,.06); z-index: 50; }
.pe-row { display: flex; gap: 8px; margin-bottom: 6px; }
.pe-input { flex: 1; padding: 6px 10px; border: 1px solid var(--border-solid); border-radius: 6px; font-size: 13px; outline: none; transition: var(--transition); }
.pe-input:focus { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(47,84,235,.1); }
.pe-entry { position: relative; }
.pe-accept { font-size: 13px; color: var(--ink-2); }

/* ===== Node cards ===== */
.node-list { display: flex; flex-direction: column; gap: 10px; }
.node-card { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 10px; background: var(--bg); border: 1px solid var(--border-solid); }
.node-card .node-name { font-weight: 500; min-width: 80px; }
.node-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.node-dot--done { background: var(--success); }
.node-dot--skip { background: var(--ink-4); }
.node-dot--progress { background: var(--brand); }
.node-dot--pending { background: var(--border-solid); }
.node-card .node-desc { font-size: 12px; color: var(--ink-3); }
.node-card .node-actions { display: flex; gap: 6px; margin-left: auto; }
.btn-success { background: var(--success); color: #fff; border: none; border-radius: 6px; padding: 4px 12px; font-size: 12px; cursor: pointer; }
.btn-success:hover { opacity: .85; }
.btn-danger { background: var(--danger); color: #fff; border: none; border-radius: 6px; padding: 4px 12px; font-size: 12px; cursor: pointer; }
.btn-danger:hover { opacity: .85; }

/* ===== Password strength ===== */
.pwd-strength { display: flex; gap: 4px; margin-top: 8px; }
.pwd-bar { flex: 1; height: 4px; border-radius: 2px; background: var(--border-solid); transition: var(--transition); }
.pwd-bar.active-1 { background: var(--danger); }
.pwd-bar.active-2 { background: var(--warning); }
.pwd-bar.active-3 { background: #60A5FA; }
.pwd-bar.active-4 { background: var(--success); }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .sidebar { width: 200px; }
  .main-area { margin-left: 200px; }
  .card-grid.cols-4 { grid-template-columns: 1fr 1fr; }
  .card-grid.cols-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .sidebar { display: none; }
  .main-area { margin-left: 0; }
  .content { padding: 16px; }
  .card-grid.cols-2, .card-grid.cols-3, .card-grid.cols-4 { grid-template-columns: 1fr; }
}
