:root {
  --bg: #F6F7F9;
  --card: #FFFFFF;
  --border: #E3E6EB;
  --text: #1F2328;
  --muted: #6B7280;
  --accent: #2563EB;
  --accent-soft: #EFF4FF;
  --success: #16A34A;
  --error: #DC2626;
  --warning: #D97706;
  --radius: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  min-width: 1024px;
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0; font-weight: 600; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 600; }
code, pre { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 12.5px; }

.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex: 0 0 220px; background: var(--card); border-right: 1px solid var(--border);
  padding: 16px 12px; position: sticky; top: 0; height: 100vh;
}
.brand { font-weight: 700; font-size: 15px; padding: 4px 10px 16px; }
.brand small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.nav a {
  display: block; padding: 7px 10px; border-radius: 6px; color: var(--text); margin-bottom: 2px;
}
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidebar-footer { position: absolute; bottom: 16px; left: 12px; right: 12px; color: var(--muted); font-size: 12px; }
.sidebar-footer form { margin-top: 6px; }

.main { flex: 1; min-width: 0; padding: 20px 28px 40px; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; min-height: 36px; }
.page-header .actions { display: flex; gap: 8px; align-items: center; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.grid { display: grid; gap: 16px; }
.grid.kpi { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi-card .label { color: var(--muted); font-size: 12px; }
.kpi-card .value { font-size: 22px; font-weight: 600; margin-top: 4px; }
.kpi-card .hint { color: var(--muted); font-size: 12px; margin-top: 2px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; background: #FAFBFC; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.wrap-text { white-space: pre-wrap; word-break: break-word; max-width: 640px; }

.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 500;
  border: 1px solid transparent; white-space: nowrap;
}
.badge-trial, .badge-scheduled, .badge-running { background: #EFF4FF; color: var(--accent); border-color: #C7D7FE; }
.badge-active, .badge-succeeded, .badge-done, .badge-sent { background: #ECFDF3; color: var(--success); border-color: #ABEFC6; }
.badge-expired, .badge-none, .badge-draft, .badge-canceled, .badge-stopped { background: #F2F4F7; color: var(--muted); border-color: var(--border); }
.badge-blocked, .badge-failed { background: #FEF3F2; color: var(--error); border-color: #FECDCA; }
.badge-pending { background: #FFFAEB; color: var(--warning); border-color: #FEDF89; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--card); color: var(--text); font: inherit;
  cursor: pointer; line-height: 1.2; white-space: nowrap;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #1D4ED8; }
.btn-danger { color: var(--error); border-color: #FECDCA; }
.btn-danger:hover { background: #FEF3F2; }
.btn-small { padding: 4px 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

form.inline { display: inline; }
.form-grid { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 12px 16px; align-items: start; max-width: 860px; }
.form-grid label { padding-top: 7px; color: var(--muted); }
input[type=text], input[type=number], input[type=password], input[type=date], input[type=time],
input[type=search], input[type=url], select, textarea {
  width: 100%; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px;
  font: inherit; color: var(--text); background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #BFD3FE; border-color: var(--accent); }
textarea { min-height: 120px; resize: vertical; }
textarea.tall { min-height: 280px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.help { color: var(--muted); font-size: 12px; margin-top: 4px; }
.checkbox { display: flex; gap: 8px; align-items: center; padding-top: 7px; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.filters input, .filters select { width: auto; min-width: 140px; }

.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 12px; border: 1px solid; }
.flash-success { background: #ECFDF3; border-color: #ABEFC6; color: #067647; }
.flash-error { background: #FEF3F2; border-color: #FECDCA; color: #B42318; }
.flash-warning { background: #FFFAEB; border-color: #FEDF89; color: #B54708; }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty strong { display: block; color: var(--text); margin-bottom: 4px; }

.pagination { display: flex; gap: 6px; align-items: center; justify-content: flex-end; padding: 10px 12px; border-top: 1px solid var(--border); }
.pagination .current { font-weight: 600; }

.dl { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 6px 12px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }

.progress { height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.progress > div { height: 100%; background: var(--accent); }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 360px; }
.login-card .field { margin-bottom: 12px; }
.login-card label { display: block; color: var(--muted); margin-bottom: 4px; }
.readonly-note { background: #FFFAEB; color: #B54708; border: 1px solid #FEDF89; border-radius: 6px; padding: 6px 10px; font-size: 12px; margin-bottom: 12px; }
.chart-box { position: relative; height: 220px; }
