* { box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  margin: 0;
  background: #0f1420;
  color: #e6e9f0;
}

/* Login */
.login-body { display:flex; align-items:center; justify-content:center; min-height:100vh; }
.login-box {
  background: #1a2233; padding: 32px 28px; border-radius: 12px;
  width: 100%; max-width: 340px; box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.login-box h1 { margin: 0 0 4px; font-size: 22px; color: #7fd4ff; }
.subtitle { margin: 0 0 20px; color: #9aa4b8; font-size: 14px; }
.login-box label { display:block; margin: 12px 0 4px; font-size: 13px; color: #b7c0d4; }
.login-box input {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid #2c374d;
  background: #10151f; color: #fff; font-size: 15px;
}
.login-box button {
  margin-top: 20px; width: 100%; padding: 11px; border: none; border-radius: 8px;
  background: #3b82f6; color: #fff; font-size: 15px; font-weight: 600; cursor: pointer;
}
.login-box button:hover { background: #2563eb; }
.flash { padding: 8px 10px; border-radius: 6px; margin-bottom: 8px; font-size: 13px; }
.flash-error { background: #3d1c1c; color: #ff9b9b; }

/* Topbar */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; background: #131a28; border-bottom: 1px solid #232d40;
  flex-wrap: wrap; gap: 8px;
}
.topbar-left { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.topbar h1 { font-size: 18px; margin: 0; color: #7fd4ff; }
.giorno-badge { font-size: 12px; background:#20304a; padding:4px 10px; border-radius: 12px; color:#9dc9ff; }
.topbar-right { display:flex; align-items:center; gap:10px; }
.operatore { font-size: 13px; color: #b7c0d4; }

.btn {
  display:inline-block; padding: 8px 14px; border-radius: 7px; border: none;
  background: #3b82f6; color: #fff; font-size: 13px; cursor: pointer; text-decoration:none;
}
.btn:hover { background: #2563eb; }
.btn-small { padding: 6px 10px; font-size: 12px; }
.btn-secondary { background: #384259; }
.btn-secondary:hover { background: #45516d; }

/* Controls */
.controls {
  display: flex; flex-wrap: wrap; gap: 20px; padding: 14px 16px;
  background: #131a28; border-bottom: 1px solid #232d40;
}
.control-group { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.control-group label { font-size: 12px; color: #9aa4b8; }
.control-group select, .control-group input[type=date] {
  padding: 7px 10px; border-radius: 6px; border: 1px solid #2c374d;
  background: #10151f; color: #fff; font-size: 13px;
}

/* New entry box */
.new-entry-box {
  padding: 16px; background:#161f30; margin: 14px 16px; border-radius: 10px;
  border: 1px solid #3b82f6;
}
.new-entry-box h3 { margin: 0 0 12px; font-size: 15px; color: #9dc9ff; }
.new-entry-box h3 .hint { display:block; font-size: 11px; color: #7a8399; font-weight: 400; margin-top: 4px; }
.entry-form { display: flex; flex-wrap: wrap; gap: 8px; }
.entry-form input {
  flex: 1 1 140px; padding: 9px 10px; border-radius: 6px; border: 1px solid #2c374d;
  background: #10151f; color: #fff; font-size: 13px;
}
.btn-primary-large {
  flex: 1 1 100%; padding: 12px; font-size: 14px; font-weight: 700;
  background: #3b82f6; margin-top: 4px;
}
.btn-primary-large:hover { background: #2563eb; }
.form-msg { font-size: 12px; margin: 8px 0 0; min-height: 16px; }
.form-ok { color: #7fe0a0; }
.form-error { color: #ff9b9b; }

/* Table */
.table-wrapper { padding: 8px 16px 30px; overflow-x: auto; }
.board-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 920px; }
.board-table thead th {
  text-align: left; padding: 10px 8px; color: #9aa4b8; border-bottom: 1px solid #232d40;
  font-size: 11px; text-transform: uppercase; letter-spacing: .03em;
}
.board-table td { padding: 10px 8px; border-bottom: 1px solid #1c2536; vertical-align: top; }
.isin-cell { font-weight: 600; color: #7fd4ff; }
.editable-cell { cursor: pointer; border-radius: 4px; transition: background .15s; }
.editable-cell:hover { background: #1c2c47; outline: 1px dashed #3b82f6; }
.inline-edit-input {
  width: 100%; padding: 5px 6px; border-radius: 4px; border: 1px solid #3b82f6;
  background: #0d1420; color: #fff; font-size: 13px;
}
.inline-edit-textarea { resize: vertical; font-family: inherit; min-height: 40px; }
.meta-cell small { color: #7a8399; }

.section-title {
  margin: 26px 16px 6px; font-size: 15px; color: #9dc9ff; font-weight: 600;
  border-top: 1px solid #232d40; padding-top: 18px;
}
.enquiry-text-cell { max-width: 500px; white-space: pre-wrap; word-break: break-word; }
.empty-msg { text-align:center; color:#6b7488; padding: 24px; }

.storico-content { padding: 10px; background:#0f1522; border-radius: 8px; }
.storico-table { width:100%; border-collapse: collapse; font-size: 12px; }
.storico-table th { text-align:left; color:#9aa4b8; padding: 6px; border-bottom: 1px solid #232d40; }
.storico-table td { padding: 6px; border-bottom: 1px solid #1c2536; }

/* Mobile */
@media (max-width: 600px) {
  .topbar h1 { font-size: 16px; }
  .entry-form input { flex: 1 1 100%; }
  .board-table { min-width: 780px; }
  .chat-panel { width: calc(100vw - 32px); height: 60vh; right: -8px; }
}

/* Chat widget */
.chat-widget { position: fixed; bottom: 20px; right: 20px; z-index: 1000; }
.chat-toggle-btn {
  width: 54px; height: 54px; border-radius: 50%; border: none;
  background: #3b82f6; color: #fff; font-size: 22px; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.4); position: relative;
}
.chat-toggle-btn:hover { background: #2563eb; }
.chat-unread-badge {
  position: absolute; top: -4px; right: -4px; background: #ef4444; color: #fff;
  font-size: 11px; font-weight: 700; border-radius: 10px; padding: 2px 6px; min-width: 18px;
}
.chat-panel {
  position: absolute; bottom: 66px; right: 0; width: 320px; height: 420px;
  background: #131a28; border: 1px solid #2c374d; border-radius: 12px;
  display: flex; flex-direction: column; box-shadow: 0 8px 30px rgba(0,0,0,.5);
  overflow: hidden;
}
.chat-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: #1a2233; font-size: 13px; font-weight: 600; color: #9dc9ff;
  border-bottom: 1px solid #232d40;
}
.chat-close-btn { background: none; border: none; color: #9aa4b8; cursor: pointer; font-size: 14px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.chat-msg { max-width: 85%; background: #1c2536; border-radius: 8px; padding: 6px 10px; align-self: flex-start; }
.chat-msg-mine { align-self: flex-end; background: #24406b; }
.chat-msg-author { font-size: 11px; color: #7fd4ff; margin-bottom: 2px; }
.chat-msg-time { color: #6b7488; font-weight: 400; }
.chat-msg-text { font-size: 13px; color: #e6e9f0; white-space: pre-wrap; word-break: break-word; }
.chat-input-row {
  display: flex; gap: 6px; padding: 10px; border-top: 1px solid #232d40; background: #131a28;
}
.chat-input-row textarea {
  flex: 1; resize: none; padding: 8px 10px; border-radius: 8px; border: 1px solid #2c374d;
  background: #10151f; color: #fff; font-size: 13px; font-family: inherit; max-height: 80px;
}
