:root{
  --bg: #f4f7fb;
  --bg-soft: #eef4fb;
  --surface: #ffffff;
  --surface-2: #f8fbff;
  --text: #183153;
  --text-soft: #607089;
  --heading: #16345f;

  --line: #dbe5f1;
  --line-strong: #c9d8ea;

  --primary: #2f6fed;
  --primary-2: #1d4ed8;
  --primary-soft: #eaf1ff;

  --success: #15803d;
  --success-soft: #ecfdf3;
  --warning: #b45309;
  --warning-soft: #fff7ed;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;

  --shadow-sm: 0 4px 12px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 10px 28px rgba(15, 23, 42, 0.08);

  --radius-sm: 12px;
  --radius: 16px;
  --radius-lg: 22px;
}

*{
  box-sizing: border-box;
}

html, body{
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(219,234,254,.70) 0%, transparent 28%),
    radial-gradient(circle at bottom right, rgba(224,242,254,.60) 0%, transparent 24%),
    linear-gradient(180deg, #f8fbff 0%, #f3f7fc 100%);
  color: var(--text);
}

body{
  min-height: 100vh;
}

a{
  color: var(--primary);
  text-decoration: none;
}

h1, h2, h3, h4{
  color: var(--heading);
  margin-top: 0;
}

code, pre{
  font-family: Consolas, "Courier New", monospace;
}

