
:root {
  --navy: #101d35;
  --navy2: #192b49;
  --primary: #3569e8;
  --primary-light: #edf3ff;
  --bg: #f5f7fb;
  --white: #ffffff;
  --text: #1b2435;
  --muted: #7c879a;
  --border: #e6eaf0;
  --green: #16a36a;
  --red: #e34f55;
  --orange: #f0a23c;
  --radius: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: Inter, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  margin: auto;
}

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

button {
  cursor: pointer;
}

.app {
  min-height: 100vh;
}

/* SIDEBAR */

.sidebar {
  width: 250px;
  background: var(--navy);
  color: white;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform .25s;
}

.brand {
  height: 86px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px;
  border-bottom: 1px solid #273550;
}

.brand-icon {
  background: var(--primary);
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 23px;
  font-weight: 800;
}

.brand h2 {
  font-size: 16px;
  font-weight: 700;
}

.brand small {
  font-size: 11px;
  color: #9baac0;
}

.nav-label {
  color: #75849e;
  font-size: 10px;
  letter-spacing: 1.5px;
  padding: 10px 10px;
  font-weight: 700;
}

.navigation {
  padding: 0 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.nav-item {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #bdc8d9;
  text-align: left;
  font-size: 13px;
  transition: .15s;
}

.nav-item:hover {
  background: #223553;
  color: white;
}

.nav-item.active {
  background: #2d60d5;
  color: white;
  font-weight: 600;
}

.sidebar-bottom {
  margin-top: auto;
  padding: 14px;
  border-top: 1px solid #273550;
}

.sidebar-info {
  background: #1a2b47;
  padding: 12px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.online-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #25c783;
}

.sidebar-info b {
  display: block;
  font-size: 12px;
}

.sidebar-info small {
  display: block;
  color: #9eacc1;
  font-size: 10px;
  margin-top: 4px;
}

/* MAIN */

.main {
  margin-left: 250px;
  min-height: 100vh;
}

.topbar {
  height: 66px;
  background: white;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.breadcrumb {
  color: var(--muted);
  font-size: 13px;
}

.breadcrumb b {
  color: var(--text);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 18px;
}

.date-label {
  color: var(--muted);
  font-size: 12px;
}

.user-avatar {
  background: #eaf0ff;
  color: #3569e8;
  font-weight: 700;
  width: 55px;
  height: 28px;
  border-radius: 20%;
  display: grid;
  place-items: center;
  font-size: 12px;
}

.menu-toggle {
  display: none;
  border: none;
  background: transparent;
  font-size: 21px;
}

.content {
  padding: 20px 22px;
  max-width: 1800px;
  margin: auto;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

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

.page-heading h1 {
  font-size: 24px;
  letter-spacing: -.5px;
  margin-bottom: 7px;
}

.page-heading p {
  font-size: 13px;
  color: var(--muted);
}

/* BUTTONS */

.btn {
  padding: 10px 15px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 12px;
  transition: .15s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: #2557ca;
}

.btn-light {
  background: white;
  color: #526078;
  border-color: var(--border);
}

.btn-light:hover {
  background: #f3f6fb;
}

.btn-danger {
  background: var(--red);
  color: white;
}

.btn-small {
  padding: 6px 9px;
  font-size: 11px;
}

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

.action-btn {
  background: #f3f6fa;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 11px;
  color: #46536a;
}

.action-btn:hover {
  background: #e9eef7;
}

.action-btn.delete {
  color: #d84048;
}

/* DASHBOARD STATS */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 15px;
  margin-bottom: 18px;
}

.stat-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  min-width: 0;
}

.stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #6c788e;
  font-size: 12px;
}

.stat-icon {
  width: 33px;
  height: 33px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: bold;
}

