:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #1f5eff;
  --primary-soft: #eaf0ff;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --ok: #047857;
  --ok-soft: #d1fae5;
  --warn: #92400e;
  --warn-soft: #fef3c7;
}
* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }
body { margin: 0; font-family: Roboto, Arial, Helvetica, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.header { background: #111827; color: #fff; padding: 14px; display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.brand { font-weight: 700; letter-spacing: .3px; }
.rupacs-logo { display: block; height: 36px; }
.user { color: #d1d5db; font-size: 14px; overflow-wrap: anywhere; }
.layout { display: grid; grid-template-columns: 230px 1fr; /*min-height: calc(100vh - 52px);*/ }
.sidebar { background: #fff; border-right: 1px solid var(--line); padding: 18px 12px; }
.sidebar a { display: block; padding: 10px 12px; border-radius: 10px; color: #374151; margin-bottom: 4px; }
.sidebar a.active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.main { padding: 24px; max-width: 1400px; width: 100%; min-width: 0; }
h1 { margin: 0 0 18px; font-size: 26px; line-height: 1.2; overflow-wrap: anywhere; }
h2 { margin: 24px 0 12px; font-size: 20px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; box-shadow: 0 8px 22px rgba(17,24,39,.04); margin-bottom: 18px; min-width: 0; }
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metric { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; min-width: 0; }
.metric .num { font-size: 28px; font-weight: 800; margin-bottom: 5px; }
.metric .label { color: var(--muted); font-size: 14px; }
.table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 14px; border: 1px solid var(--line); background: #fff; margin-bottom: 18px; }
.table-responsive table { margin-bottom: 0; border: 0; border-radius: 0; }
table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: 14px; }
th { background: #f9fafb; color: #374151; font-weight: 700; }
tr:last-child td { border-bottom: 0; }
.muted, .text-muted { color: var(--muted); }
.text-danger { color: var(--bad); }
.small { font-size: 12px; }
.text-break { overflow-wrap: anywhere; word-break: break-word; }
.nowrap { white-space: nowrap; }

input, select, textarea { width: 100%; padding: 10px 11px; border: 1px solid #cbd5e1; border-radius: 10px; font-size: 16px; background-color: #fff; min-width: 0; font-family: Roboto, Arial, Helvetica, sans-serif; }
select:not([multiple]) {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 38px;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 512 512'%3E%3Cpath fill='%23000000' d='M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 12px 12px;
}
.door-direction-icon { display: inline-flex; align-items: center; justify-content: center; width: 16px; margin-right: 6px; color: var(--muted); vertical-align: -2px; flex: 0 0 18px; }
.door-direction-icon svg, .door-direction-icon .fa-solid { display: block; width: 16px; height: 14px; max-width: 16px; max-height: 14px; fill: currentColor; }
.badge { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge-ok { color: var(--ok); background: var(--ok-soft); }
.badge-bad { color: var(--bad); background: var(--bad-soft); }
.badge-neutral { color: #374151; background: #e5e7eb; }
.badge-warn { color: var(--warn); background: var(--warn-soft); }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; border: 1px solid var(--line); background: #fff; color: var(--text); padding: 8px 12px; border-radius: 10px; cursor: pointer; font-size: 14px; text-decoration: none; line-height: 1.25; }
.btn:hover { text-decoration: none; border-color: #cbd5e1; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-row { margin-bottom: 14px; min-width: 0; }
label { display: block; font-weight: 700; margin-bottom: 6px; }
input, select, textarea { width: 100%; padding: 10px 11px; border: 1px solid #cbd5e1; border-radius: 10px; font-size: 16px; background: #fff; min-width: 0; font-family: Roboto, Arial, Helvetica, sans-serif; }
input[type="checkbox"], input[type="radio"] { width: auto; min-width: 18px; min-height: 18px; }
.filter { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; align-items: end; }
.flash { padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; overflow-wrap: anywhere; }
.flash.ok, .flash.success { color: var(--ok); background: var(--ok-soft); }
.flash.error { color: var(--bad); background: var(--bad-soft); }
.flash.warning { color: var(--warn); background: var(--warn-soft); }
.flash.info { color: #1d4ed8; background: #dbeafe; }
.inline-form { display: inline; }
.row-muted { color: var(--muted); background: #f9fafb; }
pre { background: #111827; color: #e5e7eb; padding: 14px; border-radius: 12px; overflow: auto; }
.desktop-table { display: block; }
.mobile-cards { display: none; }
.mobile-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; box-shadow: 0 6px 16px rgba(17,24,39,.035); }
.mobile-card-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.mobile-card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.mobile-meta { color: var(--muted); font-size: 12px; margin-bottom: 3px; }
.auto-refresh-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.auto-refresh-toggle-label { display: inline-flex; align-items: center; gap: 6px; margin: 0; color: var(--muted); font-size: 12px; font-weight: 400; cursor: pointer; }
.auto-refresh-toggle-label input { margin: 0; }
.auto-refresh-status { white-space: nowrap; }
.login-wrap { max-width: 400px; margin: 7vh auto 0; }
.login-card { padding: 22px; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 6px; padding: 10px; }
  .sidebar a { margin: 0; flex: 1 1 auto; text-align: center; padding: 9px 10px; }
  .grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; text-align: center; }
.filter { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric .label { color: var(--muted); font-size: 12px; }
}
@media (max-width: 640px) {
  .header { padding: 12px 14px; }
  .user { font-size: 12px; }
  .main { padding: 16px 12px; }
  h1 { font-size: 22px; }
  h2 { font-size: 18px; }
  .card { padding: 14px; border-radius: 12px; }
  .metric .num { font-size: 24px; }
  th, td { padding: 9px 10px; font-size: 13px; }
  .btn-row { flex-direction: column; align-items: stretch; }
  .btn-row .btn, .btn-row button, .btn-row a, .inline-form, .inline-form .btn { width: 100%; }
  .filter .btn { width: 100%; margin-top: 4px; }
  .desktop-table { display: none; }
  .mobile-cards { display: block; }
  .mobile-card-grid { grid-template-columns: 1fr; }
  .mobile-card .btn { width: 100%; }
  .login-wrap { max-width: none; margin: 24px 0 0; }
  .login-card .btn { width: 100%; }
}
.auth-links { margin: 14px 0 0; }
.resend-form { margin-top: 10px; }
.resend-form .btn { width: 100%; }
.login-card form .btn-primary { width: 100%; }
