:root {
  color-scheme: dark;
  --bg: #0f1419;
  --surface: #1a2332;
  --border: #2d3a4f;
  --text: #e8eef7;
  --muted: #8b9bb4;
  --accent: #5b9fd4;
  --accent-dim: #3d7cac;
  --danger: #e06c75;
  --font: system-ui, "Segoe UI", sans-serif;
  --radius: 10px;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  font-size: 0.9em;
  background: #0c1016;
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.top {
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #121a24 0%, var(--bg) 100%);
}

.brand-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.brand-row #logout {
  flex-shrink: 0;
  margin-top: 0.15rem;
}

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 1.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.login-title {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  font-weight: 650;
}

.login-sub {
  margin: 0 0 1.25rem;
  font-size: 0.95rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.login-form .input {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.login-form .input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.login-error {
  min-height: 1.25rem;
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  color: var(--danger);
}

.login-submit {
  margin-top: 0.5rem;
}

.brand h1 {
  margin: 0 0 0.25rem;
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.85rem;
}

.filters {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.workflow-multi-row {
  flex: 1 1 100%;
  flex-direction: column;
  align-items: stretch;
  gap: 0.4rem;
}

.workflow-multi-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.workflow-checkbox-list {
  max-height: 11rem;
  overflow-y: auto;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.workflow-check {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.12rem 0;
}

.workflow-check input {
  margin-top: 0.2rem;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.workflow-check span {
  word-break: break-word;
  line-height: 1.35;
}

.label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  min-width: 4rem;
}

.presets {
  display: flex;
  gap: 0.35rem;
}

input[type="datetime-local"],
input[type="number"],
select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  font: inherit;
}

input[type="number"] {
  width: 6rem;
}

select {
  min-width: 14rem;
  max-width: 100%;
}

.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 0.45rem 0.85rem;
  font: inherit;
  cursor: pointer;
}

.btn:hover {
  border-color: var(--accent-dim);
}

.btn.primary {
  background: linear-gradient(180deg, #4a8ec2 0%, var(--accent-dim) 100%);
  border-color: #4a8ec2;
  font-weight: 600;
}

.btn.preset.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.filter-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  padding: 1rem 1.5rem 0;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}

.kpi .label {
  display: block;
  margin-bottom: 0.25rem;
  min-width: 0;
}

.kpi .value {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 1rem 1.5rem 2rem;
}

@media (max-width: 960px) {
  .grid {
    grid-template-columns: 1fr;
  }
}

.panel-wide {
  grid-column: 1 / -1;
}

.panel h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
}

.table-wrap {
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #0c1016;
}

.panel-wide .table-wrap {
  max-height: 420px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead th {
  position: sticky;
  top: 0;
  background: #151c27;
  z-index: 1;
  text-align: left;
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-weight: 600;
}

tbody td {
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid #1e2732;
  vertical-align: top;
}

tbody tr:last-child td {
  border-bottom: none;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.btn.link {
  background: transparent;
  border: none;
  color: var(--accent);
  padding: 0.15rem 0.35rem;
  text-decoration: underline;
}

.btn.icon {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.15rem 0.45rem;
  color: var(--muted);
}

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.modal-card {
  position: relative;
  width: min(640px, 100%);
  max-height: min(90vh, 720px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

.modal-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.modal-body {
  padding: 1rem;
}

.detail-meta {
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.detail-meta div {
  margin-bottom: 0.25rem;
}
