:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #667085;
  --line: #d9e2ef;
  --primary: #174ea6;
  --primary-dark: #0f3470;
  --soft: #eaf2ff;
  --danger: #b42318;
  --warning: #b54708;
  --success: #027a48;
  --shadow: 0 18px 50px rgba(20, 39, 71, .10);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at top left, rgba(23, 78, 166, .20), transparent 35%),
    linear-gradient(145deg, #f8fbff 0%, #eaf2ff 100%);
}

.login-shell { width: min(940px, 94vw); }
.login-card {
  background: rgba(255, 255, 255, .92);
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 36px;
}
.brand-block { display: flex; gap: 20px; align-items: center; margin-bottom: 28px; }
.brand-mark {
  width: 76px;
  height: 76px;
  border-radius: 24px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--primary), #4e8cf5);
  color: #fff;
  font-weight: 800;
  font-size: 28px;
  box-shadow: 0 15px 30px rgba(23, 78, 166, .25);
}
.brand-mark.small { width: 50px; height: 50px; border-radius: 16px; font-size: 18px; }
h1 { margin: 0; font-size: clamp(24px, 4vw, 36px); }
p { color: var(--muted); line-height: 1.55; }
.login-form { display: grid; gap: 18px; }

label { display: grid; gap: 7px; font-weight: 700; font-size: 14px; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 14px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}
textarea { min-height: 92px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(23, 78, 166, .16); border-color: var(--primary); }
button, .button-link {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
button:hover, .button-link:hover { background: var(--primary-dark); }
button.secondary, .button-link.secondary { background: #eef2f7; color: #253858; }
button.secondary:hover, .button-link.secondary:hover { background: #dfe7f2; }
button.danger { background: var(--danger); }
button.warning { background: var(--warning); }
button.success { background: var(--success); }
button.mini, .button-link.mini { padding: 8px 10px; border-radius: 10px; font-size: 12px; }
.demo-box {
  margin-top: 24px;
  background: var(--soft);
  border: 1px solid #cfe0ff;
  padding: 16px;
  border-radius: 18px;
}
.demo-box p { margin: 7px 0; }

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 18px min(36px, 4vw);
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.topbar h1 { font-size: 20px; }
.topbar p { margin: 3px 0 0; font-size: 13px; }
.user-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f7f9fc;
  border: 1px solid var(--line);
  padding: 10px 12px;
  border-radius: 18px;
}
.user-chip span { font-weight: 800; }
.user-chip small { color: var(--muted); }
.user-chip a { color: var(--primary); text-decoration: none; font-weight: 800; }

.tabs {
  display: flex;
  gap: 8px;
  padding: 16px min(36px, 4vw) 0;
  overflow-x: auto;
}
.tab {
  background: #fff;
  color: var(--muted);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.container { padding: 18px min(36px, 4vw) 60px; }
.panel { display: none; }
.panel.active { display: block; }
.grid.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}
.card, .box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 10px 28px rgba(20, 39, 71, .06);
}
.card { padding: 20px; }
.card span { color: var(--muted); font-weight: 700; font-size: 13px; }
.card strong { display: block; font-size: 32px; margin-top: 10px; }
.box { padding: 22px; margin-bottom: 18px; }
.box-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; }
.box-head h2, .box h2 { margin: 0; }
.box-head p { margin: 6px 0 0; }
.split { align-items: flex-end; }
.filters { display: flex; gap: 10px; min-width: min(520px, 100%); }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 880px; }
th, td { text-align: left; border-bottom: 1px solid var(--line); padding: 13px 10px; vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: #f8fafc; }
td { font-size: 14px; }
.badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.badge.draft { background: #eef2f7; color: #344054; }
.badge.review { background: #fff4e5; color: var(--warning); }
.badge.approved { background: #e6f7ef; color: var(--success); }
.badge.rejected { background: #fdecec; color: var(--danger); }
.badge.archived { background: #f2f4f7; color: #475467; }
.row-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 16px;
}
.wide { grid-column: 1 / -1; }
.role-grid {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  display: grid;
  gap: 10px;
}
.role-grid legend { font-weight: 800; }
.role-grid label { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.role-grid input { width: auto; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.workflow-grid, .rule-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}
.workflow-card, .rule-grid article {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
}
.workflow-card h3, .rule-grid h3 { margin: 0 0 8px; }
.workflow-card p { margin: 0 0 10px; }
.muted { color: var(--muted); }
dialog {
  width: min(520px, 94vw);
  border: 0;
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 0;
}
dialog::backdrop { background: rgba(15, 23, 42, .45); }
.modal-form { padding: 24px; display: grid; gap: 16px; }
.modal-form h2 { margin: 0; }
.notice {
  border-radius: 16px;
  padding: 12px 14px;
  margin-bottom: 14px;
  background: #eaf2ff;
  color: #173b78;
  font-weight: 700;
}
.notice.error { background: #fdecec; color: var(--danger); }
.history-list { margin: 8px 0 0; padding-left: 16px; color: var(--muted); }
.history-list li { margin-bottom: 4px; }

@media (max-width: 860px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .grid.cards, .form-grid { grid-template-columns: 1fr; }
  .filters { flex-direction: column; }
  .box-head { align-items: flex-start; flex-direction: column; }
  .user-chip { flex-wrap: wrap; }
}
