:root {
  /* Cerner Millennium palette */
  --blue-main: #005a9e;
  --blue-dark: #003b73;
  --blue-header: #002b5c;
  --bg-main: #e5e9f0;
  --panel-bg: #f9fafc;
  --panel-border: #c0cad8;
  --text-main: #1f2933;
  --text-muted: #6b7b8c;
  --table-header-bg: #004b8d;
  --table-row-bg: #ffffff;
  --table-row-alt: #f7f9fc;
  --accent: #0078d4;
  --radius: 3px;
  --font: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  --fs-small: 11px;
  --fs-base: 12px;
  --fs-title: 15px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg-main);
  color: var(--text-main);
  font-size: var(--fs-base);
}

/* LOGIN SCREEN - Updated with EMR colors */
#login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--blue-header) 0%, var(--blue-dark) 50%, var(--blue-main) 100%);
}

.login-box {
  width: 400px;
  padding: 30px 25px 25px;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  border-top: 4px solid var(--accent);
}

.login-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--blue-header);
  margin-bottom: 5px;
  text-align: center;
}

.login-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 25px;
  text-align: center;
  padding-bottom: 10px;
  border-bottom: 1px solid #e0e0e0;
}

.label {
  font-size: 12px;
  font-weight: 500;
  margin-top: 12px;
  margin-bottom: 4px;
  color: var(--text-main);
}

.input, select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #c0cad8;
  border-radius: var(--radius);
  font-size: 13px;
  background: #ffffff;
  color: #1f2933;
  transition: all 0.2s ease;
}

.input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 120, 212, 0.1);
}

.input:hover, select:hover, textarea:hover {
  border-color: var(--blue-main);
}

/* Fix for dark text boxes - ensure inputs are readable */
input, select, textarea {
  background-color: #ffffff !important;
  color: #1f2933 !important;
}

input::placeholder, textarea::placeholder {
  color: #9ca3af;
}

.login-btn {
  margin-top: 20px;
  width: 100%;
  padding: 10px;
  background: linear-gradient(135deg, var(--blue-main), var(--blue-dark));
  color: #ffffff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.login-btn:hover {
  background: linear-gradient(135deg, var(--accent), var(--blue-main));
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 90, 158, 0.3);
}

.login-error {
  margin-top: 10px;
  font-size: 11px;
  color: #dc2626;
  text-align: center;
}

/* APP SHELL */
#app {
  display: none;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* TOP BAR */
.topbar {
  height: 42px;
  background: linear-gradient(90deg, var(--blue-header), var(--blue-main));
  color: #f9fafb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: var(--fs-base);
  border-bottom: 1px solid var(--blue-dark);
}

.topbar-title {
  font-weight: 600;
  letter-spacing: 0.03em;
  color: #ffffff;
}

.topbar-sub {
  font-size: var(--fs-small);
  opacity: 0.85;
  color: #dbeafe;
}

.topbar-right {
  font-size: var(--fs-small);
}

/* PATIENT BANNER */
.patient-banner {
  height: 34px;
  background: linear-gradient(180deg, #f0f4fa, #e1e6ee);
  border-bottom: 1px solid #c0cad8;
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: var(--fs-small);
  color: var(--text-main);
}

.banner-item { 
  margin-right: 18px; 
}

/* PATIENT TABS */
.patient-tabs-bar {
  height: 28px;
  background: #cbd4e2;
  border-bottom: 1px solid #b8c2d0;
  display: flex;
  align-items: flex-end;
  padding: 0 6px;
  gap: 3px;
}

.patient-tab {
  position: relative;
  padding: 3px 20px 3px 8px;
  border: 1px solid #9fa8b8;
  border-bottom: none;
  border-top-left-radius: 3px;
  border-top-right-radius: 3px;
  background: #e5ebf5;
  font-size: var(--fs-small);
  color: #374151;
  cursor: default;
}

.patient-tab.active {
  background: #ffffff;
  color: #111827;
  border-color: var(--accent);
}

.patient-tab-close {
  position: absolute;
  right: 6px;
  top: 2px;
  font-size: 10px;
  cursor: pointer;
  color: #6b7280;
}

.patient-tab-close:hover { 
  color: #c53030; 
}

.patient-tab-add {
  padding: 1px 8px;
  border-radius: 3px;
  border: 1px dashed #9fa8b8;
  background: #dde3ee;
  font-size: 14px;
  cursor: pointer;
  color: #6b7280;
  margin-left: 4px;
}

.patient-tab-add:hover { 
  background: #cbd4e2; 
}

/* LAYOUT */
.shell {
  display: flex;
  height: calc(100vh - 42px - 34px - 28px);
}

/* SIDEBAR */
.sidebar {
  width: 220px;
  background: linear-gradient(180deg, #f7f9fc, #e5ebf5);
  border-right: 1px solid var(--panel-border);
  font-size: var(--fs-base);
  display: flex;
  flex-direction: column;
}

.nav-section {
  padding: 8px 10px 4px;
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}

.nav-item {
  padding: 6px 10px;
  cursor: pointer;
  border-left: 3px solid transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #1f2933;
  font-size: var(--fs-small);
  transition: all 0.2s ease;
}

.nav-item:hover { 
  background: #dde7f5; 
}

.nav-item.active {
  background: #ffffff;
  border-left-color: var(--accent);
  font-weight: 600;
}

/* CONTENT */
.content {
  flex: 1;
  padding: 8px 10px;
  overflow-y: auto;
  background: #f4f7fb;
  color: var(--text-main);
}

.page { display: none; }
.page.active { display: block; }

h2 {
  margin: 0 0 4px;
  font-size: var(--fs-title);
  font-weight: 600;
  color: var(--blue-dark);
}

.subtitle {
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: var(--fs-small);
}

/* TABLES */
.table-box {
  border: 1px solid var(--panel-border);
  background: #ffffff;
  border-radius: var(--radius);
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-base);
}

th {
  background: var(--table-header-bg);
  color: #ffffff;
  padding: 8px 6px;
  border-bottom: 1px solid var(--blue-dark);
  text-align: left;
  font-weight: 500;
  font-size: var(--fs-small);
}

td {
  padding: 6px;
  border-bottom: 1px solid #e1e6ee;
  color: #111827;
  background: var(--table-row-bg);
}

tr:nth-child(even) td { 
  background: var(--table-row-alt); 
}

tr:hover td { 
  background: #edf2ff; 
}

/* MPAGE GRID */
.mpage-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 8px;
}

