/* ===== RESET & BASE ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

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

/* ===== HEADER ===== */
.header {
  background: #112240;
  border-bottom: 2px solid #1d3557;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

.header .logo {
  font-size: 22px;
  font-weight: 700;
  color: #e94560;
  letter-spacing: 2px;
}

.header .user-area {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 12px;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  background: #112240;
  border: 1px solid #1d3557;
  border-radius: 8px;
  padding: 10px;
  min-width: 220px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.header .user-area.open { display: flex; }

.header .user-area span {
  color: #8892b0;
  font-size: 13px;
  padding: 4px 10px 8px;
  border-bottom: 1px solid #1d3557;
  margin-bottom: 4px;
}

.header .user-area .btn {
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  font-size: 13px;
  border-radius: 6px;
}

.menu-section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #e94560;
  padding: 10px 10px 4px;
  margin-top: 4px;
  border-top: 1px solid #1d3557;
}

.menu-divider {
  height: 1px;
  background: #1d3557;
  margin: 6px 4px;
}

/* ===== BUTTONS ===== */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: #e94560;
  color: #fff;
}
.btn-primary:hover { background: #c73652; }

.btn-secondary {
  background: #233554;
  color: #ccd6f6;
}
.btn-secondary:hover { background: #2d4466; }

.btn-danger {
  background: #dc3545;
  color: #fff;
}
.btn-danger:hover { background: #b02a37; }

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

.btn-icon {
  background: none;
  border: none;
  color: #8892b0;
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s;
}
.btn-icon:hover { color: #e94560; background: rgba(233,69,96,0.1); }

/* ===== MAIN CONTENT ===== */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* ===== TOOLBAR ===== */
.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

/* ===== TABS ===== */
.tabs-nav {
  display: flex;
  align-items: flex-end;
  gap: 0;
  border-bottom: 2px solid #1d3557;
  margin-bottom: 0;
}

.tab-btn {
  padding: 10px 20px;
  background: #112240;
  border: 2px solid #1d3557;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  color: #8892b0;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  margin-right: -1px;
  position: relative;
  bottom: -2px;
}

.tab-btn:hover {
  color: #ccd6f6;
  background: #16213e;
}

.tab-btn.active {
  background: #16213e;
  color: #e94560;
  border-color: #e94560;
  border-bottom: 2px solid #16213e;
  font-weight: 700;
}

.tab-btn-add {
  padding: 10px 16px;
  background: transparent;
  border: 2px dashed #233554;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  color: #8892b0;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  bottom: -2px;
}
.tab-btn-add:hover {
  border-color: #e94560;
  color: #e94560;
}

/* ===== TAB CONTENT ===== */
.tab-content {
  background: #16213e;
  border: 2px solid #1d3557;
  border-top: none;
  border-radius: 0 0 8px 8px;
  padding: 24px;
}

.tab-description {
  color: #8892b0;
  font-size: 14px;
  margin-bottom: 16px;
  font-style: italic;
}

.tab-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

/* ===== TABLE ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
}

.data-table th {
  background: #112240;
  color: #e94560;
  padding: 12px 16px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 2px solid #e94560;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #1d3557;
  font-size: 14px;
}

.data-table tbody tr {
  transition: background 0.2s;
}

.data-table tbody tr:hover {
  background: rgba(233, 69, 96, 0.05);
}

.data-table .robot-name {
  color: #64ffda;
  cursor: pointer;
  font-weight: 500;
  transition: color 0.2s;
}
.data-table .robot-name:hover {
  color: #e94560;
  text-decoration: underline;
}

.data-table .number {
  font-family: 'Courier New', monospace;
  font-weight: 600;
}

.data-table .positive { color: #00c853; }
.data-table .negative { color: #e94560; }

/* ===== TOTALS TABLE ===== */
.totals-section {
  margin-top: 20px;
}

.totals-table {
  width: 100%;
  max-width: 700px;
  border-collapse: collapse;
  margin: 0 auto;
}

.totals-table th {
  background: #112240;
  color: #e94560;
  padding: 10px 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 2px solid #e94560;
}

.totals-table td {
  padding: 12px 20px;
  text-align: center;
  font-family: 'Courier New', monospace;
  font-weight: 700;
  font-size: 16px;
  color: #64ffda;
  background: #0d1b33;
  border: 1px solid #1d3557;
}

/* ===== PING STATUS ===== */
.ping-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}
.ping-dot.online { background: #00c853; box-shadow: 0 0 6px #00c853; }
.ping-dot.offline { background: #e94560; box-shadow: 0 0 6px #e94560; }
.ping-dot.stale { background: #ffc107; box-shadow: 0 0 6px #ffc107; }

/* ===== MODAL ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.active { display: flex; }

.modal {
  background: #16213e;
  border: 2px solid #1d3557;
  border-radius: 12px;
  padding: 28px;
  min-width: 420px;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal-wide {
  min-width: 800px;
  width: 80vw;
}

.modal h2 {
  color: #e94560;
  margin-bottom: 20px;
  font-size: 20px;
}

.modal .form-group {
  margin-bottom: 16px;
}

.modal .form-group label {
  display: block;
  color: #8892b0;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
}

.modal .form-group input,
.modal .form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid #233554;
  border-radius: 6px;
  background: #0a192f;
  color: #ccd6f6;
  font-size: 14px;
  outline: none;
  transition: border-color 0.3s;
}

.modal .form-group input:focus,
.modal .form-group textarea:focus {
  border-color: #e94560;
}

.modal .form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ===== CHECKBOX LIST ===== */
.checkbox-list {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid #233554;
  border-radius: 6px;
  padding: 10px;
  background: #0a192f;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-radius: 4px;
  transition: background 0.2s;
}
.checkbox-item:hover { background: #112240; }

.checkbox-item input[type="checkbox"] {
  accent-color: #e94560;
  width: 16px;
  height: 16px;
}

.checkbox-item label {
  color: #ccd6f6;
  font-size: 14px;
  cursor: pointer;
  flex: 1;
}

.checkbox-item .account-id {
  color: #8892b0;
  font-size: 12px;
}

/* ===== ROBOT LIST (admin) ===== */
.robot-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid #1d3557;
}
.robot-list-item:last-child { border-bottom: none; }

.robot-list-item .info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.robot-list-item .info .name { color: #ccd6f6; font-weight: 500; }
.robot-list-item .info .account { color: #8892b0; font-size: 12px; }

/* ===== CHART ===== */
.chart-toggle {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}
.chart-toggle-btn {
  padding: 4px 14px;
  border: 1px solid #1d3557;
  background: transparent;
  color: #8892b0;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: all .15s;
}
.chart-toggle-btn.active {
  background: #1d3557;
  color: #ccd6f6;
  border-color: #64ffda;
}

.chart-container {
  width: 100%;
  height: 450px;
  background: #0a192f;
  border-radius: 8px;
  border: 1px solid #1d3557;
  overflow: hidden;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.chart-header h3 {
  color: #64ffda;
  font-size: 18px;
}

.chart-stats {
  display: flex;
  gap: 20px;
  margin-bottom: 16px;
}

.chart-stat {
  background: #0a192f;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid #1d3557;
}

.chart-stat .label {
  color: #8892b0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.chart-stat .value {
  color: #ccd6f6;
  font-size: 18px;
  font-weight: 700;
  font-family: 'Courier New', monospace;
}

/* ===== PIN KEYPAD ===== */
.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-width: 260px;
  margin: 12px auto;
}

.pin-keypad button {
  padding: 14px;
  font-size: 20px;
  font-weight: 700;
  background: #0a192f;
  border: 2px solid #233554;
  border-radius: 8px;
  color: #ccd6f6;
  cursor: pointer;
  transition: all 0.15s;
}
.pin-keypad button:hover {
  background: #112240;
  border-color: #e94560;
}
.pin-keypad button:active {
  background: #e94560;
  color: #fff;
}

/* ===== BACKUP ===== */
.backup-section {
  padding: 16px;
  background: #0a192f;
  border: 1px solid #1d3557;
  border-radius: 8px;
}

.backup-upload-area {
  border: 2px dashed #233554;
  border-radius: 8px;
  padding: 28px;
  text-align: center;
  color: #8892b0;
  font-size: 14px;
  transition: all 0.2s;
  cursor: pointer;
}
.backup-upload-area:hover,
.backup-upload-area.drag-over {
  border-color: #e94560;
  background: rgba(233, 69, 96, 0.05);
}

/* ===== HAMBURGER MENU ===== */
.menu-toggle {
  display: block;
  background: none;
  border: 2px solid #233554;
  color: #ccd6f6;
  font-size: 22px;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  line-height: 1;
  margin-left: auto;
}
.menu-toggle:hover {
  border-color: #e94560;
  color: #e94560;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 40px;
  color: #8892b0;
}
.empty-state p { font-size: 16px; margin-bottom: 16px; }

/* ===== MIND MAPS PAGE ===== */
.maps-body { overflow: hidden; height: 100vh; }

.maps-layout {
  display: flex;
  height: calc(100vh - 60px);
  background: #0a192f;
}

.maps-sidebar {
  width: 240px;
  background: #112240;
  border-right: 2px solid #1d3557;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.maps-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid #1d3557;
}
.maps-sidebar-header h3 {
  color: #e94560;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.maps-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}

.maps-list-empty {
  padding: 16px 12px;
  color: #8892b0;
  font-size: 12px;
  text-align: center;
}

.map-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 6px;
  margin-bottom: 2px;
  cursor: pointer;
  transition: background 0.15s;
}
.map-list-item:hover { background: #16213e; }
.map-list-item.active {
  background: rgba(233,69,96,0.12);
  border-left: 3px solid #e94560;
}
.map-list-item .map-list-name {
  color: #ccd6f6;
  font-size: 13px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.map-list-item.active .map-list-name { color: #64ffda; font-weight: 600; }

.maps-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}

.maps-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #112240;
  border-bottom: 1px solid #1d3557;
  flex-wrap: wrap;
}

.maps-sidebar-toggle { display: none; }

.maps-title-input {
  background: transparent;
  border: 1px solid transparent;
  color: #64ffda;
  font-size: 16px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 6px;
  outline: none;
  min-width: 200px;
  transition: all 0.15s;
}
.maps-title-input:hover:not(:disabled) { border-color: #233554; }
.maps-title-input:focus { border-color: #e94560; background: #0a192f; }
.maps-title-input:disabled { color: #8892b0; cursor: not-allowed; }

.maps-save-status {
  color: #8892b0;
  font-size: 12px;
  font-style: italic;
  min-width: 80px;
}

.maps-toolbar-spacer { flex: 1; }
.maps-divider {
  width: 1px;
  background: #1d3557;
  align-self: stretch;
  margin: 0 4px;
}

.maps-toolbar-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #ccd6f6;
  cursor: pointer;
  user-select: none;
  padding: 4px 6px;
}
.maps-toolbar-toggle input { accent-color: #64ffda; cursor: pointer; }

.maps-canvas-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 1px 1px, rgba(35,53,84,0.6) 1px, transparent 0) 0 0 / 28px 28px,
    #0a192f;
  cursor: default;
}

.maps-viewport {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  transform-origin: 0 0;
}

.maps-edges {
  position: absolute;
  pointer-events: none;
  overflow: visible;
}

.maps-guides {
  position: absolute;
  pointer-events: none;
  overflow: visible;
  z-index: 3;
}
.maps-guides line { stroke: #ff7849; stroke-width: 1; stroke-dasharray: 5 4; }

.maps-nodes {
  position: absolute;
  left: 0;
  top: 0;
}

.mm-node {
  position: absolute;
  background: #16213e;
  border: 2px solid #e94560;
  border-radius: 999px;
  padding: 12px 22px;
  color: #ccd6f6;
  font-size: 14px;
  font-weight: 500;
  cursor: default;
  user-select: none;
  width: max-content;
  max-width: 380px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  transition: box-shadow 0.15s, transform 0.05s;
}
.mm-node:hover { box-shadow: 0 6px 18px rgba(0,0,0,0.5); }
.mm-node.selected {
  box-shadow: 0 0 0 3px rgba(100,255,218,0.4), 0 6px 18px rgba(0,0,0,0.5);
}
.mm-node.editing { cursor: text; }

.mm-node.mm-root {
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  padding: 12px 22px;
  border-radius: 28px;
}

.mm-node-text {
  outline: none;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  min-width: 40px;
}
.mm-node.editing .mm-node-text {
  background: rgba(10,25,47,0.6);
  border-radius: 6px;
  padding: 2px 6px;
}

.maps-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #8892b0;
  font-size: 16px;
  pointer-events: none;
}

/* ===== NODE INNER UI ===== */
.mm-side-btn {
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #3a86ff;
  color: #fff;
  border: 2px solid #16213e;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  /* always hit-testable: when cursor reaches the (invisible) button it triggers
     parent hover, fading the button in. Combined with no-gap positioning, the
     cursor can travel from node → button without losing the hover state. */
  pointer-events: auto;
  transition: opacity 0.15s, transform 0.15s, background 0.15s;
  z-index: 2;
}
.mm-node:hover .mm-side-btn,
.mm-node.selected .mm-side-btn {
  opacity: 1;
}
.mm-side-btn:hover {
  background: #e94560;
  transform: scale(1.1);
}
/* No gap: button left/top edge touches node edge so hover stays continuous. */
.mm-add-child {
  right: -22px;
  top: 50%;
  margin-top: -11px;
}
.mm-add-sibling {
  bottom: -22px;
  left: 50%;
  margin-left: -11px;
}

/* SVG collapse dot */
.maps-edges .mm-collapse-dot { transition: r 0.15s, stroke-width 0.15s; }
.maps-edges .mm-collapse-dot:hover { stroke-width: 3; }

/* Box-select rectangle */
.maps-selection-box {
  position: absolute;
  border: 1px dashed #64ffda;
  background: rgba(100,255,218,0.08);
  pointer-events: none;
  display: none;
  z-index: 50;
  border-radius: 2px;
}

/* link mode cursor */
.maps-canvas-wrap.link-mode { cursor: crosshair; }
.maps-canvas-wrap.link-mode .mm-node { cursor: crosshair; }
#btnLinkMode.active { background: #e94560; color: #fff; }

/* connection line hover */
.maps-edges path.mm-link { cursor: pointer; transition: stroke-width 0.15s; }
.maps-edges path.mm-link:hover { stroke-width: 4; }

.maps-help {
  position: absolute;
  right: 12px;
  bottom: 12px;
  background: rgba(17,34,64,0.92);
  border: 1px solid #1d3557;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 11px;
  color: #8892b0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  pointer-events: none;
}
.maps-help strong { color: #e94560; font-size: 11px; margin-bottom: 4px; }
.maps-help kbd {
  background: #0a192f;
  border: 1px solid #233554;
  border-radius: 3px;
  padding: 1px 5px;
  color: #64ffda;
  font-family: 'Courier New', monospace;
  font-size: 10px;
  margin-right: 4px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  /* Prevent horizontal scroll on page */
  html, body { overflow-x: hidden; width: 100%; }

  .header { padding: 10px 12px; }
  .header .logo img { height: 28px !important; }

  /* Menu drops down full-width on small screens */
  .header .user-area {
    right: 8px;
    left: 8px;
    min-width: 0;
  }

  /* Main */
  .main { padding: 8px; }

  /* Tabs */
  .tabs-nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs-nav::-webkit-scrollbar { display: none; }
  .tab-btn { padding: 7px 10px; font-size: 11px; white-space: nowrap; }
  .tab-btn-add { padding: 7px 12px; font-size: 15px; }

  /* Tab content */
  .tab-content { padding: 10px; }
  .tab-actions { flex-wrap: wrap; gap: 6px; }

  /* Table: fixed layout forces columns to fit */
  .data-table { table-layout: fixed; width: 100%; }
  .data-table th {
    padding: 6px 3px;
    font-size: 9px;
    letter-spacing: 0;
  }
  .data-table td {
    padding: 6px 3px;
    font-size: 10px;
  }
  .data-table .number {
    font-family: inherit;
    font-size: 10px;
  }
  .data-table .robot-name {
    display: inline-block;
    max-width: 64px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
  }

  /* Totals */
  .totals-table { max-width: 100%; }
  .totals-table th { padding: 6px 4px; font-size: 9px; letter-spacing: 0; }
  .totals-table td { padding: 8px 4px; font-size: 12px; }

  /* Modals */
  .modal { min-width: auto; width: 95vw; padding: 16px; }
  .modal-wide { min-width: auto; width: 95vw; }

  /* Chart */
  .chart-container { height: 280px; }
  .chart-stats { flex-wrap: wrap; gap: 6px; }
  .chart-stat { padding: 8px 10px; }
  .chart-stat .value { font-size: 14px; }

  /* Maps */
  .maps-sidebar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 220px;
    transform: translateX(-100%);
    transition: transform 0.2s;
    z-index: 50;
  }
  .maps-sidebar.open { transform: translateX(0); }
  .maps-sidebar-toggle { display: block; }
  .maps-toolbar { padding: 8px 10px; gap: 6px; }
  .maps-title-input { font-size: 14px; min-width: 100px; flex: 1; }
  .maps-save-status { display: none; }
  .maps-help { display: none; }
  .mm-node { font-size: 13px; padding: 6px 12px; }
  .mm-node.mm-root { font-size: 15px; padding: 10px 18px; }
}

/* =========================================================
   KEEP - uses system palette (navy/cyan/red)
   #0a192f bg / #112240 panels / #1d3557 borders
   #ccd6f6 text / #8892b0 muted
   #e94560 brand red / #64ffda accent cyan
   ========================================================= */
.keep-body {
  background: #0a192f;
  color: #ccd6f6;
  min-height: 100vh;
  overflow-x: hidden;
}

.keep-layout {
  display: flex;
  min-height: calc(100vh - 65px);
}

/* SIDEBAR */
.keep-sidebar {
  width: 80px;
  padding-top: 12px;
  background: #112240;
  border-right: 1px solid #1d3557;
  flex-shrink: 0;
  transition: width 0.2s;
}
.keep-sidebar:hover { width: 260px; }
.keep-side-item {
  display: flex;
  align-items: center;
  gap: 18px;
  width: 100%;
  height: 46px;
  padding: 0 26px;
  border: none;
  background: none;
  color: #ccd6f6;
  cursor: pointer;
  border-top-right-radius: 23px;
  border-bottom-right-radius: 23px;
  font-size: 14px;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  overflow: hidden;
}
.keep-side-item:hover { background: #1d3557; }
.keep-side-item.active {
  background: rgba(233,69,96,0.15);
  color: #e94560;
}
.keep-side-icon {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.keep-side-label { opacity: 0; transition: opacity 0.2s; }
.keep-sidebar:hover .keep-side-label { opacity: 1; }

/* MAIN */
.keep-main {
  flex: 1;
  padding: 24px 24px 80px;
  max-width: 100%;
  overflow-x: hidden;
}

/* SEARCH */
.keep-search-bar {
  max-width: 600px;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #112240;
  border: 2px solid #233554;
  border-radius: 8px;
  padding: 8px 14px;
  height: 44px;
  transition: border-color 0.15s;
}
.keep-search-bar:focus-within { border-color: #e94560; }
.keep-search-icon { color: #8892b0; display: flex; align-items: center; }
.keep-search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: #ccd6f6;
  font-size: 14px;
  font-family: inherit;
}
.keep-search-input::placeholder { color: #8892b0; }
.keep-search-clear {
  background: none;
  border: none;
  color: #8892b0;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  padding: 0 4px;
}
.keep-search-clear:hover { color: #e94560; }

/* ICON BUTTONS */
.keep-icon-btn {
  background: none;
  border: none;
  color: #ccd6f6;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.keep-icon-btn:hover { background: #1d3557; color: #64ffda; }
.keep-icon-btn.active { color: #e94560; }

/* TAKE A NOTE */
.keep-takenote-wrap {
  max-width: 600px;
  margin: 0 auto 24px;
}
.keep-takenote {
  background: #112240;
  border: 2px solid #233554;
  border-radius: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.keep-takenote:hover { border-color: #1d3557; box-shadow: 0 4px 12px rgba(0,0,0,0.4); }
.keep-takenote-collapsed {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  cursor: text;
}
.keep-takenote-placeholder {
  flex: 1;
  font-size: 15px;
  color: #8892b0;
  font-weight: 500;
}
.keep-takenote-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.keep-takenote-expanded {
  padding: 12px 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.keep-note-title-input {
  border: none;
  outline: none;
  background: transparent;
  color: #ccd6f6;
  font-size: 16px;
  font-weight: 600;
  padding: 8px 0;
  width: 100%;
  font-family: inherit;
}
.keep-note-content-input {
  border: none;
  outline: none;
  background: transparent;
  color: #ccd6f6;
  font-size: 14px;
  padding: 4px 0;
  width: 100%;
  resize: none;
  font-family: inherit;
  line-height: 1.5;
  min-height: 24px;
}
.keep-note-title-input::placeholder,
.keep-note-content-input::placeholder { color: #8892b0; }

.keep-note-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.keep-toolbar-spacer { flex: 1; }

/* COLOR PICKER POPUP */
.keep-color-picker { position: relative; }
.keep-color-palette {
  position: absolute;
  bottom: 42px;
  left: 0;
  background: #112240;
  border: 1px solid #1d3557;
  border-radius: 8px;
  padding: 8px;
  display: none;
  grid-template-columns: repeat(6, 28px);
  gap: 4px;
  z-index: 60;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
.keep-color-palette.open { display: grid; }
.keep-color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #233554;
  cursor: pointer;
  position: relative;
  transition: transform 0.1s, border-color 0.1s;
}
.keep-color-swatch:hover { transform: scale(1.1); border-color: #64ffda; }
.keep-color-swatch.selected { border-color: #e94560; border-width: 2px; }
.keep-color-swatch.selected::after {
  content: '';
  position: absolute;
  top: 6px; left: 9px;
  width: 6px; height: 10px;
  border: solid #e94560;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* NOTE COLORS - dark navy variants tinted with palette accents */
.keep-c-default   { background: #112240; border-color: #233554; }
.keep-c-red       { background: #3a1a25; border-color: #5a2335; }
.keep-c-orange    { background: #3a2818; border-color: #5a3a22; }
.keep-c-yellow    { background: #3a3318; border-color: #5a4a22; }
.keep-c-green     { background: #143a2a; border-color: #1f5a40; }
.keep-c-teal      { background: #0e3a3a; border-color: #1a5a5a; }
.keep-c-blue      { background: #15304d; border-color: #234d72; }
.keep-c-darkblue  { background: #1a2950; border-color: #2a3a70; }
.keep-c-purple    { background: #2a1a3d; border-color: #432a5a; }
.keep-c-pink      { background: #3a1a30; border-color: #5a2348; }
.keep-c-brown     { background: #2e2218; border-color: #4a3622; }
.keep-c-gray      { background: #1d2533; border-color: #2d3a4d; }

.keep-swatch-default  { background: #112240; border-color: #233554 !important; }
.keep-swatch-red      { background: #5a2335; }
.keep-swatch-orange   { background: #5a3a22; }
.keep-swatch-yellow   { background: #5a4a22; }
.keep-swatch-green    { background: #1f5a40; }
.keep-swatch-teal     { background: #1a5a5a; }
.keep-swatch-blue     { background: #234d72; }
.keep-swatch-darkblue { background: #2a3a70; }
.keep-swatch-purple   { background: #432a5a; }
.keep-swatch-pink     { background: #5a2348; }
.keep-swatch-brown    { background: #4a3622; }
.keep-swatch-gray     { background: #2d3a4d; }

/* CHECKLIST INSIDE NOTE */
.keep-note-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 0;
}
.keep-list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}
.keep-list-item input[type=checkbox] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #e94560;
  flex-shrink: 0;
}
.keep-list-item input[type=text] {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: #ccd6f6;
  font-size: 14px;
  font-family: inherit;
  padding: 2px 0;
}
.keep-list-item.done input[type=text] {
  text-decoration: line-through;
  opacity: 0.55;
}
.keep-list-item .keep-li-remove {
  background: none;
  border: none;
  color: #8892b0;
  cursor: pointer;
  font-size: 18px;
  padding: 0 4px;
  visibility: hidden;
}
.keep-list-item .keep-li-remove:hover { color: #e94560; }
.keep-list-item:hover .keep-li-remove { visibility: visible; }
.keep-list-additem {
  background: none;
  border: none;
  color: #8892b0;
  cursor: pointer;
  font-size: 13px;
  padding: 6px 0;
  text-align: left;
  font-family: inherit;
}
.keep-list-additem:hover { color: #64ffda; }

/* SECTION TITLES */
.keep-section-title {
  max-width: 1400px;
  margin: 8px auto 12px;
  padding: 0 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #8892b0;
}

/* GRID */
.keep-grid {
  max-width: 1400px;
  margin: 0 auto 28px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  align-items: start;
}

/* NOTE CARD */
.keep-note-card {
  border: 2px solid #233554;
  border-radius: 8px;
  padding: 12px 14px;
  position: relative;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
  display: flex;
  flex-direction: column;
  gap: 6px;
  word-wrap: break-word;
  overflow: hidden;
}
.keep-note-card:hover {
  border-color: #e94560;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
.keep-note-card .keep-card-pin {
  position: absolute;
  top: 6px;
  right: 6px;
  background: none;
  border: none;
  color: #ccd6f6;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.keep-note-card:hover .keep-card-pin { opacity: 1; }
.keep-note-card .keep-card-pin.pinned { opacity: 1; color: #e94560; }
.keep-note-card .keep-card-pin:hover { background: rgba(100,255,218,0.1); color: #64ffda; }

.keep-card-title {
  font-size: 15px;
  font-weight: 600;
  color: #ccd6f6;
  padding-right: 32px;
  word-break: break-word;
  white-space: pre-wrap;
}
.keep-card-content {
  font-size: 13.5px;
  color: #ccd6f6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 360px;
  overflow-y: auto;
  overscroll-behavior: contain;
  line-height: 1.5;
}

.keep-card-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 360px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Custom scrollbar matching the system theme */
.keep-card-content::-webkit-scrollbar,
.keep-card-list::-webkit-scrollbar,
.keep-edit-modal::-webkit-scrollbar,
.keep-note-content-input::-webkit-scrollbar {
  width: 8px;
}
.keep-card-content::-webkit-scrollbar-track,
.keep-card-list::-webkit-scrollbar-track,
.keep-edit-modal::-webkit-scrollbar-track,
.keep-note-content-input::-webkit-scrollbar-track {
  background: transparent;
}
.keep-card-content::-webkit-scrollbar-thumb,
.keep-card-list::-webkit-scrollbar-thumb,
.keep-edit-modal::-webkit-scrollbar-thumb,
.keep-note-content-input::-webkit-scrollbar-thumb {
  background: #233554;
  border-radius: 4px;
}
.keep-card-content::-webkit-scrollbar-thumb:hover,
.keep-card-list::-webkit-scrollbar-thumb:hover,
.keep-edit-modal::-webkit-scrollbar-thumb:hover,
.keep-note-content-input::-webkit-scrollbar-thumb:hover {
  background: #e94560;
}
.keep-card-content,
.keep-card-list,
.keep-edit-modal,
.keep-note-content-input {
  scrollbar-width: thin;
  scrollbar-color: #233554 transparent;
}
.keep-card-list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: #ccd6f6;
}
.keep-card-list-item.done { opacity: 0.55; text-decoration: line-through; }
.keep-card-list-item .keep-card-check {
  width: 14px;
  height: 14px;
  border: 1.5px solid #8892b0;
  border-radius: 3px;
  flex-shrink: 0;
  position: relative;
}
.keep-card-list-item.done .keep-card-check { background: #e94560; border-color: #e94560; }
.keep-card-list-item.done .keep-card-check::after {
  content: '';
  position: absolute;
  top: 0; left: 3px;
  width: 4px; height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.keep-card-actions {
  display: flex;
  align-items: center;
  gap: 0;
  margin-top: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
.keep-note-card:hover .keep-card-actions { opacity: 1; }
.keep-card-actions .keep-icon-btn {
  width: 30px;
  height: 30px;
  padding: 5px;
}
.keep-card-actions .keep-icon-btn svg { width: 16px; height: 16px; }

/* EMPTY STATE */
.keep-empty {
  text-align: center;
  margin-top: 80px;
  color: #8892b0;
}
.keep-empty-icon {
  font-size: 88px;
  margin-bottom: 12px;
  opacity: 0.5;
}
.keep-empty-text {
  font-size: 18px;
  color: #8892b0;
  font-weight: 300;
}

/* EDIT MODAL */
.keep-modal-overlay {
  background: rgba(10, 25, 47, 0.85);
}
.keep-edit-modal {
  background: #112240;
  border: 2px solid #233554;
  border-radius: 8px;
  width: 90%;
  max-width: 720px;
  height: 85vh;
  max-height: 92vh;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}
.keep-edit-modal .keep-note-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
}
.keep-edit-modal .keep-note-content-input {
  flex: 1;
  min-height: 200px;
  max-height: none;
}
.keep-edit-modal .keep-note-toolbar { flex-shrink: 0; }

/* MOBILE */
@media (max-width: 768px) {
  .keep-sidebar {
    position: fixed;
    top: 65px;
    left: 0;
    bottom: 0;
    width: 0;
    overflow: hidden;
    z-index: 70;
    background: #112240;
  }
  .keep-sidebar.open { width: 220px; border-right: 1px solid #1d3557; }
  .keep-sidebar:hover { width: 0; }
  .keep-sidebar.open:hover { width: 220px; }
  .keep-side-label { opacity: 1; }
  .keep-main { padding: 16px 12px 60px; }
  .keep-search-bar { padding: 6px 10px; height: 40px; }
  .keep-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
  }
  .keep-note-card { padding: 10px 12px; }
  .keep-card-title { font-size: 14px; }
  .keep-card-content { font-size: 13px; max-height: 240px; }
  .keep-takenote-wrap { margin-bottom: 16px; }
  .keep-edit-modal { padding: 12px 14px; }
}

