*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #f5f6fa;
  --surface:  #ffffff;
  --border:   #e2e5ed;
  --text:     #1a1d23;
  --muted:    #6b7280;
  --primary:  #2563eb;
  --primary-h:#1d4ed8;
  --success:  #16a34a;
  --warning:  #d97706;
  --danger:   #dc2626;
  --radius:   8px;
  --shadow:   0 1px 4px rgba(0,0,0,.07);
}

body { font-family: system-ui, -apple-system, sans-serif; font-size: 14px;
       background: var(--bg); color: var(--text); line-height: 1.5; }

/* ── Navbar ── */
.navbar { background: var(--surface); border-bottom: 1px solid var(--border);
          padding: 0 24px; height: 52px; display: flex; align-items: center;
          justify-content: space-between; position: sticky; top: 0; z-index: 10; }
.brand  { font-weight: 600; font-size: 15px; color: var(--primary); text-decoration: none; }
.nav-links { display: flex; gap: 20px; align-items: center; }
.nav-links a { color: var(--muted); text-decoration: none; font-size: 13px; }
.nav-links a:hover { color: var(--text); }
.btn-logout { color: var(--danger) !important; }

/* ── Layout ── */
.container { max-width: 1200px; margin: 0 auto; padding: 28px 24px; }
.page-header { display: flex; align-items: center; justify-content: space-between;
               margin-bottom: 20px; gap: 12px; }
.page-header h2 { font-size: 18px; font-weight: 600; }
.header-actions { display: flex; gap: 8px; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 16px;
       border-radius: var(--radius); border: none; cursor: pointer;
       font-size: 13px; font-weight: 500; text-decoration: none; transition: .15s; }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); }
.btn-outline  { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--bg); }
.btn-sm       { padding: 5px 12px; font-size: 12px; }
.btn-full     { width: 100%; justify-content: center; }

/* ── Alerts ── */
.alert { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px;
         font-size: 13px; }
.alert-error   { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: var(--success); border: 1px solid #bbf7d0; }

/* ── Login ── */
.login-wrap  { min-height: calc(100vh - 52px); display: flex; align-items: center;
               justify-content: center; }
.login-card  { background: var(--surface); border: 1px solid var(--border);
               border-radius: 12px; padding: 36px 40px; width: 360px;
               box-shadow: var(--shadow); }
.login-card h1  { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.login-sub      { color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.field          { margin-bottom: 16px; }
.field label    { display: block; font-size: 12px; font-weight: 500;
                  color: var(--muted); margin-bottom: 5px; }
.field input    { width: 100%; padding: 8px 12px; border: 1px solid var(--border);
                  border-radius: var(--radius); font-size: 14px; outline: none; }
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }

/* ── Table ── */
.table { width: 100%; border-collapse: collapse; font-size: 13px;
         background: var(--surface); border-radius: var(--radius); overflow: hidden;
         box-shadow: var(--shadow); }
.table th { background: #f1f3f8; padding: 9px 12px; text-align: left;
             font-weight: 600; font-size: 12px; color: var(--muted);
             border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fafbff; }
.actions { display: flex; gap: 6px; }
.mono    { font-family: monospace; font-size: 12px; }

/* ── Badges ── */
.badge { display: inline-flex; padding: 3px 8px; border-radius: 20px;
         font-size: 11px; font-weight: 500; }
.badge-done    { background: #dcfce7; color: #15803d; }
.badge-running { background: #fef9c3; color: #92400e; }
.badge-error   { background: #fee2e2; color: #991b1b; }
.badge-pending { background: #f1f5f9; color: #64748b; }

/* ── Empty state ── */
.empty-state { background: var(--surface); border: 1px dashed var(--border);
               border-radius: var(--radius); padding: 40px; text-align: center;
               color: var(--muted); }

/* ── Progress page ── */
.progress-wrap { background: var(--surface); border: 1px solid var(--border);
                 border-radius: var(--radius); padding: 20px; }
.log-box { background: #0f1117; color: #a8d8a0; font-family: monospace;
           font-size: 12px; border-radius: 6px; padding: 14px 16px;
           min-height: 300px; max-height: 500px; overflow-y: auto;
           margin-bottom: 16px; }
.log-line       { line-height: 1.6; }
.log-error      { color: #f87171; }
.spinner-row    { display: flex; align-items: center; gap: 10px;
                  color: var(--muted); font-size: 13px; }
.done-row       { display: flex; gap: 10px; }
.spinner        { width: 16px; height: 16px; border: 2px solid var(--border);
                  border-top-color: var(--primary); border-radius: 50%;
                  animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Result table ── */
.result-table-wrap { overflow-x: auto; margin-bottom: 16px; }
.result-table { min-width: 900px; }
.result-table .col-section  { width: 150px; }
.result-table .col-element  { width: 220px; }
.result-table .col-site     { width: 90px; text-align: center; }
.result-table .col-mine     { background: #f0fdf4; }
.result-table .col-count,
.result-table .col-pct      { width: 55px; text-align: center; }
.result-table .col-priority { width: 220px; }

.cell-section  { font-weight: 600; font-size: 12px; color: var(--muted);
                 background: #f8f9fc; vertical-align: top; padding-top: 12px; }
.cell-element  { color: var(--text); }
.cell-check    { text-align: center; }
.cell-mine     { background: #f0fdf4; }
.cell-priority { font-size: 12px; font-weight: 500; padding: 6px 10px; }
.cell-num, .cell-pct { text-align: center; color: var(--muted); font-size: 12px; }

/* Checkbox */
.checkbox-wrap { display: inline-flex; cursor: pointer; }
.checkbox-wrap input { position: absolute; opacity: 0; width: 0; height: 0; }
.check-visual { width: 18px; height: 18px; border: 1.5px solid var(--border);
                border-radius: 4px; display: flex; align-items: center;
                justify-content: center; transition: .15s; background: #fff; }
.check-visual.check-yes { background: #dcfce7; border-color: #86efac; }
.check-visual.check-yes::after { content: '✓'; font-size: 11px; color: #15803d; }
.checkbox-wrap:hover .check-visual { border-color: var(--primary); }

/* Save bar */
.save-bar { position: sticky; bottom: 0; background: var(--surface);
            border-top: 1px solid var(--border); padding: 12px 0;
            display: flex; justify-content: flex-end; }

.error-text { color: var(--danger); font-size: 12px; }
