/* ============================================================
   APPINSTAN APOTEK — Main Stylesheet
   Design: Navy Blue + Medical Green + White + Gold accent
   ============================================================ */

:root {
  --navy-900: #0A1628;
  --navy-800: #0D1F35;
  --navy-700: #142840;
  --navy-600: #1E3A5F;
  --navy-500: #2A5080;
  --navy-400: #3A6FA8;
  --blue-500:  #1D6FA8;
  --blue-400:  #2680BC;
  --teal-500:  #0F766E;
  --teal-400:  #14B8A6;
  --green-500: #15803D;
  --green-400: #22C55E;
  --gold-400:  #D97706;
  --gold-300:  #F59E0B;
  --red-500:   #DC2626;
  --red-400:   #EF4444;
  --text-primary:   #E8EDF5;
  --text-muted:     #8AACCA;
  --text-dim:       #4A7090;
  --sidebar-width:  230px;
  --topbar-height:  56px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  color-scheme: dark;
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--navy-900);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
}

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at top, #12365a 0, #0A1628 42%, #060F1E 100%);
}

.auth-card {
  width: min(100%, 420px);
  background: var(--navy-800);
  border: 1px solid var(--navy-600);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: 0 24px 80px rgba(0,0,0,.45);
}

.auth-logo { color: #C8DFF0; font-weight: 800; margin-bottom: 16px; }
.auth-card h1 { font-size: 22px; margin-bottom: 8px; }
.auth-card p, .auth-link { color: var(--text-muted); font-size: 13px; }
.auth-link { display: inline-block; margin-top: 16px; text-decoration: none; }

.app-input,
.form-control.app-input {
  width: 100%;
  background: #0A1628;
  border: 1px solid var(--navy-600);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 12px;
}

.app-input:focus,
.form-control.app-input:focus {
  background: #0A1628;
  border-color: var(--blue-400);
  color: var(--text-primary);
  box-shadow: 0 0 0 3px rgba(38,128,188,.18);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.detail-item {
  border: 1px solid var(--navy-600);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: #0A1628;
}

.detail-label { color: var(--text-dim); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.detail-value { color: var(--text-primary); margin-top: 4px; word-break: break-word; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.app-sidebar {
  position: fixed; left: 0; top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: #060F1E;
  border-right: 1px solid var(--navy-600);
  display: flex; flex-direction: column;
  z-index: 1000;
  overflow: hidden;
  transition: width .25s ease;
}

.sidebar-logo {
  padding: 18px 16px;
  border-bottom: 1px solid var(--navy-600);
  display: flex; align-items: center; gap: 10px;
  min-height: 64px;
}

.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--blue-500), var(--teal-400));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}

.logo-text .name { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.logo-text .sub  { font-size: 10px; color: var(--text-dim); margin-top: 1px; }

.sidebar-body {
  flex: 1; overflow-y: auto; padding: 8px 0;
}
.sidebar-body::-webkit-scrollbar { width: 3px; }
.sidebar-body::-webkit-scrollbar-thumb { background: var(--navy-600); }

.nav-section {
  padding: 14px 16px 4px;
  font-size: 10px; font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 1px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; margin: 1px 8px;
  border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-muted);
  cursor: pointer; text-decoration: none;
  transition: all .15s;
  white-space: nowrap;
}

.nav-item i { font-size: 16px; flex-shrink: 0; }
.nav-item:hover { background: var(--navy-700); color: #B8D8EE; }
.nav-item.active { background: var(--blue-500); color: #fff; font-weight: 600; }

.nav-badge {
  margin-left: auto; background: var(--red-500);
  color: #fff; font-size: 10px; padding: 1px 7px;
  border-radius: 20px; font-weight: 700;
}

.sidebar-footer {
  border-top: 1px solid var(--navy-600);
  padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
}

.sidebar-footer-logout {
  padding: 10px 12px;
}

.sidebar-footer .avatar {
  width: 34px; height: 34px; background: var(--blue-500);
  border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}
.sidebar-footer .user-info { flex: 1; min-width: 0; }
.sidebar-footer .name { font-size: 12px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer .role { font-size: 10px; color: var(--text-dim); }
.btn-logout { color: var(--text-dim); font-size: 18px; text-decoration: none; transition: color .15s; }
.btn-logout:hover { color: var(--red-400); }
.btn-logout.minimal {
  font-size: 12px;
  font-weight: 700;
  padding: 9px 12px;
  border-radius: 6px;
  color: #52657A;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #F3F7FA;
  border: 1px solid #D8E2EA;
}
.btn-logout.minimal:hover {
  background: #FDECEC;
  color: #B91C1C;
  border-color: #F5C2C7;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.app-topbar {
  position: fixed; top: 0;
  left: var(--sidebar-width); right: 0;
  height: var(--topbar-height);
  background: #060F1E;
  border-bottom: 1px solid var(--navy-600);
  display: flex; align-items: center; padding: 0 20px; gap: 12px;
  z-index: 999;
}

.topbar-title { font-size: 15px; font-weight: 600; color: #C8DFF0; flex: 1; }

.topbar-badge {
  background: var(--navy-700); color: var(--text-muted);
  font-size: 11px; padding: 4px 12px;
  border-radius: 20px; border: 1px solid var(--navy-600);
}

.topbar-badge.alert {
  background: rgba(220,38,38,.15); color: #FC8181;
  border-color: rgba(220,38,38,.3); cursor: pointer;
}

.topbar-avatar {
  width: 34px; height: 34px; background: var(--blue-500);
  border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 12px; font-weight: 700;
  cursor: pointer;
  border: 0;
  color: #fff;
}

.account-dropdown {
  position: relative;
}

.account-trigger {
  box-shadow: 0 0 0 3px rgba(15,111,122,.08);
}

.account-menu {
  width: 290px;
  border: 1px solid #D8E2EA;
  border-radius: 10px;
  padding: 8px;
  box-shadow: 0 22px 54px rgba(23,32,51,.18);
  color: #172033;
}

.account-menu-head {
  display: grid;
  grid-template-columns: 42px minmax(0,1fr);
  gap: 10px;
  align-items: center;
  padding: 10px 10px 12px;
  border-bottom: 1px solid #E6EEF4;
  margin-bottom: 6px;
}

.account-menu-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  overflow: hidden;
}

.account-menu-head strong,
.account-menu-head span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-menu-head strong {
  font-size: 13px;
}

.account-menu-head span {
  font-size: 11px;
  color: #6B839A;
  margin-top: 2px;
}

.account-menu .dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}

.account-menu .dropdown-item i {
  color: #64748B;
  font-size: 15px;
}

.account-menu .dropdown-item:hover {
  background: #EEF7F7;
  color: var(--brand-primary);
}

.account-menu .dropdown-item:hover i {
  color: var(--brand-primary);
}

.account-menu .logout-item {
  color: #B91C1C;
}

.account-menu .logout-item i {
  color: #B91C1C;
}

.about-subtitle {
  font-size: 12px;
  color: #6B839A;
  margin-top: 2px;
}

.compliance-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #E8F7EF;
  color: #166534;
  font-weight: 800;
  font-size: 13px;
  margin-bottom: 12px;
}

.about-grid {
  display: grid;
  gap: 10px;
}

.about-grid div {
  padding: 11px 12px;
  border: 1px solid #D8E2EA;
  border-radius: 8px;
  background: #F8FBFD;
}

.about-grid strong,
.about-grid span {
  display: block;
}

.about-grid strong {
  color: #172033;
  font-size: 13px;
  margin-bottom: 3px;
}

.about-grid span,
.about-note {
  color: #52657A;
  font-size: 12px;
  line-height: 1.55;
}

.about-note {
  margin: 12px 0 0;
}

.topbar-icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid #D8E2EA;
  border-radius: 8px;
  background: #FFFFFF;
  color: #40566D;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.topbar-icon-btn:hover {
  background: #EEF4F8;
  color: var(--brand-primary);
}
.sidebar-toggle-btn {
  display: none;
}
.sidebar-backdrop {
  display: none;
}

body.pos-mode {
  --sidebar-width: 214px;
}

body.pos-mode .app-sidebar {
  width: 214px;
}

body.pos-mode .app-content {
  padding: 16px 18px;
}

body.pos-mode .nav-item {
  padding: 8px 12px;
  margin-inline: 7px;
  font-size: 12.5px;
}

body.pos-mode .nav-item.active[href$="/pos"] {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));
  color: #fff;
  box-shadow: 0 10px 24px rgba(15,111,122,.22);
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.app-main {
  margin-left: var(--sidebar-width);
  padding-top: var(--topbar-height);
  min-height: 100vh;
}

