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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #f0f2f5;
  min-height: 100vh;
}

body.page-login {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Top Bar */
.top-bar {
  background: #2c3e50;
  color: #fff;
  padding: 0 20px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.top-bar .session-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 600;
}

.top-bar .session-info .badge-admin {
  background: #e74c3c;
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
}

.top-bar .top-bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-bar .btn-nav {
  color: #fff;
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 13px;
  transition: background 0.2s;
}

.top-bar .btn-nav:hover {
  background: rgba(255,255,255,0.1);
}

.top-bar .btn-logout {
  background: none;
  border: 1px solid rgba(255,255,255,0.4);
  color: #fff;
  padding: 6px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.2s;
}

.top-bar .btn-logout:hover {
  background: rgba(255,255,255,0.1);
}

/* Login Page */
.login-container {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  padding: 40px;
  width: 100%;
  max-width: 400px;
}

.login-container h1 {
  text-align: center;
  margin-bottom: 30px;
  color: #333;
  font-size: 24px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  color: #555;
  font-size: 14px;
  font-weight: 600;
}

.form-group input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: #4a90d9;
}

.btn {
  padding: 10px 20px;
  background: #4a90d9;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn:hover {
  background: #357abd;
}

.btn-login {
  width: 100%;
  padding: 12px;
  font-size: 16px;
}

.error-msg {
  color: #e74c3c;
  font-size: 13px;
  text-align: center;
  margin-bottom: 15px;
  min-height: 20px;
}

/* Content Area */
.content {
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

/* Panel */
.panel {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  padding: 24px;
  margin-bottom: 20px;
}

.panel h2 {
  font-size: 18px;
  color: #333;
  margin-bottom: 16px;
  border-bottom: 1px solid #eee;
  padding-bottom: 10px;
}

/* Inline Form */
.inline-form {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.inline-form input {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

.inline-form input:focus {
  outline: none;
  border-color: #4a90d9;
}

.inline-form .btn {
  padding: 8px 16px;
  font-size: 13px;
}

.inline-form label {
  font-size: 13px;
  color: #555;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid #eee;
  font-size: 14px;
}

.data-table th {
  background: #f8f9fa;
  color: #555;
  font-weight: 600;
}

.data-table tr:hover {
  background: #f8f9fa;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-danger {
  background: #e74c3c;
}

.btn-danger:hover {
  background: #c0392b;
}

.btn-gen {
  background: #6c757d;
  padding: 8px 12px;
  font-size: 12px;
}

.btn-gen:hover {
  background: #5a6268;
}

.badge-locked {
  background: #e74c3c;
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  margin-left: 4px;
}

.btn-info {
  background: #17a2b8;
}

.btn-info:hover {
  background: #138496;
}

/* Machine Panel */
.machine-panel {
  background: #f8f9fa;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 16px;
  margin-top: 16px;
}

.machine-panel h3 {
  font-size: 15px;
  color: #333;
  margin-bottom: 12px;
}

.machine-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.machine-tag {
  background: #e9ecef;
  border: 1px solid #ced4da;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.machine-tag .remove-btn {
  background: none;
  border: none;
  color: #e74c3c;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  line-height: 1;
}

.machine-tag .remove-btn:hover {
  color: #c0392b;
}

.pw-mask {
  font-family: monospace;
  letter-spacing: 1px;
}

.btn-eye {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  vertical-align: middle;
  padding: 0 2px;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.btn-eye:hover {
  opacity: 1;
}

.status-ok {
  color: #28a745;
  font-weight: 600;
}

.status-err {
  color: #e74c3c;
  font-weight: 600;
}

.status-detail {
  color: #888;
  font-size: 13px;
  font-weight: normal;
}

.machine-online {
  background: #d4edda;
  border: 2px solid #28a745;
}

.online-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  background: #28a745;
  border-radius: 50%;
  margin-right: 4px;
}

.on-label {
  color: #28a745;
  font-weight: 700;
  margin-left: 4px;
}

.machine-offline {
  background: #fde8e8;
  border: 2px solid #e74c3c;
}

.offline-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  background: #e74c3c;
  border-radius: 50%;
  margin-right: 4px;
}

.off-label {
  color: #e74c3c;
  font-weight: 700;
  margin-left: 4px;
}

.msg {
  font-size: 13px;
  margin-top: 8px;
}

.msg-success { color: #28a745; }
.msg-error { color: #e74c3c; }

/* Filter Bar */
.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-bar label {
  font-size: 13px;
  color: #555;
  font-weight: 600;
}

.filter-bar input[type="datetime-local"] {
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 18px;
  font-weight: 600;
}

.filter-bar input:focus {
  outline: none;
  border-color: #4a90d9;
}

.filter-sep {
  font-size: 16px;
  color: #999;
  padding-bottom: 2px;
}

/* Report Table */
.table-wrap {
  overflow-x: auto;
}

.report-table {
  table-layout: fixed;
  width: 100%;
}

.report-table col.col-location { width: 9%; }
.report-table col.col-machine  { width: 7%; }
.report-table col.col-num      { width: 11%; }
.report-table col.col-num-sm   { width: 10%; }
.report-table col.col-rtp      { width: 5%; }
.report-table col.col-detail   { width: 6%; }

.report-table th,
.report-table td {
  font-size: 13px;
  padding: 8px 6px;
  border-right: 1px solid #ddd;
}

.report-table th:last-child,
.report-table td:last-child {
  border-right: none;
}

.report-table th {
  white-space: normal;
  word-break: keep-all;
}

.report-table th {
  background: #3b5998;
  color: #fff;
  text-align: center;
}

.report-table td.num {
  text-align: right;
}

.report-table td.center {
  text-align: center;
}

.report-table col.col-highlight {
  background: #d6e4f0;
}

.report-table .subtotal-row {
  background: #d6e4f0;
  font-weight: 600;
}

.report-table .subtotal-row:hover {
  background: #c8dae8;
}

.report-table .grand-total-row {
  background: #3b5998;
  color: #fff;
  font-weight: 700;
}

.report-table .grand-total-row:hover {
  background: #344e86;
}

/* Event Detail Modal */
body.event-detail-open {
  overflow: hidden;
}

.event-detail-modal[hidden] {
  display: none;
}

.event-detail-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(20, 30, 40, 0.65);
}

.event-detail-window {
  display: flex;
  flex-direction: column;
  width: min(900px, 100%);
  max-height: 90vh;
  overflow: hidden;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

.event-detail-header,
.event-detail-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
}

.event-detail-header {
  border-bottom: 1px solid #e5e7eb;
}

.event-detail-header h2 {
  margin: 0;
  color: #2c3e50;
  font-size: 20px;
}

.event-detail-close {
  border: 0;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  font-size: 28px;
  line-height: 1;
}

.event-detail-body {
  min-height: 180px;
  padding: 20px;
  overflow: auto;
}

.event-detail-context {
  margin-bottom: 12px;
  color: #555;
  font-size: 13px;
}

.event-detail-table {
  min-width: 640px;
}

.event-detail-table th:first-child,
.event-detail-table td:first-child {
  width: 30%;
}

.event-detail-table td:first-child {
  text-align: left;
}

.event-detail-table td.num {
  text-align: right;
}

.event-detail-message {
  padding: 24px !important;
  color: #777;
  text-align: center !important;
}

.event-detail-error {
  color: #e74c3c;
}

.event-detail-footer {
  justify-content: flex-end;
  border-top: 1px solid #e5e7eb;
}
