:root {
  --rule-blue: #2563eb;
  --rule-blue-dark: #1d4ed8;
  --rule-blue-soft: #eff6ff;
  --rule-ink: #162337;
  --rule-muted: #64748b;
  --rule-border: #dce7f7;
  --rule-warning: #b7791f;
  --rule-success: #16856f;
  --rule-danger: #c73546;
}

.rule-admin-main,
.employee-rules-main { padding-bottom: calc(108px + env(safe-area-inset-bottom)); }
.rule-hero { min-height: auto; padding: 24px 28px; }
.rule-hero h1 { margin-bottom: 6px; }
.rule-tabs { display: flex; gap: 8px; padding: 5px; margin: 18px 0; overflow-x: auto; border: 1px solid var(--rule-border); border-radius: 16px; background: #fff; }
.rule-tabs a { flex: 0 0 auto; min-height: 42px; display: inline-flex; align-items: center; justify-content: center; padding: 8px 16px; border-radius: 12px; color: var(--rule-muted); font-weight: 750; text-decoration: none; }
.rule-tabs a.is-active { color: var(--rule-blue-dark); background: var(--rule-blue-soft); box-shadow: inset 0 0 0 1px #bfdbfe; }

.rule-filter,
.employee-rule-filter { display: grid; grid-template-columns: minmax(180px,1.35fr) repeat(3,minmax(150px,1fr)) auto; gap: 12px; align-items: end; padding: 18px; }
.rule-filter label,
.employee-rule-filter label { display: grid; gap: 7px; color: var(--rule-muted); font-size: .79rem; font-weight: 750; }
.rule-filter input,.rule-filter select,.employee-rule-filter input,.employee-rule-filter select { min-height: 44px; }
.rule-admin-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.rule-admin-card { position: relative; display: grid; gap: 14px; padding: 20px; overflow: hidden; }
.rule-admin-card.is-important::before,.employee-rule-card.is-important::before,.employee-rule-detail.is-important::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: #d6a53d; }
.rule-admin-card header,.employee-rule-card header,.employee-rule-detail>header { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; }
.rule-admin-card h2,.employee-rule-card h2,.employee-rule-detail h2 { margin: 6px 0 0; color: var(--rule-ink); font-size: clamp(1.05rem,2vw,1.28rem); line-height: 1.3; overflow-wrap: anywhere; }
.rule-category { display: inline-flex; align-items: center; color: var(--rule-blue-dark); font-size: .73rem; font-weight: 850; letter-spacing: .05em; }
.rule-admin-meta { display: flex; flex-wrap: wrap; gap: 7px 14px; color: var(--rule-muted); font-size: .78rem; }
.rule-confirm-progress { display: grid; grid-template-columns: auto minmax(90px,1fr); gap: 10px; align-items: center; color: var(--rule-muted); font-size: .8rem; }
.rule-confirm-progress b { color: var(--rule-ink); }
.rule-confirm-progress progress { width: 100%; height: 7px; border: 0; border-radius: 99px; overflow: hidden; }
.rule-confirm-progress progress::-webkit-progress-bar { background: #e8eef7; }
.rule-confirm-progress progress::-webkit-progress-value { background: var(--rule-blue); }
.rule-admin-card footer { display: flex; flex-wrap: wrap; gap: 8px; }
.rule-status--draft { color: #805ad5; background: #f3e8ff; }
.rule-status--scheduled { color: #996515; background: #fff8df; }
.rule-status--active { color: var(--rule-success); background: #e7f8f2; }
.rule-status--inactive,.rule-status--archived { color: #64748b; background: #eef2f7; }

.rule-editor-card { padding: clamp(18px,3vw,30px); }
.rule-editor-form { display: grid; gap: 20px; }
.rule-form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.rule-content-field { gap: 7px; }
.rule-content-field>small { color: var(--rule-muted); }
.rule-content-field textarea { min-height: 190px; line-height: 1.55; font-family: inherit; }
.rule-content-field textarea[readonly],.rule-editor-form input[readonly] { background: #f6f8fb; color: #64748b; }
.rule-options,.rule-audience { min-width: 0; margin: 0; padding: 18px; border: 1px solid var(--rule-border); border-radius: 18px; background: #f9fbff; }
.rule-options legend,.rule-audience legend { padding: 0 8px; color: var(--rule-ink); font-weight: 850; }
.rule-options { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.rule-option { min-width: 0; display: flex; align-items: flex-start; gap: 11px; padding: 12px; border: 1px solid #e2eaf5; border-radius: 14px; background: #fff; cursor: pointer; }
.rule-option input { flex: 0 0 auto; width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--rule-blue); }
.rule-option span { min-width: 0; display: grid; gap: 3px; }
.rule-option strong { color: var(--rule-ink); font-size: .9rem; }
.rule-option small { color: var(--rule-muted); line-height: 1.4; }
.rule-option--all { margin-bottom: 14px; border-color: #bfdbfe; background: var(--rule-blue-soft); }
.rule-audience-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.rule-audience-grid>div { min-width: 0; display: grid; gap: 8px; align-content: start; padding: 14px; border-radius: 14px; background: #fff; }
.rule-audience-grid h3 { margin: 0 0 4px; font-size: .9rem; }
.rule-audience-grid label { display: flex; align-items: center; gap: 9px; min-height: 36px; color: var(--rule-ink); font-size: .87rem; }
.rule-audience-grid input { width: 18px; height: 18px; accent-color: var(--rule-blue); }
.rule-audience-grid small { color: var(--rule-muted); }
.rule-lifecycle-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--rule-border); }
.button.danger { border-color: #fecdd3; color: var(--rule-danger); background: #fff7f7; }

.rule-category-layout { display: grid; grid-template-columns: minmax(280px,.75fr) minmax(0,1.6fr); gap: 18px; align-items: start; }
.rule-category-form { position: sticky; top: 86px; display: grid; gap: 14px; padding: 20px; }
.rule-category-form h2 { margin: 0; }
.rule-category-list { display: grid; gap: 12px; }
.rule-category-card { display: grid; gap: 12px; padding: 17px; }
.rule-category-card__top { display: flex; justify-content: space-between; gap: 12px; }
.rule-category-card__top span { color: var(--rule-muted); font-size: .8rem; }

.rule-statistics { display: grid; gap: 20px; padding: clamp(18px,3vw,28px); }
.rule-stat-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; }
.rule-stat-grid article { min-width: 0; display: grid; gap: 6px; padding: 16px; border: 1px solid var(--rule-border); border-radius: 15px; background: #f8fbff; }
.rule-stat-grid span { color: var(--rule-muted); font-size: .78rem; font-weight: 700; }
.rule-stat-grid strong { color: var(--rule-ink); font-size: 1.55rem; }
.rule-pending-list { display: grid; gap: 8px; }
.rule-pending-list>div { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--rule-border); border-radius: 13px; }
.rule-pending-list>div>span:first-child { display: grid; }
.rule-pending-list small { color: var(--rule-muted); }

.employee-rule-filter { grid-template-columns: minmax(180px,1.5fr) minmax(150px,1fr) minmax(160px,1fr) auto; }
.employee-rule-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 15px; }
.employee-rule-card { position: relative; min-width: 0; display: grid; gap: 11px; padding: 20px; color: inherit; text-decoration: none; transition: transform .16s ease,border-color .16s ease,box-shadow .16s ease; }
.employee-rule-card:hover { transform: translateY(-2px); border-color: #b7d2fb; box-shadow: 0 12px 28px rgba(37,99,235,.1); }
.employee-rule-card p { margin: 0; color: var(--rule-muted); line-height: 1.5; }
.employee-rule-card footer { display: flex; justify-content: space-between; gap: 10px; align-items: center; color: var(--rule-muted); font-size: .78rem; }
.rule-pin { color: #9a6700; font-size: .73rem; font-weight: 800; }
.employee-rule-detail { position: relative; display: grid; gap: 18px; padding: clamp(20px,4vw,36px); }
.rule-detail-meta { display: flex; flex-wrap: wrap; gap: 7px 14px; margin-top: 9px; color: var(--rule-muted); font-size: .8rem; }
.rule-detail-summary { margin: 0; padding: 14px 16px; border-left: 3px solid var(--rule-blue); border-radius: 0 12px 12px 0; color: #3d4c63; background: var(--rule-blue-soft); line-height: 1.55; }
.rule-content { color: #263449; font-size: 1rem; line-height: 1.72; overflow-wrap: anywhere; }
.rule-content p:first-child { margin-top: 0; }
.rule-content a { color: var(--rule-blue-dark); font-weight: 700; }
.employee-rule-detail>footer { display: grid; gap: 14px; padding-top: 18px; border-top: 1px solid var(--rule-border); }
.rule-read-state,.rule-ack-complete { display: flex; gap: 10px; align-items: center; color: var(--rule-success); }
.rule-read-state>span { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: #e7f8f2; }
.rule-read-state p,.rule-ack-complete { margin: 0; }
.rule-read-state p { display: grid; }
.rule-read-state small,.rule-ack-complete span { color: var(--rule-muted); }
.rule-ack-complete { justify-content: space-between; flex-wrap: wrap; padding: 13px 15px; border-radius: 13px; background: #eaf8f3; }
.rule-ack-button { min-height: 50px; width: 100%; white-space: normal; line-height: 1.25; }

.dashboard-rule-reminder { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 13px; align-items: center; margin-bottom: 16px; padding: 15px 17px; border: 1px solid #f0d487; border-radius: 18px; color: var(--rule-ink); background: #fffaf0; text-decoration: none; box-shadow: 0 8px 24px rgba(146,98,13,.08); }
.dashboard-rule-reminder__icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; color: #fff; background: #d69e2e; font-weight: 900; }
.dashboard-rule-reminder>span:nth-child(2) { min-width: 0; display: grid; gap: 3px; }
.dashboard-rule-reminder small { color: #7b6a42; }
.dashboard-rule-reminder>b { color: var(--rule-blue-dark); font-size: .82rem; }

@media (max-width: 900px) {
  .rule-filter,.employee-rule-filter { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .rule-filter .button,.employee-rule-filter .button { min-height: 44px; }
  .rule-admin-list,.employee-rule-list { grid-template-columns: 1fr; }
  .rule-category-layout { grid-template-columns: 1fr; }
  .rule-category-form { position: static; }
  .rule-stat-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (max-width: 620px) {
  .rule-hero { padding: 18px; }
  .rule-hero .status-pill { align-self: flex-start; }
  .rule-tabs { margin-inline: -2px; }
  .rule-filter,.employee-rule-filter { grid-template-columns: 1fr; padding: 15px; }
  .rule-admin-card,.employee-rule-card { padding: 17px; }
  .rule-admin-card header,.employee-rule-detail>header { align-items: stretch; }
  .rule-admin-card header,.employee-rule-detail>header,.rule-category-card__top { flex-direction: column; }
  .rule-admin-card header .status-pill,.employee-rule-detail>header .status-pill { align-self: flex-start; }
  .rule-confirm-progress { grid-template-columns: 1fr; }
  .rule-form-grid,.rule-options,.rule-audience-grid { grid-template-columns: 1fr; }
  .rule-options,.rule-audience { padding: 14px; }
  .rule-lifecycle-actions { display: grid; }
  .rule-lifecycle-actions form,.rule-lifecycle-actions button { width: 100%; }
  .employee-rule-card footer { align-items: flex-start; }
  .rule-stat-grid { gap: 8px; }
  .rule-stat-grid article { padding: 13px; }
  .rule-stat-grid strong { font-size: 1.3rem; }
  .dashboard-rule-reminder { grid-template-columns: auto minmax(0,1fr); }
  .dashboard-rule-reminder>b { grid-column: 2; }
}

@media (prefers-reduced-motion: reduce) {
  .employee-rule-card { transition: none; }
}

