/* ToolRent Admin — matches mskrishno-style dashboard */
:root {
  --sidebar: #141414;
  --sidebar-text: #c8c8c8;
  --sidebar-active: #28a745;
  --sidebar-hover: #1f1f1f;
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #222;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #28a745;
  --primary-dark: #21913c;
  --danger: #dc3545;
  --warn: #f59e0b;
  --info: #3b82f6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  --font: "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body.admin-body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: grid;
  grid-template-columns: 230px 1fr;
}

.admin-sidebar {
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  padding: 1.15rem 1.1rem;
  font-weight: 500;
  font-size: 1.05rem;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.75rem 0.55rem;
  flex: 1;
  overflow: auto;
}
.sidebar-foot {
  padding: 0.55rem;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0.8rem;
  border-radius: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 400;
}
.nav-item i { width: 1.1rem; text-align: center; opacity: 0.85; }
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active {
  background: rgba(40, 167, 69, 0.16);
  color: var(--sidebar-active);
  font-weight: 500;
}
.nav-item.active i { color: var(--sidebar-active); }

.admin-main {
  padding: 1.35rem 1.6rem 2rem;
  min-width: 0;
}
.admin-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.admin-top h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.admin-user {
  color: var(--muted);
  font-size: 0.9rem;
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.92rem;
}
.flash-success { background: #e8f8ee; color: #176b34; }
.flash-error { background: #fdecec; color: #9b1c1c; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.9rem;
  margin-bottom: 1.35rem;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.05rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  flex-shrink: 0;
}
.stat-icon.users { background: #3b82f6; }
.stat-icon.services { background: #8b5cf6; }
.stat-icon.orders { background: #28a745; }
.stat-icon.pending { background: #f59e0b; }
.stat-icon.providers { background: #06b6d4; }
.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 0.15rem;
}
.stat-value {
  font-size: 1.4rem;
  font-weight: 500;
  line-height: 1.1;
}

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.15rem 1.25rem;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
  flex-wrap: wrap;
}
.panel-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 500;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  margin-bottom: 0.85rem;
}
.search-box {
  display: flex;
  gap: 0.45rem;
  flex: 1;
  min-width: 220px;
}
.search-box input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  font: inherit;
}
.btn {
  border: 0;
  border-radius: 8px;
  padding: 0.55rem 0.95rem;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.85rem; }

.status-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
}
.status-tab {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
}
.status-tab .count {
  display: inline-block;
  margin-left: 0.25rem;
  background: #eef2ff;
  color: #3730a3;
  border-radius: 999px;
  padding: 0.05rem 0.4rem;
  font-size: 0.75rem;
}
.status-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.status-tab.active .count {
  background: rgba(255,255,255,0.25);
  color: #fff;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.data-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.empty-row {
  text-align: center;
  color: var(--muted);
  padding: 1.5rem 0.5rem !important;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 500;
}
.badge-pending { background: #fff7ed; color: #c2410c; }
.badge-processing { background: #eff6ff; color: #1d4ed8; }
.badge-success { background: #ecfdf5; color: #047857; }
.badge-reject { background: #fef2f2; color: #b91c1c; }
.badge-active { background: #ecfdf5; color: #047857; }
.badge-inactive { background: #f3f4f6; color: #6b7280; }
.badge-remote { background: #eff6ff; color: #1d4ed8; }
.badge-server { background: #fef3c7; color: #92400e; }
.badge-imei { background: #f5f3ff; color: #6d28d9; }
.badge-other { background: #f3f4f6; color: #6b7280; }
.badge-added { background: #ecfdf5; color: #047857; }
.badge-updated { background: #eff6ff; color: #1d4ed8; }
.badge-edited { background: #fef3c7; color: #92400e; }
.badge-rotated { background: #f5f3ff; color: #6d28d9; }
.badge-recovered { background: #fff7ed; color: #c2410c; }

.gmail-panel .gmail-connected {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}
.gmail-setup {
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  background: #fafafa;
}
.gmail-setup summary {
  cursor: pointer;
  font-weight: 500;
  font-size: 0.92rem;
}
.gmail-steps {
  margin: 0.65rem 0 0;
  padding-left: 1.15rem;
  color: #555;
  font-size: 0.88rem;
  line-height: 1.65;
}
.gmail-connect-form { margin-top: 0.5rem; }
.btn-gmail {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  border: 1px solid #dadce0;
  background: #fff;
  color: #3c4043;
  border-radius: 8px;
  padding: 0.7rem 1.15rem;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.btn-gmail:hover:not(:disabled) { background: #f8f9fa; }
.btn-gmail:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.75rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--muted);
}
.badge-link {
  text-decoration: none;
}
.badge-link:hover { filter: brightness(0.95); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}
.form-group { display: flex; flex-direction: column; gap: 0.35rem; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { font-size: 0.82rem; font-weight: 400; color: var(--muted); }
.form-group input,
.form-group select,
.form-group textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  font: inherit;
}
.form-actions { margin-top: 1rem; display: flex; gap: 0.5rem; }

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #0f172a, #14532d 55%, #052e16);
  font-family: var(--font);
}
.auth-card {
  width: min(400px, 92vw);
  background: #fff;
  border-radius: 14px;
  padding: 1.6rem 1.5rem 1.4rem;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.auth-card h1 { margin: 0 0 0.25rem; font-size: 1.3rem; }
.auth-card p { margin: 0 0 1.1rem; color: var(--muted); font-size: 0.9rem; }
.auth-form .form-group { margin-bottom: 0.8rem; }
.btn-block { width: 100%; justify-content: center; }

.demo-banner {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.88rem;
}

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  body.admin-body { grid-template-columns: 1fr; }
  .admin-sidebar { position: relative; height: auto; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
}

/* Digital Inventory — simple */
.inv-simple { padding: 1.15rem 1.2rem 1.35rem; }
.inv-add {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}
.inv-add select,
.inv-add input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font: inherit;
  font-weight: 400;
  background: #fff;
  min-width: 0;
}
.inv-add select { flex: 1.2; min-width: 160px; }
.inv-add input { flex: 1; min-width: 140px; }
.inv-link {
  color: var(--primary);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.35rem 0.25rem;
  white-space: nowrap;
}
.inv-link:hover { text-decoration: underline; }
.inv-meta {
  margin: 0.9rem 0 0.65rem;
  color: var(--muted);
  font-size: 0.88rem;
}
.inv-table-wrap { overflow: auto; }
.inv-table td, .inv-table th { font-weight: 400; }
.inv-row-actions {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  justify-content: flex-end;
  white-space: nowrap;
}
.inv-row-actions form { display: inline; margin: 0; }
.linkish {
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  font-size: 0.85rem;
  color: var(--primary);
  cursor: pointer;
  text-decoration: none;
}
.linkish:hover { text-decoration: underline; }
.linkish.danger { color: var(--danger); }
.inv-row-active { background: #f0fdf4; }
.inv-history {
  margin-top: 1rem;
  padding: 1rem 1.1rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fafafa;
}
.inv-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.inv-history-head h3 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 500;
}
.inv-timer-cell { white-space: nowrap; }
.inv-timer {
  display: inline-block;
  min-width: 3.2rem;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  background: #ecfdf5;
  color: #047857;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}
.inv-timer-warn { background: #fff7ed; color: #c2410c; }
.inv-timer-due { background: #fef2f2; color: #b91c1c; font-weight: 500; }
.inv-timer-muted { color: var(--muted); }
.inv-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0.85rem 0 0.65rem;
}
.inv-toolbar .inv-meta { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.inv-timer-set {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
}
.inv-timer-set label { font-size: 0.82rem; color: var(--muted); }
.inv-timer-set input[type="number"] {
  width: 4.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.45rem;
  font: inherit;
}
.inv-timer-unit { font-size: 0.8rem; color: var(--muted); }
.inv-code { font-size: 0.82rem; max-width: 280px; word-break: break-all; }
.inv-ts { white-space: nowrap; font-size: 0.85rem; }
.inv-sold-at { color: #c2410c; font-weight: 500; }
.inv-order-id { font-size: 0.75rem; color: var(--muted); }
.inv-pending { display: block; font-size: 0.8rem; color: #1d4ed8; margin-top: 0.2rem; }
.btn-mark-sold {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #c2410c;
  border-radius: 6px;
  padding: 0.25rem 0.55rem;
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}
.btn-mark-sold:hover { background: #ffedd5; }
.inv-subh {
  margin: 1.1rem 0 0.5rem;
  font-size: 0.92rem;
  font-weight: 500;
}

@media (max-width: 720px) {
  .inv-add select,
  .inv-add input { flex: 1 1 100%; }
}

/* Inventory — two-column layout + history dialog */
.inv-layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  gap: 1.15rem;
  align-items: start;
}

.inv-sidebar {
  position: sticky;
  top: 1rem;
  padding: 1.15rem 1.2rem 1.25rem;
}

.inv-sidebar-title {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  font-weight: 500;
}

.inv-sidebar-hint {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.inv-sidebar-form .form-group {
  margin-bottom: 0.85rem;
}

.inv-sidebar-form label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.inv-sidebar-form select,
.inv-sidebar-form input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font: inherit;
  background: #fff;
}

.inv-sidebar-form .form-actions {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.25rem;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.inv-open-site {
  display: inline-block;
  margin-top: 0.85rem;
}

.inv-divider {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 1.1rem 0;
}

.inv-timer-set--stack .inv-timer-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.inv-timer-set--stack input[type="number"] {
  flex: 1;
  min-width: 0;
}

.inv-main {
  padding: 1.15rem 1.2rem 1.35rem;
  min-width: 0;
}

.inv-main-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.inv-main-title {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  font-weight: 500;
}

.inv-main .inv-meta {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

/* History dialog — wide but not full viewport */
body.inv-dialog-open { overflow: hidden; }

.inv-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.inv-modal.open {
  display: flex;
}

.inv-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  cursor: pointer;
}

.inv-modal-panel {
  position: relative;
  z-index: 1;
  width: min(1100px, 92vw);
  max-height: min(88vh, 900px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.18);
  overflow: hidden;
}

.inv-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
}

.inv-dialog-head h3 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
  font-weight: 500;
}

.inv-dialog-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.inv-dialog-close {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.inv-dialog-close:hover {
  background: #f1f5f9;
  color: var(--text);
}

.inv-dialog-body {
  padding: 0;
  overflow: auto;
  flex: 1;
  min-height: 0;
}

.inv-dialog-tabs {
  display: flex;
  gap: 0;
  padding: 0 1.15rem;
  border-bottom: 1px solid var(--border);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 1;
}

.inv-tab {
  border: 0;
  background: none;
  padding: 0.7rem 0.95rem;
  font: inherit;
  font-size: 0.88rem;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.inv-tab:hover { color: var(--text); }

.inv-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 500;
}

.inv-tab-panels { padding: 0.85rem 1.15rem 1.15rem; }

.inv-tab-panel { display: none; }
.inv-tab-panel.active { display: block; }

.inv-dialog-body .inv-subh:first-child { margin-top: 0; }

@media (max-width: 960px) {
  .inv-layout {
    grid-template-columns: 1fr;
  }

  .inv-sidebar {
    position: static;
  }
}