.mpage-card {
  border: 1px solid var(--panel-border);
  background: var(--panel-bg);
  padding: 10px;
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.mpage-title {
  font-weight: 600;
  font-size: var(--fs-small);
  margin-bottom: 8px;
  color: var(--blue-dark);
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 4px;
}

/* FLOWSHEET */
.flowsheet-box {
  border: 1px solid var(--panel-border);
  background: #ffffff;
  overflow-x: auto;
  border-radius: var(--radius);
}

.flowsheet-table {
  min-width: 640px;
}

.flowsheet-table input {
  width: 70px !important;
  padding: 4px !important;
  font-size: 11px !important;
  text-align: center;
  background: #ffffff !important;
  color: #1f2933 !important;
  border: 1px solid #c0cad8;
  border-radius: 2px;
}

.flowsheet-table td {
  padding: 4px !important;
}

/* CHART TABS */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--panel-border);
  margin-bottom: 6px;
  background: #dde3ee;
  border-radius: var(--radius) var(--radius) 0 0;
}

.tab {
  padding: 6px 12px;
  cursor: pointer;
  font-size: var(--fs-small);
  color: #374151;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
  background: #ffffff;
}

.tab:hover:not(.active) {
  background: #eef2f7;
}

.tab-content {
  display: none;
  border: 1px solid var(--panel-border);
  background: #ffffff;
  padding: 10px;
  border-radius: 0 0 var(--radius) var(--radius);
}

.tab-content.active {
  display: block;
}

/* FORMS */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 10px;
}

.form-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
}

.btn {
  padding: 6px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--blue-main);
  background: linear-gradient(180deg, #f0f6ff, #dbeafe);
  cursor: pointer;
  font-size: var(--fs-small);
  color: var(--blue-dark);
  transition: all 0.2s ease;
}

.btn:hover {
  background: linear-gradient(180deg, #e1e6ee, #cbd4e2);
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(180deg, var(--blue-main), var(--blue-dark));
  color: #ffffff;
  border: none;
  font-weight: 600;
}

.btn-primary:hover {
  background: linear-gradient(180deg, var(--accent), var(--blue-main));
}

.btn-small {
  padding: 2px 8px;
  font-size: 10px;
}

/* RESPONSIVE */
@media (max-width: 900px) {
  .mpage-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }
}

@media (max-width: 700px) {
  .shell {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--panel-border);
  }
  .nav-section {
    display: none;
  }
  .nav-item {
    border-left: none;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
  }
  .nav-item.active {
    border-bottom-color: var(--accent);
  }
  .content {
    margin-top: 4px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
}

/* Additional fixes for input fields */
input[type="text"], 
input[type="number"], 
input[type="date"], 
input[type="password"],
select,
textarea {
  background: #ffffff !important;
  color: #1f2933 !important;
  border: 1px solid #c0cad8;
}

input:disabled, 
select:disabled, 
textarea:disabled {
  background: #f3f4f6 !important;
  color: #6b7280 !important;
}

/* Logout button */
#logout-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 4px 12px;
  margin-left: 10px;
  cursor: pointer;
  border-radius: 3px;
  font-size: 11px;
  transition: all 0.2s ease;
}

#logout-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #e5e9f0;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--blue-main);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--blue-dark);
}