html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

:root {
  --ink: #132238;
  --muted: #64748b;
  --canvas: #f4f6f8;
  --surface: #ffffff;
  --nav: #102336;
  --nav-soft: #1c3448;
  --teal: #0f8a7b;
  --teal-dark: #0a6d62;
  --line: #dfe5ea;
  --danger: #c2413b;
  --warning: #d28a17;
  --radius: 14px;
}

* { box-sizing: border-box; }
html { font-size: 15px; }
body { color: var(--ink); background: var(--canvas); margin: 0; font-family: Inter, "Segoe UI", Arial, sans-serif; }
a { color: var(--teal-dark); text-decoration: none; }
a:hover { color: var(--teal); }
.app-body { min-height: 100vh; margin-bottom: 0; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--nav); color: #d7e1e8; display: flex; flex-direction: column; padding: 24px 16px 18px; z-index: 20; }
.brand { color: white; display: flex; align-items: center; gap: 12px; padding: 0 10px 27px; }
.brand:hover { color: white; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; background: var(--teal); border-radius: 10px 4px 10px 4px; font-size: 21px; font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 20px; letter-spacing: .2px; }
.brand small { color: #8fa6b5; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; margin-top: 1px; }
.side-nav { display: flex; flex-direction: column; gap: 5px; }
.side-nav a { color: #bed0dc; min-height: 44px; display: flex; align-items: center; gap: 11px; padding: 8px 12px; border-radius: 9px; font-weight: 600; }
.side-nav a span { width: 27px; height: 27px; display: grid; place-items: center; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08); border-radius: 7px; font-size: 11px; }
.side-nav a:hover, .side-nav a.active { color: white; background: var(--nav-soft); }
.side-nav a.active { box-shadow: inset 3px 0 0 var(--teal); }
.side-nav a.active span { background: var(--teal); border-color: var(--teal); }
.nav-divider { color: #6f899a; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .13em; margin: 22px 12px 7px; }
.sidebar-footer { margin-top: auto; border-top: 1px solid rgba(255,255,255,.08); padding: 16px 10px 0; display: grid; gap: 5px; }
.sidebar-footer small { color: #6f899a; }
.server-status { font-size: 12px; font-weight: 700; }
.server-status i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #4ade80; margin-right: 5px; box-shadow: 0 0 0 3px rgba(74,222,128,.12); }
.app-content { min-width: 0; }
.topbar { height: 68px; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; padding: 0 30px; position: sticky; top: 0; z-index: 15; }
.topbar-title { font-weight: 800; font-size: 16px; }
.menu-toggle { display: none; border: 0; background: transparent; font-size: 22px; margin-right: 10px; }
.user-menu { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.site-selector { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.site-selector label { color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.site-selector select { max-width: 220px; border: 1px solid #ced7de; border-radius: 7px; padding: 7px 28px 7px 10px; background: white; color: var(--ink); font-size: 12px; font-weight: 700; }
.site-selector + .user-menu, .current-site + .user-menu { margin-left: 14px; }
.current-site { margin-left: auto; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-radius: 20px; padding: 6px 10px; background: #e8f5f1; color: var(--teal-dark); font-size: 11px; font-weight: 800; }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; background: #e1f3f0; color: var(--teal-dark); display: grid; place-items: center; font-weight: 800; }
.user-meta { display: grid; line-height: 1.2; }
.user-meta strong { font-size: 12px; max-width: 210px; overflow: hidden; text-overflow: ellipsis; }
.user-meta small { color: var(--muted); font-size: 11px; }
.logout-button { border: 0; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; padding: 7px; }
.logout-button:hover { color: var(--danger); }
.main-content { padding: 31px clamp(20px, 3vw, 44px) 50px; max-width: 1600px; margin: 0 auto; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 25px; }
.page-heading h1 { font-size: clamp(25px, 3vw, 34px); letter-spacing: -.03em; margin: 3px 0 7px; font-weight: 800; }
.page-heading p { color: var(--muted); margin: 0; }
.eyebrow { color: var(--teal-dark); font-size: 10px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.btn { border-radius: 8px; font-weight: 700; padding: .63rem 1rem; }
.btn-primary { background: var(--teal); border-color: var(--teal); }
.btn-primary:hover, .btn-primary:focus { background: var(--teal-dark); border-color: var(--teal-dark); }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; }
.metric-card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: grid; min-height: 132px; color: var(--ink); transition: transform .15s ease, box-shadow .15s ease; }
.metric-card:hover { color: var(--ink); transform: translateY(-2px); box-shadow: 0 9px 22px rgba(24,39,58,.08); }
.metric-card--accent::before { content: ""; position: absolute; left: -1px; top: 18px; bottom: 18px; width: 4px; border-radius: 0 4px 4px 0; background: var(--teal); }
.metric-label { color: var(--muted); font-size: 12px; font-weight: 700; }
.metric-card strong { font-size: 35px; line-height: 1; letter-spacing: -.04em; align-self: center; }
.metric-note { color: #91a0ae; font-size: 11px; }
.status-strip { display: flex; flex-wrap: wrap; gap: 25px; align-items: center; margin: 17px 3px 25px; color: var(--muted); font-size: 12px; }
.status-strip strong { color: var(--ink); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.status-dot--warning { background: var(--warning); }
.status-dot--danger { background: var(--danger); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel-heading { padding: 20px 22px; display: flex; justify-content: space-between; align-items: center; gap: 20px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { font-size: 17px; margin: 4px 0 0; font-weight: 800; }
.panel-heading > a { font-size: 12px; font-weight: 800; }
.empty-state { text-align: center; padding: 52px 20px 58px; }
.empty-icon { width: 48px; height: 48px; display: grid; place-items: center; margin: 0 auto 13px; background: #e3f3f1; color: var(--teal-dark); border-radius: 13px 5px 13px 5px; font-size: 24px; font-weight: 900; }
.empty-state h3 { font-size: 17px; margin: 0 0 7px; }
.empty-state p { color: var(--muted); margin: 0 auto 19px; max-width: 450px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; padding: 11px 16px; background: #f8fafb; color: #738292; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; border-bottom: 1px solid var(--line); }
.data-table td { padding: 13px 16px; border-bottom: 1px solid #edf0f2; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table td strong, .data-table td small { display: block; }
.data-table td small { color: var(--muted); margin-top: 2px; }
.badge-status { display: inline-flex; align-items: center; padding: 5px 8px; border-radius: 20px; font-size: 10px; font-weight: 800; background: #e8f5f1; color: #16705f; white-space: nowrap; }
.badge-status--repair { background: #fff3dc; color: #8a5c13; }
.badge-status--retired { background: #edf0f2; color: #64748b; }
.badge-status--reserve { background: #e9f0fb; color: #355d95; }
.auth-body { min-height: 100vh; margin: 0; background: var(--nav); }
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-wrap { width: min(960px, 100%); display: grid; grid-template-columns: 1.05fr .95fr; border-radius: 20px; overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,.28); }
.login-branding { color: white; padding: 60px 55px; background: linear-gradient(145deg, #16364d, #0d2639); position: relative; }
.login-branding::after { content: ""; position: absolute; width: 180px; height: 180px; right: -65px; bottom: -75px; border: 34px solid rgba(15,138,123,.22); border-radius: 50%; }
.login-logo { width: 50px; height: 50px; display: grid; place-items: center; background: var(--teal); border-radius: 14px 5px 14px 5px; font-size: 27px; font-weight: 900; margin-bottom: 56px; }
.login-branding .eyebrow { color: #73c7bb; }
.login-branding h1 { font-size: 44px; letter-spacing: -.04em; margin: 5px 0 12px; font-weight: 850; }
.login-branding p { color: #b6c8d4; line-height: 1.6; max-width: 390px; }
.login-branding ul { list-style: none; padding: 20px 0 0; margin: 0; display: grid; gap: 11px; color: #d5e0e7; font-size: 13px; }
.login-branding li::before { content: "✓"; color: #5ed0bd; font-weight: 900; margin-right: 9px; }
.login-card { background: white; padding: 62px 50px; }
.login-card h2, .login-card h1 { font-size: 27px; margin: 5px 0 7px; font-weight: 800; letter-spacing: -.02em; }
.login-card > p { color: var(--muted); margin-bottom: 28px; }
.form-field { display: grid; gap: 7px; margin-bottom: 16px; }
.form-field label { font-size: 12px; font-weight: 800; }
.form-field input, .form-field select, .form-field textarea { width: 100%; border: 1px solid #cfd8df; border-radius: 8px; padding: 11px 12px; color: var(--ink); outline: none; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(15,138,123,.12); }
.form-field span { color: var(--danger); font-size: 11px; }
.check-field { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 12px; margin: 3px 0 19px; }
.login-submit { width: 100%; }
.validation-summary { color: var(--danger); font-size: 12px; margin-bottom: 10px; }
.dev-hint { margin-top: 18px; background: #eef8f6; color: #276c63; border-radius: 8px; padding: 10px 12px; display: grid; font-size: 11px; }
.dev-hint span { font-family: Consolas, monospace; margin-top: 2px; }
.login-help { display: block; text-align: center; color: #8a98a5; margin-top: 20px; }
.single-card { width: min(500px, 100%); border-radius: 18px; }
.heading-actions { display: flex; gap: 9px; flex-wrap: wrap; }
.btn-light { background: white; border-color: var(--line); color: var(--ink); }
.btn-dark { background: var(--ink); border-color: var(--ink); }
.filter-bar { display: grid; grid-template-columns: minmax(240px, 2fr) repeat(3, minmax(130px, 1fr)) auto auto; align-items: end; gap: 12px; background: white; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 18px; }
.filter-bar.simple { grid-template-columns: minmax(260px, 1fr) auto auto; }
.filter-bar > div { display: grid; gap: 6px; }
.filter-bar label { color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.filter-bar input, .filter-bar select, .inline-form input, .inline-form select { min-width: 0; border: 1px solid #ced7de; border-radius: 7px; padding: 9px 10px; background: white; }
.clear-filter { align-self: center; font-size: 12px; font-weight: 700; padding: 10px 3px; }
.panel-heading.compact { min-height: 58px; padding-top: 14px; padding-bottom: 14px; }
.panel-heading.compact h2 { margin: 0; }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions a, .row-actions button { display: inline; border: 0; background: transparent; color: var(--teal-dark); font-size: 11px; font-weight: 800; padding: 4px 5px; }
.row-actions form { display: inline; }
.row-actions button { color: var(--danger); }
.alert-success, .alert-error, .alert-info { border-radius: 9px; padding: 12px 15px; margin-bottom: 16px; font-size: 13px; font-weight: 700; }
.alert-success { color: #176456; background: #e6f6f1; border: 1px solid #b9e4d8; }
.alert-error { color: #963832; background: #fff0ef; border: 1px solid #efc8c5; }
.alert-info { color: #355d95; background: #edf4ff; border: 1px solid #cdddf3; }
.form-layout { display: grid; gap: 16px; max-width: 1050px; }
.form-layout.narrow { max-width: 760px; }
.form-card { background: white; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.form-card-heading { margin-bottom: 21px; }
.form-card-heading h2 { font-size: 18px; margin: 0 0 4px; }
.form-card-heading p { color: var(--muted); font-size: 12px; margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px 16px; }
.form-grid .wide { grid-column: span 2; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 4px 0; }
.details-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.detail-list { margin: 0; display: grid; grid-template-columns: 180px minmax(0, 1fr); }
.detail-list dt, .detail-list dd { margin: 0; padding: 11px 20px; border-bottom: 1px solid #edf0f2; }
.detail-list dt { color: var(--muted); font-size: 11px; }
.detail-list dd { font-size: 13px; font-weight: 600; }
.compact-empty { padding: 28px 20px; }
.compact-empty p { margin-bottom: 0; }
.count-pill { display: inline-grid; place-items: center; min-width: 28px; height: 24px; border-radius: 20px; background: #e8f3f2; color: var(--teal-dark); font-weight: 800; }
.room-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.room-card { display: grid; grid-template-columns: auto 1fr; background: white; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; position: relative; }
.room-number { min-width: 75px; display: grid; place-items: center; background: #e6f2f1; color: var(--teal-dark); font-size: 23px; font-weight: 900; }
.room-card-body { padding: 20px; }
.room-card h2 { font-size: 17px; margin: 4px 0; }
.room-card p { color: var(--muted); font-size: 12px; margin: 0; }
.room-stats { display: flex; gap: 16px; margin-top: 17px; color: var(--muted); font-size: 11px; }
.room-stats strong { color: var(--ink); }
.room-actions { grid-column: 1 / -1; display: flex; align-items: center; justify-content: flex-end; gap: 6px; padding: 8px 12px; border-top: 1px solid var(--line); }
.room-actions form { display: flex; margin: 0; }
.room-actions a, .room-actions button { display: inline-flex; align-items: center; min-height: 28px; border: 0; background: transparent; color: var(--teal-dark); font-size: 11px; font-weight: 800; line-height: 1; padding: 6px 8px; }
.room-actions button { color: var(--danger); }
.metric-grid--three { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 18px; }
.create-drawer { background: white; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 18px; overflow: hidden; }
.create-drawer summary { padding: 17px 20px; color: var(--teal-dark); cursor: pointer; font-weight: 800; }
.drawer-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.mini-form { padding: 20px; border-right: 1px solid var(--line); }
.mini-form:last-child { border-right: 0; }
.mini-form h3 { font-size: 16px; margin: 0 0 17px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.software-section { margin-top: 18px; }
.product-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; }
.product-card { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 18px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.product-card:nth-child(odd) { border-right: 1px solid var(--line); }
.product-card strong, .product-card span { display: block; }
.product-card span { color: var(--muted); font-size: 11px; margin-top: 2px; }
.product-card form button { border: 0; background: transparent; color: var(--danger); font-size: 11px; font-weight: 700; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; align-items: start; gap: 18px; }
.inline-form { display: flex; align-items: center; gap: 6px; }
.inline-form input { max-width: 180px; }
.access-form { display: grid; grid-template-columns: minmax(125px, 1fr) minmax(150px, 1fr) auto; gap: 6px; align-items: center; }
.access-form select { min-width: 0; border: 1px solid #ced7de; border-radius: 7px; padding: 8px; background: white; }
.small-button { border: 0; border-radius: 6px; background: #e5f1ef; color: var(--teal-dark); padding: 8px; font-size: 10px; font-weight: 800; }
.create-user { position: sticky; top: 87px; }
.role-help { border-top: 1px solid var(--line); margin-top: 20px; padding-top: 16px; display: grid; }
.role-help strong { font-size: 11px; }
.role-help span { color: var(--muted); font-size: 10px; margin-bottom: 8px; }
.text-danger { color: var(--danger) !important; font-weight: 700; }
.app-version { margin-top: 7px; color: #8093a1; font-family: Consolas, monospace; }
.auth-version { position: fixed; right: 18px; bottom: 13px; color: rgba(255,255,255,.55); font-family: Consolas, monospace; font-size: 10px; }
.cartridge-metrics { margin-bottom: 18px; }
.cartridge-validation { padding: 0 20px; }
.form-help, .muted-text { color: var(--muted); font-size: 11px; }
.form-help { margin: -3px 0 16px; line-height: 1.5; }
.cartridge-filter { grid-template-columns: minmax(260px, 1fr) auto auto auto; }
.filter-check { display: flex !important; align-items: center; gap: 8px; align-self: center; color: var(--ink) !important; font-size: 12px !important; text-transform: none !important; letter-spacing: 0 !important; white-space: nowrap; }
.filter-check input { width: 16px; height: 16px; }
.compatibility-list { display: grid; gap: 5px; }
.compatibility-list > span { display: flex; align-items: center; gap: 5px; }
.compatibility-list form { display: inline; }
.compatibility-list button { border: 0; background: transparent; color: var(--danger); font-size: 16px; line-height: 1; padding: 1px 4px; }
.stock-badge, .movement-badge { display: inline-flex; align-items: center; border-radius: 20px; padding: 5px 9px; font-size: 10px; font-weight: 800; white-space: nowrap; }
.stock-badge--ok { color: #16705f; background: #e8f5f1; }
.stock-badge--low { color: #8a5c13; background: #fff3dc; }
.stock-badge--empty { color: #963832; background: #fff0ef; }
.movement-badge--in { color: #16705f; background: #e8f5f1; }
.movement-badge--out { color: #8a5c13; background: #fff3dc; }
.movement-quantity { font-weight: 900; }
.movement-quantity--in { color: var(--teal-dark); }
.movement-quantity--out { color: var(--danger); }
.cartridge-history { margin-top: 18px; }
.cartridge-aliases .panel-heading p { color: var(--muted); font-size: 12px; margin: 6px 0 0; }
.alias-empty { display: grid; gap: 4px; padding: 18px 22px; background: #fbfcfd; }
.alias-empty strong { font-size: 13px; }
.alias-empty span { color: var(--muted); font-size: 12px; }
.alias-editor { padding: 20px 22px 22px; border-top: 1px solid var(--line); background: #fbfcfd; }
.alias-editor-heading { margin-bottom: 15px; }
.alias-editor-heading h3 { font-size: 15px; margin: 0; }
.alias-editor-heading p { color: var(--muted); font-size: 12px; margin: 5px 0 0; }
.alias-form { display: grid; gap: 2px; }
.alias-form-grid { display: grid; grid-template-columns: minmax(250px, 2fr) repeat(2, minmax(150px, 1fr)); gap: 4px 16px; }
.alias-form-grid .form-field { margin-bottom: 12px; }
.alias-notes-field { grid-column: 1 / -1; }
.alias-form-actions { display: flex; justify-content: flex-end; gap: 10px; }

@media (max-width: 1000px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -260px; transition: left .2s ease; width: 248px; box-shadow: 10px 0 30px rgba(0,0,0,.2); }
  .sidebar--open { left: 0; }
  .menu-toggle { display: block; }
  .filter-bar, .cartridge-filter { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .room-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .drawer-grid, .admin-grid { grid-template-columns: 1fr; }
  .alias-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .alias-name-field, .alias-notes-field { grid-column: 1 / -1; }
  .mini-form { border-right: 0; border-bottom: 1px solid var(--line); }
  .create-user { position: static; }
}
@media (max-width: 620px) {
  .topbar { padding: 0 16px; }
  .topbar-title { display: none; }
  .site-selector label { display: none; }
  .site-selector select { max-width: 150px; }
  .current-site { max-width: 135px; }
  .user-meta { display: none; }
  .main-content { padding: 22px 14px 40px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .metric-grid { grid-template-columns: 1fr; }
  .status-strip { align-items: flex-start; flex-direction: column; gap: 8px; }
  .panel-heading { align-items: flex-start; }
  .filter-bar, .filter-bar.simple, .form-grid, .details-grid, .room-grid, .metric-grid--three, .product-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .alias-form-grid { grid-template-columns: 1fr; }
  .alias-name-field, .alias-notes-field { grid-column: auto; }
  .alias-form-actions .btn { width: 100%; }
  .detail-list { grid-template-columns: 1fr; }
  .detail-list dt { padding-bottom: 2px; border-bottom: 0; }
  .detail-list dd { padding-top: 2px; }
  .product-card:nth-child(odd) { border-right: 0; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-branding { display: none; }
  .login-card { padding: 40px 28px; }
}