/* Layout */
.layout{
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar{
  background: linear-gradient(180deg, #ffffff 0%, #f4f8ff 100%);
  border-right: 1px solid var(--line);
  padding: 22px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand{
  font-size: 25px;
  font-weight: 800;
  color: var(--primary-2);
  letter-spacing: .2px;
}

.brand-sub{
  margin-top: 4px;
  color: var(--text-soft);
  font-size: 13px;
}

.menu{
  margin-top: 26px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.menu a{
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--text);
  font-weight: 700;
  border: 1px solid transparent;
  transition: .2s ease;
}

.menu a:hover{
  background: var(--primary-soft);
  border-color: #d6e4ff;
}

.menu a.active{
  background: linear-gradient(180deg, #edf4ff 0%, #e4efff 100%);
  color: var(--primary-2);
  border-color: #cfe0ff;
  box-shadow: inset 0 0 0 1px rgba(47,111,237,.05);
}

.side-footer{
  margin-top: 28px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text-soft);
  font-size: 13px;
  box-shadow: var(--shadow-sm);
}

.logout-btn{
  display: inline-block;
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  background: #fff1f2;
  color: #be123c;
  border: 1px solid #fecdd3;
  font-weight: 700;
}

.main{
  min-width: 0;
}

.topbar{
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.username{
  color: var(--text-soft);
  font-size: 14px;
}

.content{
  padding: 24px;
}

/* Hero */
.hero{
  background: linear-gradient(135deg, #ffffff 0%, #eef5ff 100%);
  border: 1px solid #d9e7ff;
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-md);
  margin-bottom: 18px;
}

.hero h1{
  margin-bottom: 8px;
  font-size: 28px;
  color: var(--primary-2);
}

.hero p{
  margin: 0;
  color: var(--text-soft);
}

/* Cards */
.card{
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-md);
  margin-bottom: 18px;
}

.home-cards{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

.home-card{
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow-md);
}

.home-card h3{
  margin-bottom: 8px;
  color: var(--primary-2);
}

.jump{
  display: inline-block;
  margin-top: 12px;
  padding: 10px 14px;
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  color: #fff;
  border-radius: 10px;
  font-weight: 700;
}

/* Grid */
.grid{
  display: grid;
  gap: 16px;
}

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

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

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

.kv-grid > div,
.kpi{
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}

.k{
  display: block;
  color: var(--text-soft);
  font-size: 13px;
  margin-bottom: 6px;
}

.v{
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.15;
}

/* Form */
label{
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
  color: var(--text);
}

input[type="text"],
input[type="password"],
input[type="file"],
select,
textarea{
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: .2s ease;
}

textarea{
  min-height: 170px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus{
  border-color: #9fc0ff;
  box-shadow: 0 0 0 4px rgba(47,111,237,.10);
}

.buttons{
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  color: #fff;
  padding: 11px 16px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.btn.secondary{
  background: #eff4fb;
  color: var(--text);
  border: 1px solid var(--line);
}

.btn:hover{
  filter: brightness(.98);
}

/* Text helpers */
.note,
.subnote,
.muted{
  color: var(--text-soft);
}

.ok{
  color: var(--success);
  font-weight: 700;
}

.warn{
  color: var(--warning);
  font-weight: 700;
}

.danger{
  color: var(--danger);
  font-weight: 700;
}

/* Alerts */
.alert{
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 14px;
  font-size: 14px;
}

.alert.info{
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.alert.error,
.error-box{
  background: var(--danger-soft);
  border: 1px solid #fecaca;
}

.success-box{
  background: var(--success-soft);
  border: 1px solid #bbf7d0;
}

/* Badges */
.badge,
.pill{
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: #edf4ff;
  color: #1d4ed8;
  border: 1px solid #d7e5ff;
  font-size: 12px;
  font-weight: 700;
  margin: 3px 4px 3px 0;
}

.pill.gray{
  background: #f1f5f9;
  color: #64748b;
  border-color: #e2e8f0;
}

/* Tables */
.table-wrap{
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

table{
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

thead th{
  background: #eef4fb;
  color: #1f4a7c;
  text-align: left;
  font-weight: 800;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

tbody td{
  padding: 11px 12px;
  border-bottom: 1px solid #edf2f7;
  vertical-align: top;
}

tbody tr:hover{
  background: #f8fbff;
}

.cell-code code{
  color: #133b6b;
  white-space: pre-wrap;
  word-break: break-word;
}

.cell-desc{
  color: #2b4669;
  min-width: 320px;
}

.parsed-fields-wrap{
  overflow-x: auto;
}

.parsed-fields-table{
  min-width: 1100px;
}

.parsed-fields-table .w-no{ width: 70px; }
.parsed-fields-table .w-field{ width: 260px; }
.parsed-fields-table .w-mo{ width: 90px; }
.parsed-fields-table .w-data{ width: 260px; }
.parsed-fields-table .w-desc{ width: 420px; }

/* Code / raw blocks */
pre.raw,
.printer-box,
.screen-text,
.raw-soft,
.screen-preview-box,
.state-raw-box{
  white-space: pre-wrap;
  word-break: break-word;
}

pre.raw,
.raw-soft{
  margin: 0;
  padding: 14px;
  background: #f7faff;
  color: #183153;
  border: 1px solid #dce8f7;
  border-radius: 14px;
}

.printer-box{
  background: #fbfdff;
  border: 1px dashed #d6e2f0;
  border-radius: 14px;
  padding: 14px;
}

.printer-line{
  padding: 7px 0;
  border-bottom: 1px dashed #e6edf5;
}

.printer-line:last-child{
  border-bottom: none;
}

.screen-preview-box{
  padding: 12px 14px;
  background: linear-gradient(180deg, #f8fbff 0%, #f2f7ff 100%);
  border: 1px solid #dbe7f5;
  border-radius: 12px;
  color: #183153;
  font-family: Consolas, "Courier New", monospace;
}

.state-raw-box{
  margin: 0;
  padding: 14px;
  background: #fbfdff;
  border: 1px solid #dbe5f0;
  border-radius: 12px;
  color: #26415f;
}

/* Details block */
.details{
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  margin-bottom: 12px;
}

.details summary{
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  background: #f8fbff;
  font-weight: 700;
  color: var(--text);
  border-bottom: 1px solid transparent;
}

.details[open] summary{
  border-bottom-color: var(--line);
}

.details-body{
  padding: 16px;
  border-top: 1px solid var(--line);
}

/* Screen area */
.screen-search{
  max-width: 420px;
}

.screen-counter{
  margin-top: 8px;
  color: var(--text-soft);
  font-size: 13px;
}

.screen-layout{
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 16px;
}

.screen-block{
  background: #fcfdff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}

.screen-meta{
  margin-bottom: 10px;
}

.ndc-wrap{
  overflow: auto;
  border: 1px solid #d7e3f1;
  border-radius: 12px;
  background: #fff;
}

.ndc-grid{
  border-collapse: collapse;
  font-family: Consolas, monospace;
  font-size: 12px;
}

.ndc-grid th,
.ndc-grid td{
  border: 1px solid #e5edf7;
  padding: 6px 8px;
  text-align: center;
}

.ndc-grid thead th{
  background: #edf4ff;
}

.ndc-grid .corner,
.ndc-grid .row-h{
  background: #f3f7fc;
  font-weight: 700;
}

.ndc-grid td.blank{
  color: #c0cad8;
}

/* Section spacing helpers */
.section-title{
  margin-bottom: 12px;
}

.block-title{
  margin: 18px 0 10px;
  color: var(--heading);
}

.inline-spacer-top{
  margin-top: 12px;
}

/* Login */
.login-page{
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, #dbeafe 0%, transparent 35%),
    radial-gradient(circle at bottom right, #e0f2fe 0%, transparent 32%),
    linear-gradient(180deg, #f8fbff 0%, #f1f6fc 100%);
}

.login-card{
  width: 100%;
  max-width: 420px;
  background: rgba(255,255,255,.93);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, .10);
}

.login-card h1{
  margin-bottom: 8px;
  color: var(--primary-2);
}

/* Responsive */
@media (max-width: 1100px){
  .grid-4{
    grid-template-columns: repeat(2, minmax(0,1fr));
  }

  .screen-layout{
    grid-template-columns: 1fr;
  }
}

@media (max-width: 840px){
  .layout{
    grid-template-columns: 1fr;
  }

  .sidebar{
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .topbar{
    padding: 14px 18px;
  }

  .content{
    padding: 18px;
  }

  .grid-2,
  .grid-4{
    grid-template-columns: 1fr;
  }

  .kv-grid{
    grid-template-columns: 1fr;
  }

  .parsed-fields-table{
    min-width: 920px;
  }
}
.login-duration {
  margin-bottom: 12px;
  color: #64748b;
}

.online-users {
  margin: 12px 0 16px;
  padding: 12px;
  border: 1px solid #dbe4f0;
  border-radius: 12px;
  background: #f8fbff;
}

.online-users-title {
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 10px;
}

.online-users-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.online-user-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
  flex: 0 0 10px;
}

.online-user-name {
  font-weight: 600;
  color: #0f172a;
}

.online-users-empty {
  color: #64748b;
  font-size: 13px;
} 