:root {
  --bg: #0f1419;
  --surface: #171d26;
  --surface-2: #1f2733;
  --border: #2b3543;
  --text: #e6edf3;
  --text-dim: #8b98a8;
  --accent: #ff6b35;
  --accent-dim: #ff6b3522;
  --green: #3fb950;
  --yellow: #d29922;
  --orange: #db6d28;
  --red: #f85149;
  --blue: #58a6ff;
  --radius: 10px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", "Microsoft JhengHei", "PingFang TC", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- layout */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 28px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand {
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
  letter-spacing: .5px;
}
.brand span { color: var(--accent); }
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a {
  color: var(--text-dim);
  padding: 6px 13px;
  border-radius: 7px;
  font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-dim); color: var(--accent); }
.userbox { color: var(--text-dim); font-size: 13px; display: flex; align-items: center; gap: 12px; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 24px; }

h1 { font-size: 22px; margin-bottom: 4px; }
h2 { font-size: 16px; margin-bottom: 14px; font-weight: 600; }
h3 { font-size: 14px; margin-bottom: 10px; color: var(--text-dim); font-weight: 600;
     text-transform: uppercase; letter-spacing: .6px; }
.subtitle { color: var(--text-dim); margin-bottom: 22px; }

/* ----------------------------------------------------------------- cards */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.card.pad0 { padding: 0; overflow: hidden; }
.card-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  display: flex; justify-content: space-between; align-items: center;
}

/* ----------------------------------------------------------------- stats */
.stat .label {
  color: var(--text-dim); font-size: 11px; text-transform: uppercase;
  letter-spacing: .7px; font-weight: 600;
}
.stat .value { font-size: 30px; font-weight: 700; line-height: 1.25; margin-top: 4px; }
.stat .value.sm { font-size: 21px; }
.stat .hint { color: var(--text-dim); font-size: 12px; margin-top: 2px; }

.c-green  { color: var(--green); }
.c-yellow { color: var(--yellow); }
.c-orange { color: var(--orange); }
.c-red    { color: var(--red); }
.c-blue   { color: var(--blue); }
.c-dim    { color: var(--text-dim); }
.c-accent { color: var(--accent); }

/* ---------------------------------------------------------------- badges */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600; border: 1px solid transparent;
}
.b-green  { background: #3fb95022; color: var(--green);  border-color: #3fb95055; }
.b-yellow { background: #d2992222; color: var(--yellow); border-color: #d2992255; }
.b-orange { background: #db6d2822; color: var(--orange); border-color: #db6d2855; }
.b-red    { background: #f8514922; color: var(--red);    border-color: #f8514955; }
.b-blue   { background: #58a6ff22; color: var(--blue);   border-color: #58a6ff55; }
.b-dim    { background: var(--surface-2); color: var(--text-dim); border-color: var(--border); }

/* ---------------------------------------------------------------- tables */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; padding: 10px 14px; font-size: 11px; font-weight: 600;
  color: var(--text-dim); text-transform: uppercase; letter-spacing: .6px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 11px 14px; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
.num { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- charts */
.chart-box { position: relative; height: 260px; padding: 16px; }
.chart-box.tall { height: 320px; }

/* -------------------------------------------------------------- calendar */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border); }
.cal .dow {
  background: var(--surface-2); padding: 8px; text-align: center;
  font-size: 11px; color: var(--text-dim); font-weight: 600;
}
.cal .day { background: var(--surface); min-height: 92px; padding: 6px; }
.cal .day.other { background: var(--bg); opacity: .45; }
.cal .day.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal .daynum { font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }
.cal .ev {
  display: block; font-size: 11px; padding: 2px 5px; border-radius: 4px;
  margin-bottom: 2px; background: var(--surface-2); color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cal .ev:hover { text-decoration: none; background: var(--border); }
.cal .ev.done { border-left: 3px solid var(--green); }
.cal .ev.planned { border-left: 3px solid var(--blue); }
.cal .ev.partial { border-left: 3px solid var(--yellow); }
.cal .ev.skipped { border-left: 3px solid var(--red); }

/* ----------------------------------------------------------------- forms */
label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 4px; font-weight: 600; }
input, select, textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  color: var(--text); padding: 8px 11px; border-radius: 7px;
  font-family: inherit; font-size: 14px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
.field { margin-bottom: 14px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }

.btn {
  background: var(--accent); color: #fff; border: none; padding: 9px 18px;
  border-radius: 7px; font-weight: 600; cursor: pointer; font-size: 14px;
  font-family: inherit;
}
.btn:hover { opacity: .9; }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn.sm { padding: 5px 12px; font-size: 12px; }

/* ----------------------------------------------------------------- misc */
.progress { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.progress > div { height: 100%; background: var(--accent); }

.alert {
  padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px;
  border: 1px solid; font-size: 13px;
}
.alert.red    { background: #f8514915; border-color: #f8514955; color: #ffa198; }
.alert.yellow { background: #d2992215; border-color: #d2992255; color: #e3b341; }
.alert.green  { background: #3fb95015; border-color: #3fb95055; color: #7ee787; }
.alert.blue   { background: #58a6ff15; border-color: #58a6ff55; color: #a5d6ff; }

.empty { text-align: center; color: var(--text-dim); padding: 36px 18px; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.flex { display: flex; gap: 10px; align-items: center; }
.between { display: flex; justify-content: space-between; align-items: center; }
.small { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }

/* ----------------------------------------------------------------- login */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { font-size: 26px; text-align: center; display: block; margin-bottom: 6px; }
.login-hint {
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-dim); line-height: 1.9;
}
.login-hint code { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; color: var(--text); }