.app-content { padding: 22px 24px; }

.page-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 20px;
}
.page-title { font-size: 20px; font-weight: 700; color: #C8DFF0; }
.page-sub   { font-size: 12px; color: var(--text-dim); margin-top: 3px; }
.page-actions { display: flex; gap: 8px; align-items: center; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--navy-800);
  border: 1px solid var(--navy-600);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}

.card-title {
  font-size: 13px; font-weight: 600;
  color: var(--text-muted); margin-bottom: 14px;
}

.stat-card {
  background: var(--navy-800);
  border: 1px solid var(--navy-600);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  position: relative; overflow: hidden;
}

.stat-card .label { font-size: 11px; color: var(--text-dim); margin-bottom: 6px; }
.stat-card .value { font-size: 24px; font-weight: 700; }
.stat-card .sub   { font-size: 11px; color: var(--text-dim); margin-top: 4px; }
.stat-card .icon  { position: absolute; right: 14px; top: 14px; font-size: 28px; opacity: .12; }

.stat-card.blue  .value { color: #63B3ED; }
.stat-card.green .value { color: #68D391; }
.stat-card.amber .value { color: #F6AD55; }
.stat-card.red   .value { color: #FC8181; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; transition: all .15s;
  text-decoration: none; line-height: 1;
}

.btn-primary { background: var(--blue-500); color: #fff; border-color: var(--blue-500); }
.btn-primary:hover { background: var(--blue-400); color: #fff; }
.btn-success { background: var(--green-500); color: #fff; border-color: var(--green-500); }
.btn-success:hover { background: var(--green-400); }
.btn-danger  { background: var(--red-500); color: #fff; border-color: var(--red-500); }
.btn-danger:hover { background: var(--red-400); }
.btn-warning { background: var(--gold-400); color: #fff; border-color: var(--gold-400); }
.btn-secondary { background: var(--navy-700); color: var(--text-muted); border-color: var(--navy-600); }
.btn-secondary:hover { background: var(--navy-600); color: var(--text-primary); }
.btn-outline { background: transparent; color: var(--blue-500); border-color: var(--blue-500); }
.btn-outline:hover { background: var(--blue-500); color: #fff; }

.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }
.btn-block { width: 100%; justify-content: center; }

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.form-control, .form-select {
  width: 100%;
  background: var(--navy-900);
  border: 1px solid var(--navy-600);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 9px 12px;
  font-size: 13px;
  transition: border-color .15s;
  outline: none;
}
.form-control:focus, .form-select:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(29,111,168,.15);
}
.form-control::placeholder { color: var(--text-dim); }
.form-label { font-size: 12px; color: var(--text-muted); margin-bottom: 5px; display: block; font-weight: 600; letter-spacing: .3px; }

/* ============================================================
   TABLES
   ============================================================ */
.table-dark-custom {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.table-dark-custom thead tr {
  background: var(--navy-900);
}
.table-dark-custom th {
  padding: 10px 14px; text-align: left;
  font-size: 11px; font-weight: 700;
  color: var(--text-dim); text-transform: uppercase;
  letter-spacing: .5px; border-bottom: 1px solid var(--navy-600);
}
.table-dark-custom td {
  padding: 11px 14px; border-bottom: 1px solid var(--navy-700);
  color: var(--text-muted); vertical-align: middle;
}
.table-dark-custom tr:hover td { background: var(--navy-900); }
.table-dark-custom .td-name { color: var(--text-primary); font-weight: 600; }

/* ============================================================
   BADGES
   ============================================================ */
.badge-pill {
  display: inline-block; padding: 3px 10px;
  border-radius: 20px; font-size: 11px; font-weight: 700;
}
.badge-blue   { background: rgba(29,111,168,.2); color: #63B3ED; }
.badge-green  { background: rgba(21,128,61,.2);  color: #68D391; }
.badge-red    { background: rgba(220,38,38,.2);  color: #FC8181; }
.badge-amber  { background: rgba(217,119,6,.2);  color: #F6AD55; }
.badge-teal   { background: rgba(15,118,110,.2); color: #2DD4BF; }
.badge-gray   { background: rgba(100,116,139,.2);color: #94A3B8; }

/* ============================================================
   ALERTS
   ============================================================ */
.alert-box {
  padding: 12px 16px; border-radius: var(--radius-md);
  font-size: 13px; margin-bottom: 14px;
  display: flex; align-items: flex-start; gap: 10px;
}
.alert-box.danger  { background: rgba(220,38,38,.12); border-left: 3px solid var(--red-500); color: #FC8181; }
.alert-box.warning { background: rgba(217,119,6,.12); border-left: 3px solid var(--gold-400); color: #F6AD55; }
.alert-box.success { background: rgba(21,128,61,.12); border-left: 3px solid var(--green-500); color: #68D391; }
.alert-box.info    { background: rgba(29,111,168,.12);border-left: 3px solid var(--blue-500); color: #63B3ED; }

/* ============================================================
   POS SPECIFIC
   ============================================================ */
.pos-container {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 14px;
  height: calc(100vh - var(--topbar-height) - 44px);
}

.pos-search-bar {
  display: flex; gap: 8px; align-items: center;
}

.pos-search-input {
  flex: 1;
  background: var(--navy-900);
  border: 1px solid var(--navy-600);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 14px; outline: none;
}
.pos-search-input:focus { border-color: var(--blue-500); }

.pos-cart {
  flex: 1; overflow-y: auto;
  background: var(--navy-800);
  border: 1px solid var(--navy-600);
  border-radius: var(--radius-lg);
}

.pos-panel {
  background: var(--navy-800);
  border: 1px solid var(--navy-600);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex; flex-direction: column; gap: 14px;
  overflow-y: auto;
}

.pos-action-bar {
  position: sticky;
  bottom: -18px;
  margin: 0 -18px -18px;
  padding: 12px 18px 14px;
  background: inherit;
  border-top: 1px solid var(--navy-600);
  display: grid;
  gap: 8px;
  z-index: 2;
}

.pos-pay-button {
  min-height: 48px;
  font-size: 15px;
  letter-spacing: .01em;
}

/* ============================================================
   DATATABLE OVERRIDE
   ============================================================ */
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
  background: var(--navy-900) !important;
  border: 1px solid var(--navy-600) !important;
  color: var(--text-primary) !important;
  border-radius: var(--radius-sm) !important;
  padding: 5px 10px !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
  background: var(--navy-800) !important;
  border: 1px solid var(--navy-600) !important;
  color: var(--text-muted) !important;
  border-radius: var(--radius-sm) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: var(--blue-500) !important;
  color: #fff !important;
  border-color: var(--blue-500) !important;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-content {
  background: var(--navy-800) !important;
  border: 1px solid var(--navy-600) !important;
  border-radius: var(--radius-lg) !important;
  color: var(--text-primary) !important;
}

.modal-header { border-bottom-color: var(--navy-600) !important; }
.modal-footer { border-top-color: var(--navy-600) !important; }
.modal-title  { color: var(--text-primary) !important; }
.btn-close    { filter: invert(1) !important; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .pos-container { grid-template-columns: 1fr; }
  body.pos-mode .app-topbar,
  body.pos-mode .app-main {
    margin-left: 0;
  }
}

@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }
  .app-sidebar {
    transform: translateX(-105%);
    transition: transform .25s ease;
    width: 280px !important;
    z-index: 1100;
  }
  .app-sidebar.open { transform: translateX(0); --sidebar-width: 260px; width: 260px; }
  .app-topbar, .app-main { left: 0 !important; margin-left: 0 !important; }
  .sidebar-toggle-btn { display: inline-flex; }
  .sidebar-backdrop.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.38);
    z-index: 998;
  }
  .app-content { padding: 14px 12px; }
  .topbar-title { font-size: 14px; }
  .topbar-badge { display: none; }
  #clockDisplay { display: none; }
}

/* ============================================================
   LIGHT ENTERPRISE THEME OVERRIDE
   ============================================================ */
:root {
  --surface-page: #F4F7FB;
  --surface-card: #FFFFFF;
  --surface-muted: #EEF4F8;
  --border-soft: #D8E2EA;
  --text-primary: #172033;
  --text-muted: #52657A;
  --text-dim: #7890A8;
  --brand-primary: #0F6F7A;
  --brand-primary-hover: #0B5D66;
  --brand-accent: #1D7A46;
  color-scheme: light;
}

body.app-body {
  background: var(--surface-page);
  color: var(--text-primary);
}

.app-sidebar {
  background: #FFFFFF;
  border-right: 1px solid var(--border-soft);
  box-shadow: 2px 0 18px rgba(23,32,51,.05);
}

.sidebar-logo {
  border-bottom: 1px solid var(--border-soft);
}

.logo-icon {
  background: linear-gradient(135deg, #0F6F7A, #20A08C);
  color: #fff;
}

.logo-text .name,
.sidebar-footer .name {
  color: #142033;
}

.logo-text .sub,
.sidebar-footer .role,
.nav-section {
  color: #6B839A;
}

.nav-item {
  color: #40566D;
}

.nav-item:hover {
  background: #EAF3F7;
  color: #0F5160;
}

.nav-item.active {
  background: #DDF1EF;
  color: #0C5D67;
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--brand-primary);
}

.sidebar-footer {
  border-top: 1px solid var(--border-soft);
  background: #FFFFFF;
}

.btn-logout {
  color: #557085;
}

.app-topbar {
  background: #FFFFFF;
  border-bottom: 1px solid var(--border-soft);
  box-shadow: 0 1px 16px rgba(23,32,51,.05);
}

.topbar-title,
.page-title {
  color: #172033;
}

.topbar-badge {
  background: #EEF4F8;
  color: #40566D;
  border-color: var(--border-soft);
}

.app-main {
  background: var(--surface-page);
}

.app-content {
  color: var(--text-primary);
}

.page-sub {
  color: var(--text-muted);
}

.card,
.stat-card,
.detail-item,
.settings-panel,
.backup-panel,
.settings-card {
  background: var(--surface-card) !important;
  border: 1px solid var(--border-soft) !important;
  color: var(--text-primary) !important;
  box-shadow: 0 10px 28px rgba(23,32,51,.06);
}

.card-title,
.stat-card .label,
.stat-card .sub,
.settings-desc,
.settings-help,
.backup-meta {
  color: var(--text-muted) !important;
}

.stat-card .value,
.stat-card.blue .value,
.stat-card.green .value,
.stat-card.amber .value,
.stat-card.red .value {
  color: #0F6F7A;
}

.stat-card.green .value {
  color: #15803D;
}

.stat-card.amber .value {
  color: #B45309;
}

.stat-card.red .value {
  color: #B91C1C;
}

.btn-primary {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--brand-primary-hover);
  border-color: var(--brand-primary-hover);
  color: #fff;
}

.btn-success {
  background: var(--brand-accent);
  border-color: var(--brand-accent);
}

.btn-secondary {
  background: #E7EEF4;
  border-color: #D1DEE8;
  color: #223247;
}

.btn-secondary:hover {
  background: #D9E6EF;
  color: #172033;
}

.btn-outline {
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}

.app-input,
.form-control.app-input,
.form-select.app-input {
  background: #FFFFFF;
  border-color: #C9D8E3;
  color: var(--text-primary);
}

.app-input:focus,
.form-control.app-input:focus,
.form-select.app-input:focus {
  background: #FFFFFF;
  border-color: var(--brand-primary);
  color: var(--text-primary);
  box-shadow: 0 0 0 3px rgba(15,111,122,.14);
}

.table-dark-custom thead tr {
  background: #EEF4F8;
}

.table-dark-custom th {
  color: #50677C;
  border-bottom: 1px solid var(--border-soft);
}

.table-dark-custom td {
  color: #25364A;
  border-bottom: 1px solid #E6EEF4;
}

.table-dark-custom tr:hover td {
  background: #F7FAFC;
}

.alert-success {
  background: #E8F7EF;
  border-color: #B8E3C9;
  color: #166534;
}

.alert-danger {
  background: #FDECEC;
  border-color: #F5C2C7;
  color: #991B1B;
}

/* POS light palette */
.pos-container {
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
  height: calc(100vh - var(--topbar-height) - 32px);
  min-height: 620px;
}

.pos-search-bar {
  gap: 10px;
}

.pos-search-input {
  background: #FFFFFF;
  border: 1px solid #C9D8E3;
  color: #172033;
  border-radius: 8px;
  padding: 12px 14px;
}

.pos-search-input::placeholder {
  color: #71869B;
}

.pos-search-input:focus {
  border-color: #0F6F7A;
  box-shadow: 0 0 0 3px rgba(15,111,122,.14);
}

.pos-search-results {
  display: none;
  position: fixed;
  background: #FFFFFF;
  border: 1px solid #D8E2EA;
  border-radius: 8px;
  max-height: 280px;
  overflow-y: auto;
  z-index: 1400;
  width: calc(100% - 48px);
  box-shadow: 0 18px 40px rgba(23,32,51,.14);
}

.pos-search-results-static {
  display: block !important;
  position: relative !important;
  width: 100% !important;
  max-height: none !important;
  box-shadow: none !important;
}

.pos-search-results .search-item:hover {
  background: #F1F7FA;
}

.pos-panel {
  background: #FFFFFF;
  border: 1px solid #D8E2EA;
  border-radius: 8px;
  color: #172033;
  box-shadow: 0 10px 28px rgba(23,32,51,.06);
  max-height: calc(100vh - var(--topbar-height) - 32px);
  overflow-y: auto;
}

.pos-panel .form-label {
  color: #52657A;
  font-weight: 700;
}

.pos-panel .form-control {
  background: #FFFFFF;
  border-color: #C9D8E3;
  color: #172033;
}

.pos-panel .form-control::placeholder {
  color: #71869B;
}

.pos-divider {
  border-color: #D8E2EA;
  opacity: 1;
}

.payment-method-btn.btn-secondary {
  background: #EEF4F8;
  border-color: #D8E2EA;
  color: #223247;
}

.payment-method-btn.btn-secondary:hover {
  background: #E0ECF4;
  color: #0F5160;
}

.payment-method-btn.btn-primary {
  background: #0F6F7A;
  border-color: #0F6F7A;
  color: #FFFFFF;
}

.pos-action-bar {
  background: linear-gradient(180deg, rgba(255,255,255,.88), #FFFFFF 30%);
  border-top-color: #D8E2EA;
  box-shadow: 0 -16px 28px rgba(255,255,255,.9);
}

.pos-pay-button {
  background: #168047;
  border-color: #168047;
  box-shadow: 0 10px 22px rgba(22,128,71,.18);
}

@media (max-width: 1180px) {
  .pos-container {
    grid-template-columns: minmax(0, 1fr) 340px;
  }
}

@media (max-width: 1024px) {
  .pos-container {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }

  .pos-panel {
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 768px) {
  .pos-search-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .pos-search-bar .btn,
  .pos-search-bar select {
    width: 100% !important;
  }

  .pos-action-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    border-radius: 14px 14px 0 0;
    z-index: 990;
  }

  body.pos-mode .app-content {
    padding-bottom: 128px;
  }
}

/* Dark mode */
body.dark-mode {
  --surface-page: #0F172A;
  --surface-card: #172033;
  --surface-muted: #223047;
  --border-soft: #2B3B52;
  --text-primary: #E8EDF5;
  --text-muted: #A9B8C9;
  --text-dim: #7F92A8;
  background: var(--surface-page);
  color: var(--text-primary);
}

body.dark-mode .app-sidebar,
body.dark-mode .sidebar-footer {
  background: #0B1220 !important;
  border-color: #233149 !important;
  box-shadow: 2px 0 22px rgba(0,0,0,.28);
}

body.dark-mode .sidebar-logo {
  border-bottom-color: #233149 !important;
}

body.dark-mode .logo-text .name,
body.dark-mode .sidebar-footer .name {
  color: #F1F5F9 !important;
}

body.dark-mode .logo-text .sub,
body.dark-mode .sidebar-footer .role,
body.dark-mode .nav-section {
  color: #8EA3B8 !important;
}

body.dark-mode .nav-item {
  color: #B7C5D6 !important;
}

body.dark-mode .nav-item:hover {
  background: #17243A !important;
  color: #FFFFFF !important;
}

body.dark-mode .nav-item.active {
  background: linear-gradient(135deg, #0F6F7A, #168047) !important;
  color: #FFFFFF !important;
  box-shadow: inset 3px 0 0 rgba(255,255,255,.35), 0 12px 26px rgba(0,0,0,.24);
}

body.dark-mode .btn-logout.minimal {
  color: #B7C5D6 !important;
  background: #111827 !important;
  border-color: #2B3B52 !important;
}

body.dark-mode .btn-logout.minimal:hover {
  background: rgba(239,68,68,.14) !important;
  color: #FCA5A5 !important;
  border-color: rgba(239,68,68,.34) !important;
}

body.dark-mode .sidebar-backdrop.open {
  background: rgba(2,6,23,.64) !important;
}

body.dark-mode .app-topbar,
body.dark-mode .card,
body.dark-mode .stat-card,
body.dark-mode .detail-item,
body.dark-mode .settings-panel,
body.dark-mode .backup-panel,
body.dark-mode .settings-card,
body.dark-mode .profile-card,
body.dark-mode .company-panel,
body.dark-mode .pos-panel {
  background: var(--surface-card) !important;
  border-color: var(--border-soft) !important;
  color: var(--text-primary) !important;
}

body.dark-mode .app-main,
body.dark-mode body.app-body {
  background: var(--surface-page);
}

body.dark-mode .page-title,
body.dark-mode .topbar-title,
body.dark-mode .card-title,
body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3 {
  color: var(--text-primary) !important;
}

body.dark-mode .app-input,
body.dark-mode .form-control,
body.dark-mode .form-control.app-input,
body.dark-mode .topbar-icon-btn,
body.dark-mode .topbar-badge,
body.dark-mode .pos-search-input,
body.dark-mode .brand-color-field {
  background: #111827 !important;
  border-color: #334155 !important;
  color: #E8EDF5 !important;
}

body.dark-mode .account-menu,
body.dark-mode .about-modal {
  background: #172033 !important;
  border-color: #2B3B52 !important;
  color: #E8EDF5 !important;
}

body.dark-mode .account-menu-head {
  border-bottom-color: #2B3B52 !important;
}

body.dark-mode .account-menu-head strong,
body.dark-mode .about-grid strong {
  color: #F1F5F9 !important;
}

body.dark-mode .account-menu-head span,
body.dark-mode .about-subtitle,
body.dark-mode .about-grid span,
body.dark-mode .about-note {
  color: #A9B8C9 !important;
}

body.dark-mode .account-menu .dropdown-item {
  color: #D7E0EA !important;
}

body.dark-mode .account-menu .dropdown-item:hover {
  background: #223047 !important;
  color: #FFFFFF !important;
}

body.dark-mode .about-grid div {
  background: #111827 !important;
  border-color: #2B3B52 !important;
}

body.dark-mode .compliance-badge {
  background: rgba(34,197,94,.14) !important;
  color: #86EFAC !important;
}

body.dark-mode .table-dark-custom thead tr {
  background: #111827;
}

body.dark-mode .table-dark-custom td {
  color: #D7E0EA;
  border-color: #26364A;
}

body.dark-mode .table-dark-custom tr:hover td {
  background: #111827;
}

body.dark-mode .pos-action-bar {
  background: linear-gradient(180deg, rgba(23,32,51,.86), #172033 34%);
  border-top-color: var(--border-soft);
  box-shadow: 0 -16px 30px rgba(15,23,42,.72);
}
