@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@500;600;700;800&display=swap');

:root {
  --espresso: #38281f;
  --cocoa: #6f4930;
  --bronze: #9d662e;
  --bronze-dark: #7f4f25;
  --bronze-soft: #efe0ce;
  --cream: #f6f2eb;
  --cream-deep: #eee7dc;
  --paper: #fcfaf6;
  --white: #ffffff;
  --sage: #6f8063;
  --sage-soft: #e7ede2;
  --ink: #2d2925;
  --muted: #7e7770;
  --line: #e7ded3;
  --success: #47775a;
  --warning: #b57930;
  --danger: #9b4942;
  --shadow: 0 12px 36px rgba(65, 47, 34, .055);
  font-family: "DM Sans", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--cream);
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; background: var(--cream); }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.app-shell { display: grid; grid-template-columns: 258px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 24px 18px 20px;
  display: flex; flex-direction: column; color: var(--espresso);
  background: #f3eee6; border-right: 1px solid #e6ddd1;
}
.brand, .login-brand { display: flex; align-items: center; gap: 12px; }
.brand { min-height: 74px; padding: 6px 9px 17px; border-bottom: 1px solid var(--line); }
.brand-logo { width: 88px; height: 70px; object-fit: contain; flex: 0 0 auto; }
.brand strong { display: block; font-family: Manrope, sans-serif; font-size: 14px; letter-spacing: -.2px; }
.brand small { display: block; color: var(--muted); font-size: 10px; margin-top: 3px; }
.sidebar nav { display: grid; gap: 5px; margin-top: 24px; }
.nav-label { margin: 0 12px 9px; font-size: 9px; font-weight: 800; letter-spacing: 1.4px; color: #9f9489; text-transform: uppercase; }
.nav-label-secondary { margin-top: 25px; }
.sidebar nav a {
  padding: 10px 12px; border-radius: 11px; color: #6f665e;
  display: flex; gap: 11px; align-items: center; font-size: 13px; font-weight: 650;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}
.sidebar nav a:hover { background: rgba(157,102,46,.08); color: var(--bronze-dark); transform: translateX(2px); }
.sidebar nav a.active { background: var(--white); color: var(--bronze-dark); box-shadow: 0 6px 18px rgba(85,58,37,.07); }
.nav-icon { width: 26px; height: 26px; border: 1px solid #dbd0c3; border-radius: 8px; display: grid; place-items: center; font-size: 11px; }
.sidebar nav a.active .nav-icon { color: white; background: var(--bronze); border-color: var(--bronze); }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding: 16px 8px 0; }
.user-card { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-card > span:last-child { min-width: 0; }
.user-card strong, .user-card small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card strong { font-size: 12px; }
.user-card small { max-width: 145px; font-size: 9px; color: var(--muted); margin-top: 3px; }
.avatar { width: 35px; height: 35px; flex: 0 0 auto; border-radius: 11px; background: var(--bronze); color: white; display: grid; place-items: center; font-weight: 800; }
.text-button { border: 0; background: none; color: var(--muted); padding: 12px 0 0; cursor: pointer; font-size: 11px; }
.text-button:hover { color: var(--bronze-dark); }

.app-shell main { padding: 0 40px 50px; min-width: 0; }
.topbar { min-height: 112px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.topbar h1 { margin: 3px 0 0; font-family: Manrope, sans-serif; font-size: 27px; letter-spacing: -.85px; color: var(--espresso); }
.eyebrow { text-transform: uppercase; letter-spacing: 1.65px; font-size: 9px; font-weight: 800; color: var(--bronze); margin: 0; }
.eyebrow.light { color: #f1d4ad; }
.topbar-meta { padding: 10px 13px; background: rgba(255,255,255,.7); border: 1px solid var(--line); border-radius: 12px; font-size: 11px; font-weight: 700; display: flex; align-items: center; gap: 7px; }
.topbar-meta small { color: var(--muted); font-weight: 500; margin-left: 5px; }
.live-dot, .status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #5a9169; box-shadow: 0 0 0 4px rgba(90,145,105,.13); }
.status-dot.warning { background: var(--warning); box-shadow: 0 0 0 4px rgba(181,121,48,.13); }
.menu-button { display: none; }

.hero-strip {
  min-height: 192px; border-radius: 20px; color: white; padding: 31px 34px;
  display: flex; align-items: flex-end; justify-content: space-between; overflow: hidden; position: relative;
  background: linear-gradient(115deg, #7b4c27 0%, #9d662e 58%, #b98147 100%);
  box-shadow: 0 18px 44px rgba(104,65,32,.17);
}
.hero-strip:before, .hero-strip:after { content: ""; position: absolute; transform: rotate(30deg); border: 1px solid rgba(255,255,255,.13); }
.hero-strip:before { width: 270px; height: 235px; right: -35px; top: -90px; border-width: 30px; }
.hero-strip:after { width: 155px; height: 135px; right: 50px; bottom: -90px; border-width: 24px; }
.hero-strip > * { position: relative; z-index: 1; }
.hero-strip h2 { font-family: Manrope, sans-serif; font-size: 30px; letter-spacing: -1px; margin: 7px 0; }
.hero-strip p:last-child { margin: 0; color: #f4e5d2; max-width: 650px; font-size: 13px; }
.light-button { background: white; color: var(--bronze-dark); padding: 11px 15px; border-radius: 10px; font-size: 11px; font-weight: 800; box-shadow: 0 8px 22px rgba(73,42,20,.11); }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; margin: 18px 0; }
.stat-card, .panel { background: rgba(255,255,255,.87); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.stat-card { min-height: 112px; padding: 18px; display: flex; align-items: center; gap: 14px; }
.stat-card div { min-width: 0; }
.stat-card small, .stat-card strong, .stat-card em { display: block; }
.stat-card small { color: var(--muted); font-size: 10px; font-weight: 700; }
.stat-card strong { font-family: Manrope, sans-serif; font-size: 26px; line-height: 1; margin: 4px 0; color: var(--espresso); }
.stat-card em { color: #a1988f; font-size: 9px; font-style: normal; white-space: nowrap; }
.stat-icon { width: 42px; height: 42px; flex: 0 0 auto; border-radius: 13px; display: grid; place-items: center; font-weight: 900; }
.stat-icon.green { background: var(--bronze-soft); color: var(--bronze-dark); }
.stat-icon.blue { background: #ece4d8; color: #765c45; }
.stat-icon.mint { background: var(--sage-soft); color: var(--sage); }
.stat-icon.amber { background: #f2e7d1; color: var(--warning); }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .75fr); gap: 18px; }
.panel { padding: 22px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 18px; }
.panel-head h3, .form-panel h3 { margin: 4px 0 0; font-family: Manrope, sans-serif; font-size: 18px; color: var(--espresso); letter-spacing: -.4px; }
.panel-head a { font-size: 11px; color: var(--bronze-dark); font-weight: 800; }
.branch-list, .activity-list { display: grid; }
.branch-row, .activity-row { display: flex; align-items: center; gap: 12px; padding: 13px 0; border-top: 1px solid #efe8df; }
.branch-row:first-child, .activity-row:first-child { border-top: 0; }
.branch-row { transition: transform .16s ease; }
.branch-row:hover { transform: translateX(3px); }
.branch-code, .activity-avatar { width: 38px; height: 38px; border-radius: 11px; background: var(--bronze-soft); color: var(--bronze-dark); display: grid; place-items: center; font-weight: 850; font-size: 11px; flex: 0 0 auto; }
.activity-avatar { background: var(--sage-soft); color: var(--sage); }
.branch-copy, .activity-row > span:nth-child(2) { min-width: 0; flex: 1; }
.branch-copy strong, .branch-copy small, .activity-row strong, .activity-row small { display: block; }
.branch-copy strong, .activity-row strong { font-size: 12px; color: var(--espresso); }
.branch-copy small, .activity-row small { color: var(--muted); font-size: 10px; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.branch-metric { text-align: right; }
.branch-metric strong, .branch-metric small { display: block; }
.branch-metric strong { font-family: Manrope, sans-serif; font-size: 15px; }
.branch-metric small { font-size: 9px; color: var(--muted); }
.status-pill { font-size: 9px; font-weight: 800; padding: 5px 8px; border-radius: 999px; white-space: nowrap; }
.status-pill.online { color: #456e51; background: #e3eee5; }
.status-pill.offline { color: #81766b; background: #eee9e3; }
.pending-panel { margin-top: 18px; }
.pending-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.pending-grid > div { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; background: #fbf6ed; border: 1px solid #eee0cd; padding: 13px; border-radius: 11px; }
.pending-grid small { grid-column: 2; color: var(--muted); margin-top: 3px; }

.split-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; align-items: start; }
.form-panel { position: sticky; top: 20px; }
.form-panel > .muted { margin-bottom: 22px; }
.muted { color: var(--muted); line-height: 1.55; }
.stack-form { display: grid; gap: 15px; }
.stack-form label, .login-form label, .filter-form label, .edit-row label, .device-card label { font-size: 10px; color: #6d6259; font-weight: 750; }
.stack-form input, .stack-form select, .login-form input, .filter-form input, .filter-form select, .edit-row input, .device-card input, .device-card select {
  display: block; width: 100%; margin-top: 6px; border: 1px solid #ddd2c6; background: #fff;
  border-radius: 10px; padding: 11px 12px; outline: none; color: var(--ink); transition: border .16s, box-shadow .16s;
}
input:focus, select:focus { border-color: var(--bronze); box-shadow: 0 0 0 3px rgba(157,102,46,.11); }
input::placeholder { color: #b4aca4; }
.primary-button, .secondary-button, .export-button { border: 0; border-radius: 10px; padding: 11px 14px; font-weight: 800; font-size: 11px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 10px; transition: transform .16s ease, background .16s ease, box-shadow .16s ease; }
.primary-button { background: var(--bronze); color: white; box-shadow: 0 8px 18px rgba(126,79,37,.15); }
.primary-button:hover { background: var(--bronze-dark); transform: translateY(-1px); }
.secondary-button { background: #f1ebe3; color: var(--bronze-dark); }
.wide { width: 100%; }
.count-badge { font-size: 10px; font-weight: 800; padding: 6px 9px; background: #f1ebe3; color: var(--bronze-dark); border-radius: 999px; }
.edit-list { display: grid; }
.edit-row { display: grid; grid-template-columns: 42px minmax(150px, 1fr) minmax(120px, .7fr) 70px 82px auto; align-items: end; gap: 12px; padding: 15px 0; border-top: 1px solid #efe8df; }
.edit-row:first-child { border-top: 0; }
.edit-row small, .device-card small { display: block; color: var(--muted); font-weight: 600; }
.check-label { display: flex !important; align-items: center; gap: 7px; padding-bottom: 10px; }
.check-label input { width: auto !important; margin: 0 !important; accent-color: var(--bronze); }
.device-count { font-size: 10px; color: var(--muted); padding-bottom: 12px; }
.device-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.device-card { border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: grid; gap: 12px; background: #fffdf9; }
.device-card-head, .device-card-foot { display: flex; align-items: center; justify-content: space-between; }
.device-visual { width: 42px; height: 42px; background: var(--bronze); color: white; border-radius: 12px; display: grid; place-items: center; font-size: 19px; }
.device-details { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 12px 0; display: grid; gap: 10px; }
.device-details small, .device-details strong { display: block; }
.device-details strong { font-size: 10px; margin-top: 3px; word-break: break-all; }
.device-card-foot .check-label { padding: 0; }
.filter-panel { margin-bottom: 18px; }
.filter-form { display: grid; grid-template-columns: 1.1fr 1.1fr .8fr .8fr .8fr auto auto; gap: 10px; align-items: end; }
.table-panel { padding: 0; overflow: hidden; }
.table-panel .panel-head { padding: 22px 22px 0; }
.export-button { background: var(--bronze-soft); color: var(--bronze-dark); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; background: #f7f3ed; padding: 11px 18px; font-size: 9px; text-transform: uppercase; letter-spacing: .8px; color: #8b8178; }
td { padding: 14px 18px; border-top: 1px solid #efe8df; font-size: 11px; }
td strong, td small { display: block; }
td small { font-size: 9px; color: var(--muted); margin-top: 4px; }
.employee-chip { background: var(--bronze-soft); color: var(--bronze-dark); border-radius: 7px; padding: 5px 8px; font-weight: 800; }
.pagination { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); }
.pagination a { font-weight: 800; color: var(--bronze-dark); margin-left: 14px; }
.empty-state { text-align: center; color: var(--muted); padding: 30px; }
.alert { padding: 12px 15px; border-radius: 10px; margin-bottom: 15px; font-size: 12px; font-weight: 650; }
.alert.success { background: #e2eee4; color: #3f6d4b; }
.alert.error { background: #f6e4e0; color: var(--danger); }
.security-card { background: #f5eee5; border-left: 3px solid var(--bronze); padding: 16px; border-radius: 10px; }
.security-card .muted { margin: 6px 0 0; font-size: 11px; }
.user-admin-list { padding: 4px 22px 22px; }
.user-admin-row { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(145px, .7fr) minmax(250px, 1fr) auto; gap: 14px; align-items: center; padding: 16px 0; border-top: 1px solid var(--line); }
.user-admin-row:first-child { border-top: 0; }
.user-admin-identity { display: flex; align-items: center; gap: 11px; min-width: 0; }
.user-admin-identity strong, .user-admin-identity small, .user-admin-meta small { display: block; }
.user-admin-identity small, .user-admin-meta small { color: var(--muted); font-size: 9px; margin-top: 4px; }
.role-pill { display: inline-flex; padding: 5px 8px; border-radius: 999px; background: #eee9e3; color: #665b52; font-size: 9px; font-weight: 800; }
.role-pill.super_admin { background: var(--bronze-soft); color: var(--bronze-dark); }
.user-actions summary { color: var(--bronze-dark); cursor: pointer; font-size: 10px; font-weight: 800; }
.inline-reset-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 7px; margin-top: 8px; }
.inline-reset-form input { min-width: 0; border: 1px solid #ddd2c6; border-radius: 8px; padding: 9px; font-size: 10px; }
.danger-button { border: 0; border-radius: 9px; padding: 9px 11px; background: #f6e4e0; color: var(--danger); font-size: 10px; font-weight: 800; cursor: pointer; }

.login-body { min-height: 100vh; display: grid; grid-template-columns: minmax(520px, 1.08fr) minmax(420px, .92fr); background: var(--paper); }
.login-brand-panel { position: relative; min-height: 100vh; padding: 46px 60px 36px; display: flex; flex-direction: column; overflow: hidden; color: white; background: linear-gradient(145deg, #58361f 0%, #8c582b 56%, #a96f37 100%); }
.login-brand { position: relative; z-index: 2; }
.login-logo { width: 170px; height: 170px; object-fit: contain; border-radius: 27px; background: white; box-shadow: 0 16px 40px rgba(49,27,13,.17); }
.login-message { position: relative; z-index: 2; margin: auto 0 32px; max-width: 650px; }
.login-message h1 { font-family: Manrope, sans-serif; font-size: clamp(45px, 5vw, 71px); line-height: 1; letter-spacing: -3.2px; margin: 14px 0 23px; }
.login-message > p:last-child { max-width: 560px; color: #f2dfc9; font-size: 15px; line-height: 1.7; }
.brand-proof { position: relative; z-index: 2; display: flex; gap: 22px; color: #ebd1b1; text-transform: uppercase; letter-spacing: 1px; font-size: 8px; font-weight: 800; }
.brand-proof span { display: flex; align-items: center; gap: 8px; }
.brand-proof span:before { content: ""; width: 4px; height: 4px; background: #ecd0ae; border-radius: 50%; }
.hex-art { position: absolute; right: -120px; bottom: -155px; width: 610px; height: 530px; transform: rotate(30deg); }
.hex-art i { position: absolute; inset: 0; border: 1px solid rgba(255,255,255,.11); }
.hex-art i:nth-child(2) { inset: 70px; }
.hex-art i:nth-child(3) { inset: 140px; background: rgba(255,255,255,.025); }
.login-panel { display: grid; place-items: center; padding: 45px; position: relative; }
.login-panel:after { content: "Stay Healthy"; position: absolute; bottom: 28px; color: #b2a79d; font-size: 10px; letter-spacing: 1px; }
.login-form { width: min(405px, 100%); }
.login-kicker { display: inline-flex; padding: 6px 9px; margin-bottom: 25px; border-radius: 6px; background: var(--bronze-soft); color: var(--bronze-dark); font-size: 8px; font-weight: 800; letter-spacing: 1.2px; }
.login-form h2 { font-family: Manrope, sans-serif; color: var(--espresso); font-size: 36px; letter-spacing: -1.5px; margin: 8px 0; }
.login-form > .muted { margin: 0 0 30px; font-size: 12px; }
.login-form label { display: block; margin: 17px 0; }
.login-form input { padding: 14px; font-size: 12px; }
.login-form .primary-button { margin-top: 10px; padding: 14px; }
.security-note { text-align: center; color: #9e958d; font-size: 9px; margin-top: 22px; }
.lock-dot { color: var(--sage); margin-right: 5px; }

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid, .split-layout { grid-template-columns: 1fr; }
  .form-panel { position: static; }
  .filter-form { grid-template-columns: repeat(3, 1fr); }
  .edit-row { grid-template-columns: 42px 1fr 1fr; }
  .user-admin-row { grid-template-columns: 1fr 1fr; }
  .login-body { grid-template-columns: 1fr; }
  .login-brand-panel { min-height: 465px; }
  .login-message { margin: 70px 0 25px; }
  .login-message h1 { font-size: 50px; }
  .login-panel { min-height: 560px; padding: 65px 30px; }
}

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -275px; z-index: 10; width: 258px; transition: left .2s; box-shadow: 18px 0 45px rgba(54,38,28,.16); }
  .user-admin-row, .inline-reset-form { grid-template-columns: 1fr; }
  .nav-open .sidebar { left: 0; }
  .app-shell main { padding: 0 16px 35px; }
  .topbar { min-height: 91px; }
  .menu-button { display: block; border: 1px solid var(--line); background: white; border-radius: 9px; padding: 9px; margin-right: 10px; }
  .topbar > div:nth-child(2) { margin-right: auto; }
  .topbar h1 { font-size: 22px; }
  .topbar-meta small { display: none; }
  .hero-strip { align-items: flex-start; gap: 22px; flex-direction: column; padding: 26px; }
  .hero-strip h2 { font-size: 25px; }
  .stats-grid, .content-grid { grid-template-columns: 1fr 1fr; }
  .edit-row { grid-template-columns: 1fr; }
  .edit-row > .branch-code { display: none; }
  .filter-form { grid-template-columns: 1fr 1fr; }
  .login-brand-panel { min-height: 410px; padding: 30px; }
  .login-logo { width: 130px; height: 130px; }
  .login-message { margin: 48px 0 20px; }
  .login-message h1 { font-size: 40px; letter-spacing: -2px; }
  .login-message > p:last-child { font-size: 13px; }
  .login-panel { min-height: 560px; padding: 55px 24px; }
}

@media (max-width: 500px) {
  .stats-grid, .content-grid, .filter-form { grid-template-columns: 1fr; }
  .topbar-meta { font-size: 0; padding: 9px; }
  .login-brand-panel { min-height: 390px; }
  .login-message h1 { font-size: 35px; }
  .brand-proof { gap: 12px; flex-wrap: wrap; }
}