.stat-icon.blue { background: #edf3ff; color: #3769e6; }
.stat-icon.green { background: #e8f8f0; color: #159c63; }
.stat-icon.red { background: #fff0f0; color: #df4b52; }
.stat-icon.orange { background: #fff5e6; color: #d88b21; }

.stat-card h2 {
  font-size: 28px;
  margin: 12px 0 6px;
  font-weight: 800;
}

.stat-card small {
  font-size: 11px;
  color: #9aa4b4;
}

.secondary-stats .compact {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 95px;
}

.compact span {
  color: var(--muted);
  font-size: 12px;
}

.compact h2 {
  font-size: 24px;
  margin: 12px 0 0;
}

/* PANELS */

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.panel {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 18px;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.panel-header h3, .panel h3 {
  font-size: 14px;
  margin-bottom: 5px;
}

.panel-header p, .muted {
  color: var(--muted);
  font-size: 11px;
}

.panel > h3 {
  padding: 20px 20px 0;
}

.panel > p {
  padding: 10px 20px 15px;
}

.status-summary {
  padding: 22px;
}

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

.status-row:last-child {
  margin-bottom: 0;
}

.status-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 105px;
  color: #58647a;
  font-size: 12px;
}

.status-track {
  background: #edf0f5;
  height: 7px;
  flex: 1;
  border-radius: 20px;
  overflow: hidden;
}

.status-fill {
  height: 100%;
  border-radius: 20px;
  background: var(--primary);
}

.status-count {
  font-weight: 700;
  font-size: 12px;
  width: 24px;
  text-align: right;
}

.quick-actions {
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.quick-actions button {
  border: 1px solid var(--border);
  background: #f9fafc;
  padding: 13px;
  border-radius: 8px;
  text-align: left;
  color: #536179;
  font-size: 12px;
}

.quick-actions button:hover {
  border-color: #b8caff;
  background: var(--primary-light);
  color: var(--primary);
}

/* TABLES */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 17px;
}

.toolbar input,
.toolbar select {
  height: 38px;
  border: 1px solid var(--border);
  background: white;
  border-radius: 8px;
  padding: 0 12px;
  font-size: 12px;
  color: #4c5970;
}

.toolbar input {
  flex: 1;
  min-width: 190px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

thead {
  background: #f8f9fc;
}

th {
  color: #77849a;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 13px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 12px 14px;
  font-size: 12px;
  border-bottom: 1px solid #edf0f4;
  color: #4e5a70;
}

tbody tr:hover {
  background: #fbfcfe;
}

tbody tr:last-child td {
  border-bottom: none;
}

.empty-row {
  text-align: center;
  padding: 30px;
  color: #9aa5b5;
}

/* STATUS BADGES */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border-radius: 30px;
  font-size: 10px;
  font-weight: 700;
}

.badge-working,
.badge-resolved,
.badge-received,
.badge-active,
.badge-in-stock {
  background: #e9f8ef;
  color: #168958;
}

.badge-faulty,
.badge-open,
.badge-expired,
.badge-out-of-stock {
  background: #fff0f0;
  color: #d84d53;
}

.badge-maintenance,
.badge-in-progress,
.badge-partially-received,
.badge-expiring,
.badge-low-stock {
  background: #fff5e7;
  color: #ca8420;
}

.badge-standby,
.badge-ordered,
.badge-upcoming,
.badge-retired,
.badge-cancelled {
  background: #eef2f8;
  color: #62718a;
}

.badge-critical {
  background: #ffe4e5;
  color: #c72d3b;
}

.badge-high {
  background: #fff0e5;
  color: #d56c20;
}

.badge-medium {
  background: #fff7db;
  color: #a87a0c;
}

.badge-low {
  background: #eaf3ff;
  color: #4272cc;
}

/* FORMS */

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full {
  grid-column: 1 / -1;
}

.form-group label {
  font-size: 11px;
  color: #5d6980;
  font-weight: 600;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  border: 1px solid #dfe5ee;
  border-radius: 8px;
  padding: 10px;
  outline: none;
  background: white;
  font-size: 12px;
  color: #354158;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: #6790ef;
  box-shadow: 0 0 0 3px #edf2ff;
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.form-note {
  font-size: 10px;
  color: var(--muted);
}

/* MODAL */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 40, .55);
  z-index: 1000;
  padding: 20px;
  overflow-y: auto;
  align-items: flex-start;
  justify-content: center;
}

.modal-overlay.show {
  display: flex;
}

.modal {
  width: 100%;
  max-width: 700px;
  background: white;
  border-radius: 14px;
  margin: auto;
  box-shadow: 0 20px 70px rgba(0, 0, 0, .15);
}

.modal-header {
  padding: 19px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 17px;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 21px;
  color: #758198;
}

.modal-body {
  padding: 22px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.modal-body .form-grid {
  gap: 15px;
}

/* REPORTS */

.report-actions {
  padding: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.settings-panel {
  padding: 22px;
}

.settings-panel h3 {
  padding: 0;
  margin-bottom: 10px;
}

.settings-panel p {
  padding: 0;
  margin-bottom: 15px;
  line-height: 1.7;
}

.settings-panel input[type=file] {
  display: block;
  margin-bottom: 15px;
}

.danger-zone {
  border-color: #ffd5d5;
}

.danger-zone h3 {
  color: #d33c45;
}

/* TOAST */

.toast {
  position: fixed;
  bottom: 25px;
  right: 25px;
  padding: 14px 18px;
  background: #15243c;
  color: white;
  border-radius: 9px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .15);
  z-index: 2000;
  font-size: 12px;
  display: none;
  max-width: 90vw;
}

.toast.show {
  display: block;
}

/* FOOTER */

.footer {
  padding: 15px 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #98a3b3;
  font-size: 10px;
  border-top: 1px solid var(--border);
  margin-top: 10px;
}

/* RESPONSIVE */

@media (max-width: 1150px) {
  .sidebar {
    width: 220px;
  }
  .main {
    margin-left: 220px;
  }
  .content {
    padding: 10px 10px;
  }
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 800px) {
  .sidebar {
    transform: translateX(-100%);
    width: 260px;
    box-shadow: 10px 0 30px rgba(0,0,0,.1);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main {
    margin-left: 0;
  }
  .menu-toggle {
    display: block;
  }
  .topbar {
    padding: 0 16px;
    gap: 12px;
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .page-heading {
    align-items: flex-start;
  }
  .page-heading h1 {
    font-size: 21px;
  }
  .page-heading .btn {
    white-space: normal;
  }
}

@media (max-width: 550px) {
  .content {
    padding: 15px 10px;
  }
  .topbar {
    height: 58px;
  }
  .breadcrumb {
    flex: 1;
    font-size: 11px;
  }
  .date-label {
    display: none;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .stat-card {
    padding: 13px;
  }
  .stat-card h2 {
    font-size: 24px;
  }
  .page-heading {
    flex-direction: column;
  }
  .page-heading .btn {
    width: 100%;
  }
  .toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .toolbar input {
    grid-column: 1 / -1;
    width: 100%;
  }
  .toolbar select {
    width: 100%;
  }
  .toolbar .btn {
    width: 100%;
  }
  .quick-actions {
    grid-template-columns: 1fr;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .form-group.full {
    grid-column: auto;
  }
  .modal-overlay {
    padding: 10px;
  }
  .modal-body {
    padding: 15px;
  }
  .footer {
    flex-direction: column;
  }
}

@media print {
  .sidebar, .topbar, .btn, .toolbar, .actions, .menu-toggle {
    display: none !important;
  }
  .main {
    margin: 0;
  }
  .content {
    padding: 0;
  }
  .page {
    display: none !important;
  }
  .page.active {
    display: block !important;
  }
  body {
    background: white;
  }
  .panel, .stat-card {
    break-inside: avoid;
  }
}


/* PURCHASE ORDER PDF ATTACHMENT */
.pdf-upload-group {
  grid-column: 1 / -1;
  padding: 14px;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  background: #f8fafc;
}
.pdf-upload-group input[type="file"] {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 10px;
  border: 1px solid #dbe2ea;
  border-radius: 8px;
  background: #fff;
}
.existing-pdf {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  padding: 10px;
  border-radius: 8px;
  background: #eef2f7;
  overflow-wrap: anywhere;
}
.remove-pdf-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
}
.pdf-preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}
.pdf-preview-frame {
  display: block;
  width: 100%;
  height: min(68vh, 720px);
  border: 1px solid #dbe2ea;
  border-radius: 8px;
  background: #f1f5f9;
}
@media (max-width: 550px) {
  .existing-pdf, .pdf-preview-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }
  .pdf-preview-toolbar .btn {
    width: 100%;
    justify-content: center;
  }
}
