:root {
  --page: #f5f6fa;
  --surface: #ffffff;
  --ink: #171524;
  --muted: #6e6a80;
  --line: #e7e5ef;
  --navy: #211d46;
  --violet: #7458da;
  --violet-soft: #f4f0ff;
  --green: #0ba87d;
  --amber: #c27803;
  --red: #d6486d;
  --shadow: 0 18px 42px rgba(36, 31, 68, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--page);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 14px;
}

body.auth-locked .topbar,
body.auth-locked .page-shell {
  display: none;
}

body:not(.auth-locked) .login-screen {
  display: none;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(245, 246, 250, 0.94), rgba(245, 246, 250, 0.98)),
    var(--navy);
}

.login-card {
  width: min(430px, 100%);
  padding: 28px;
  display: grid;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0;
  font-size: 26px;
}

.login-card .primary-button {
  width: 100%;
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-weight: 800;
}

.login-help {
  display: grid;
  gap: 5px;
  padding: 12px;
  border-radius: 8px;
  background: #faf9ff;
  color: #5f5a73;
  font-size: 13px;
}

.user-pill {
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

body.role-ground #adminDashboardViewBtn,
body.role-ground #searchViewBtn,
body.role-ground #verificationViewBtn,
body.role-ground #exportCsvBtn,
body.role-ground #exportVerificationBtn,
body.role-ground [data-storage-delete],
body.role-ground [data-delete] {
  display: none !important;
}

body.role-verify #adminDashboardViewBtn,
body.role-verify #manageViewBtn,
body.role-verify #searchViewBtn,
body.role-verify #newAssetBtn,
body.role-verify #exportCsvBtn,
body.role-verify #addBranchBtn,
body.role-verify .asset-form,
body.role-verify [data-storage-edit],
body.role-verify [data-edit],
body.role-verify [data-storage-delete],
body.role-verify [data-delete] {
  display: none !important;
}

body.role-manager #manageViewBtn,
body.role-manager #verificationViewBtn,
body.role-manager #newAssetBtn,
body.role-manager #addBranchBtn,
body.role-manager .asset-form,
body.role-manager [data-storage-edit],
body.role-manager [data-edit],
body.role-manager [data-storage-delete],
body.role-manager [data-delete] {
  display: none !important;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

.topbar {
  min-height: 78px;
  padding: 14px 34px;
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow,
.welcome {
  margin: 0 0 4px;
  color: #bbb6da;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar h1,
.hero-copy h2,
.panel-heading h2,
.asset-form h3,
.dialog-card h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 24px;
  font-weight: 600;
}

.topbar-actions,
.toolbar,
.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.primary-button,
.ghost-button,
.icon-text-button,
.row-action {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 700;
}

.primary-button {
  background: var(--violet);
  color: #fff;
  box-shadow: 0 10px 22px rgba(116, 88, 218, 0.22);
}

.ghost-button {
  background: #fff;
  color: var(--violet);
  border-color: #d8d2f4;
}

.icon-text-button {
  background: var(--violet-soft);
  color: var(--violet);
  border-color: #dfd8fb;
}

.page-shell {
  padding: 34px;
}

.hero-panel,
.side-panel,
.main-panel,
.asset-form,
.table-card,
.dialog-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.hero-panel {
  padding: 28px;
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) 1.2fr;
  gap: 24px;
  align-items: center;
  position: relative;
  overflow: hidden;
}

.hero-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 150px;
  background: linear-gradient(180deg, #fbf9ff, rgba(255, 255, 255, 0));
  pointer-events: none;
}

.hero-copy,
.summary-grid {
  position: relative;
}

.welcome {
  color: var(--violet);
}

.hero-copy h2 {
  max-width: 620px;
  font-size: 24px;
  line-height: 1.25;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric-card {
  min-height: 112px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.metric-card strong {
  display: block;
  margin-top: 12px;
  font-size: 30px;
  line-height: 1;
}

.workspace-grid {
  margin-top: 24px;
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.view-tabs {
  margin-top: 22px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.view-tabs button {
  min-height: 40px;
  border: 1px solid #ddd8f2;
  border-radius: 8px;
  background: #fff;
  color: #5d5870;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 800;
}

.view-tabs button.active {
  background: var(--violet);
  color: #fff;
  border-color: var(--violet);
}

.screen {
  display: none;
}

.screen.active.workspace-grid {
  display: grid;
}

.screen.active.search-screen {
  display: block;
}

.screen.active.admin-dashboard {
  display: grid;
}

.admin-dashboard {
  margin-top: 24px;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 0;
  min-height: 720px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: #fff;
}

.admin-sidebar {
  padding: 18px 14px;
  background: #0b2d49;
  color: #dcecff;
  display: grid;
  align-content: start;
  gap: 8px;
}

.admin-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 18px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.admin-logo span {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #39c7d7;
  color: #092840;
  font-weight: 900;
}

.admin-logo strong {
  color: #fff;
  font-size: 16px;
}

.admin-menu {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #dcecff;
  text-align: left;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 750;
}

.admin-menu.active,
.admin-menu:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.admin-content {
  min-width: 0;
  padding: 22px;
  background: #f7f8fb;
}

.admin-topline {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 18px;
}

.admin-topline h2 {
  margin: 0;
  font-size: 24px;
}

.admin-filter-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.admin-filter-row select {
  width: 180px;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr;
  gap: 18px;
}

.admin-card {
  padding: 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(24, 31, 56, 0.06);
}

.highlight-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.highlight-grid div {
  min-height: 86px;
  padding: 14px;
  border: 1px solid #dff5ef;
  border-radius: 10px;
  background: #effdf8;
}

.highlight-grid span,
.health-box span {
  display: block;
  color: #646075;
  font-size: 13px;
  font-weight: 800;
}

.highlight-grid strong,
.health-box strong {
  display: block;
  margin-top: 10px;
  font-size: 28px;
}

.vendor-list {
  display: grid;
  gap: 10px;
}

.vendor-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 8px;
  background: #f6f7fb;
}

.vendor-row strong {
  color: var(--violet);
}

.asset-health-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
}

.health-box {
  min-height: 100px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.health-box.total {
  background: #eef4ff;
  border-color: #cfdefc;
}

.health-box.working {
  background: #eafbf4;
  border-color: #c8f1df;
}

.health-box.damaged {
  background: #fff0f3;
  border-color: #f6cad5;
}

.health-box.warranty {
  background: #effdf8;
  border-color: #d2f5e7;
}

.health-box.expired {
  background: #fff7e8;
  border-color: #f8dfad;
}

.health-box.missing {
  background: #f4f0ff;
  border-color: #ded5ff;
}

.admin-table-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.mini-table,
.mini-wide-table {
  width: 100%;
  min-width: 0;
  table-layout: auto;
}

.mini-table th,
.mini-table td,
.mini-wide-table th,
.mini-wide-table td {
  font-size: 12px;
  padding: 10px;
}

.mini-table-wrap {
  overflow: auto;
}

.empty-note {
  margin: 0;
  color: var(--muted);
}

.search-screen {
  margin-top: 24px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.search-filter-panel {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 14px;
}

.side-panel,
.main-panel {
  padding: 20px;
}

.side-panel {
  position: sticky;
  top: 18px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
}

.panel-heading h2 {
  font-size: 22px;
}

.panel-heading p {
  margin: 5px 0 0;
  color: var(--muted);
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: #4d495c;
  font-size: 13px;
  font-weight: 750;
}

.field.required span::after {
  content: " *";
  color: var(--red);
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid #dcd9e8;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  font-size: 14px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px rgba(116, 88, 218, 0.13);
}

.side-panel .field + .field {
  margin-top: 14px;
}

.branch-list {
  margin-top: 18px;
  display: grid;
  gap: 8px;
  max-height: 520px;
  overflow: auto;
  padding-right: 4px;
}

.branch-item {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #28243a;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  text-align: left;
}

.branch-item.active {
  border-color: var(--violet);
  background: var(--violet-soft);
  color: var(--violet);
}

.branch-count {
  min-width: 26px;
  min-height: 24px;
  border-radius: 999px;
  background: #f0eef7;
  color: #615c74;
  display: inline-grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
}

.main-panel {
  min-width: 0;
}

.toolbar {
  justify-content: flex-end;
}

.search-box {
  width: min(430px, 100%);
  min-height: 38px;
  border: 1px solid #dcd9e8;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  color: var(--muted);
  background: #fff;
}

.search-box input {
  min-height: 34px;
  border: 0;
  box-shadow: none;
  padding: 0;
}

.toolbar select {
  width: 170px;
}

.asset-form {
  margin-top: 18px;
  padding: 20px;
}

.form-title {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.form-title h3 {
  font-size: 20px;
}

.form-title p {
  margin: 4px 0 0;
  color: var(--muted);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.remarks-field {
  grid-column: span 2;
}

.form-actions {
  justify-content: flex-end;
  margin-top: 18px;
}

.table-card {
  margin-top: 18px;
  overflow: hidden;
}


.table-meta {
  min-height: 56px;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.table-meta span {
  color: var(--muted);
}

.table-scroll {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 2600px;
  border-collapse: collapse;
  table-layout: fixed;
}

.verification-table {
  min-width: 2100px;
}

th,
td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
  font-size: 12px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #086ad8;
  color: #ffffff;
  font-weight: 850;
}

td {
  background: #fff;
  color: #242132;
}

.empty-state td {
  height: 150px;
  color: var(--muted);
  text-align: center;
  vertical-align: middle;
  font-size: 16px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-verified {
  background: #defaf1;
  color: var(--green);
}

.status-pending {
  background: #fff6df;
  color: var(--amber);
}

.status-repair {
  background: #fff0f3;
  color: var(--red);
}

.status-disposed {
  background: #eceaf1;
  color: #595569;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.row-action {
  min-height: 30px;
  padding: 0 10px;
  background: #fff;
  color: var(--violet);
  border-color: #d9d3f2;
  font-size: 12px;
}

.row-action.danger {
  color: var(--red);
  border-color: #f2c9d3;
}

.photo-thumb {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--line);
}

.photo-link {
  max-width: 130px;
  min-height: 30px;
  border: 1px solid #d9d3f2;
  border-radius: 7px;
  background: #fff;
  color: var(--violet);
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.barcode-box {
  width: 150px;
  display: grid;
  gap: 4px;
  justify-items: center;
  background: #fff;
}

.barcode-box svg {
  width: 138px;
  height: 44px;
  display: block;
  fill: #111;
}

.barcode-box small {
  color: #5e596f;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10;
  max-width: 360px;
  padding: 14px 16px;
  border-radius: 10px;
  background: #211d46;
  color: #fff;
  box-shadow: 0 18px 42px rgba(36, 31, 68, 0.22);
  font-weight: 700;
  font-size: 14px;
}

.toast.error {
  background: #9e2445;
}

dialog {
  width: min(760px, calc(100% - 28px));
  border: 0;
  padding: 0;
  background: transparent;
}

dialog::backdrop {
  background: rgba(20, 16, 42, 0.42);
}

.dialog-card {
  padding: 22px;
}

.dialog-card .field {
  margin-top: 14px;
}

.photo-dialog-card {
  width: min(760px, calc(100vw - 28px));
  max-height: calc(100vh - 36px);
  overflow: auto;
}

.photo-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.photo-dialog-body {
  display: grid;
  gap: 12px;
}

.photo-preview-large {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 10px;
  border: 1px solid var(--line);
  object-fit: contain;
  background: #f7f7fb;
}

.photo-missing {
  color: var(--red);
  font-weight: 800;
}

.photo-upload-box {
  display: grid;
  gap: 9px;
  padding: 14px;
  border: 1px dashed #bdb6e4;
  border-radius: 10px;
  background: #faf9ff;
}

.photo-upload-box span {
  color: var(--violet);
  font-weight: 850;
}

.verification-table select,
.verification-table input,
.verification-table textarea {
  min-height: 34px;
  padding: 6px 8px;
  font-size: 12px;
}

.verification-table textarea {
  min-width: 180px;
}

.verification-filters {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

@media (max-width: 1300px) {
  .hero-panel,
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .search-filter-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .side-panel {
    position: static;
  }

  .branch-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: none;
  }

  .form-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .topbar,
  .panel-heading,
  .form-title {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    padding: 16px;
  }

  .topbar h1 {
    font-size: 24px;
  }

  .page-shell {
    padding: 16px;
  }

  .hero-panel,
  .side-panel,
  .main-panel,
  .asset-form {
    padding: 16px;
  }

  .hero-copy h2 {
    font-size: 24px;
  }

  .summary-grid,
  .branch-list,
  .form-grid,
  .search-filter-panel {
    grid-template-columns: 1fr;
  }

  .remarks-field {
    grid-column: auto;
  }

  .toolbar,
  .topbar-actions,
  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar select,
  .search-box,
  .primary-button,
  .ghost-button {
    width: 100%;
  }
}

/* Final typography scale */
.topbar,
.page-shell,
.login-card {
  font-size: 14px;
}

.field span,
.eyebrow,
.welcome {
  font-size: 12px;
}

.details-text,
.panel-heading p,
.form-title p,
.table-meta span,
.admin-card p {
  font-size: 14px;
}

.metric-card strong,
.highlight-grid strong,
.health-box strong {
  font-size: 28px;
}

.asset-form h3,
.panel-heading h2,
.dialog-card h2 {
  font-size: 20px;
}

.hero-copy h2,
.admin-topline h2 {
  font-size: 20px;
}

h1,
h2,
h3,
.topbar h1,
.hero-copy h2,
.panel-heading h2,
.asset-form h3,
.dialog-card h2,
.admin-topline h2,
.login-card h1 {
  font-size: 20px !important;
  line-height: 1.3;
}

.metric-card strong,
.highlight-grid strong,
.health-box strong {
  font-size: 20px !important;
  line-height: 1.2;
}

/* Maximum font and verification table corrections */
body,
body * {
  font-size: min(20px, 1em);
}

.topbar h1,
.hero-copy h2,
.admin-topline h2,
.metric-card strong,
.highlight-grid strong,
.health-box strong,
.asset-form h3,
.panel-heading h2,
.dialog-card h2,
.login-card h1 {
  font-size: 20px !important;
}

.verification-table {
  min-width: 1800px;
  table-layout: fixed;
}

.verification-table th,
.verification-table td {
  padding: 8px;
  font-size: 13px !important;
  overflow: hidden;
}

.verification-table th:nth-child(1),
.verification-table td:nth-child(1) {
  width: 140px;
}

.verification-table th:nth-child(2),
.verification-table td:nth-child(2) {
  width: 150px;
}

.verification-table th:nth-child(3),
.verification-table td:nth-child(3) {
  width: 130px;
}

.verification-table th:nth-child(10),
.verification-table td:nth-child(10),
.verification-table th:nth-child(11),
.verification-table td:nth-child(11),
.verification-table th:nth-child(12),
.verification-table td:nth-child(12),
.verification-table th:nth-child(13),
.verification-table td:nth-child(13),
.verification-table th:nth-child(14),
.verification-table td:nth-child(14),
.verification-table th:nth-child(15),
.verification-table td:nth-child(15) {
  width: 150px;
}

.verification-table .barcode-box {
  width: 122px;
  max-width: 122px;
}

.verification-table .barcode-box svg {
  width: 112px;
  height: 34px;
}

.verification-table .barcode-box small {
  display: block;
  max-width: 120px;
  overflow-wrap: anywhere;
  text-align: center;
  font-size: 10px !important;
}

.verification-table select,
.verification-table input,
.verification-table textarea {
  width: 100%;
  max-width: 100%;
  font-size: 13px !important;
}

.verification-table textarea {
  min-width: 0;
  resize: vertical;
}
