* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #f0f2f5; color: #1a1a1a; }

header { background: #1e3a5f; color: white; padding: 16px 24px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 10; }
header h1 { font-size: 18px; font-weight: 600; }
.header-btn { background: #2563eb; color: white; border: none; padding: 8px 16px; border-radius: 8px; font-size: 14px; cursor: pointer; }
.header-btn:hover { background: #1d4ed8; }

.container { padding: 20px 24px 20px; height: calc(100vh - 120px); overflow-y: auto; box-sizing: border-box; }

table { width: 100%; border-collapse: collapse; background: white; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,0.1); table-layout: fixed; }
th { background: #1e3a5f; color: white; padding: 12px 14px; text-align: left; font-size: 13px; font-weight: 600; }
td { padding: 10px 14px; border-bottom: 1px solid #e8eaed; font-size: 13px; vertical-align: middle; overflow: hidden; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8f9ff; }

.client-cell { font-weight: 700; font-size: 13px; color: #1e3a5f; background: #f0f4ff !important; border-right: 3px solid #2563eb; width: 120px; }
.note-cell { background: #f0f4ff !important; color: #444; font-size: 13px; width: 200px; }
.note-inner { max-height: 80px; overflow-y: auto; }

a { color: #2563eb; text-decoration: none; font-size: 12px; }
a:hover { text-decoration: underline; }

.client-actions { display: flex; flex-wrap: nowrap; gap: 6px; align-items: center; white-space: nowrap; }
.btn { border: none; padding: 5px 10px; border-radius: 6px; font-size: 12px; cursor: pointer; white-space: nowrap; }
.btn-add { background: #f0fdf4; color: #16a34a; }
.btn-add:hover { background: #dcfce7; }
.btn-edit { background: #eff6ff; color: #2563eb; font-size: 14px; padding: 5px 8px; }
.btn-edit:hover { background: #dbeafe; }
.btn-del { background: #fef2f2; color: #dc2626; font-size: 14px; padding: 5px 8px; }
.btn-del:hover { background: #fee2e2; }

/* Modal */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 100; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: white; border-radius: 12px; padding: 28px; width: 520px; max-width: 95vw; box-shadow: 0 8px 32px rgba(0,0,0,0.2); }
.modal h3 { margin-bottom: 20px; font-size: 16px; color: #1e3a5f; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: #555; margin-bottom: 4px; text-transform: uppercase; }
.field input, .field textarea, .field select { width: 100%; padding: 8px 12px; border: 1px solid #ddd; border-radius: 8px; font-size: 14px; font-family: inherit; outline: none; }
.field input:focus, .field textarea:focus { border-color: #2563eb; }
.field textarea { resize: vertical; min-height: 80px; }
.modal-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
.btn-save { background: #2563eb; color: white; border: none; padding: 9px 20px; border-radius: 8px; font-size: 14px; cursor: pointer; }
.btn-save:hover { background: #1d4ed8; }
.btn-cancel { background: #f3f4f6; color: #333; border: none; padding: 9px 20px; border-radius: 8px; font-size: 14px; cursor: pointer; }
.btn-cancel:hover { background: #e5e7eb; }

/* Login */
#pin-screen { display: flex; align-items: center; justify-content: center; height: 100vh; background: #f0f2f5; }
#pin-box { background: white; padding: 40px; border-radius: 16px; text-align: center; box-shadow: 0 4px 20px rgba(0,0,0,0.1); width: 340px; }
#pin-box h2 { color: #1e3a5f; margin-bottom: 8px; }
#pin-box p { color: #888; font-size: 13px; margin-bottom: 20px; }
#pin-input { width: 100%; padding: 10px; font-size: 20px; text-align: center; letter-spacing: 6px; border: 1px solid #ddd; border-radius: 8px; margin-bottom: 12px; outline: none; }
#pin-input:focus { border-color: #2563eb; }
#login-btn { width: 100%; padding: 10px; background: #2563eb; color: white; border: none; border-radius: 8px; font-size: 15px; cursor: pointer; }
#login-btn:hover { background: #1d4ed8; }
#pin-error { color: #dc2626; font-size: 13px; margin-top: 8px; }

.pencil-client {
  position: absolute;
  top: 4px;
  right: 4px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  color: #2563eb;
  padding: 2px;
  opacity: 0.5;
}
.pencil-client:hover { opacity: 1; }