/* =========================================================
   NOLAP OFFICE — Premium Solid Blue
   ========================================================= */

:root {
  --primary:        #2563eb;
  --primary-dark:   #1d4ed8;
  --primary-dim:    #3b82f6;
  --primary-light:  #dbeafe;
  --primary-faint:  #eff6ff;

  --sidebar-bg:     #0b1220;
  --sidebar-hover:  #151e32;
  --sidebar-active: rgba(37, 99, 235, 0.14);
  --sidebar-text:   #8896aa;
  --sidebar-bright: #e2e8f0;

  --ink:            #0b0f19;
  --ink-soft:       #1e293b;
  --body:           #334155;
  --muted:          #64748b;
  --muted-light:    #94a3b8;

  --bg:             #f4f6f9;
  --surface:        #ffffff;
  --surface-hover:  #f8fafc;

  --border:         #e2e8f0;
  --border-strong:  #cbd5e1;

  --green:          #059669;
  --green-bg:       #ecfdf5;
  --green-border:   #a7f3d0;
  --red:            #dc2626;
  --red-bg:         #fef2f2;
  --red-border:     #fecaca;
  --amber:          #d97706;
  --amber-bg:       #fffbeb;
  --amber-border:   #fde68a;

  --radius-sm:      8px;
  --radius:         12px;
  --radius-lg:      16px;

  --shadow-sm:      0 1px 2px 0 rgb(11 15 25 / 0.04);
  --shadow:         0 1px 3px 0 rgb(11 15 25 / 0.06), 0 1px 2px -1px rgb(11 15 25 / 0.06);
  --shadow-md:      0 4px 6px -1px rgb(11 15 25 / 0.06), 0 2px 4px -2px rgb(11 15 25 / 0.06);
  --shadow-lg:      0 10px 15px -3px rgb(11 15 25 / 0.06), 0 4px 6px -4px rgb(11 15 25 / 0.06);
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--body);
  background: var(--bg);
}

.num, td.num, th.num, .money {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

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

/* =========================================================
   Layout
   ========================================================= */

.layout {
  display: flex;
  min-height: 100vh;
}

/* ---------------------------------------------------------
   Sidebar
   --------------------------------------------------------- */
.sidebar {
  width: 264px;
  background: var(--sidebar-bg);
  color: #fff;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar .brand {
  padding: 26px 24px 22px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgb(255 255 255 / 0.06);
}

.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  border-radius: 8px;
  flex-shrink: 0;
}

.logo-text {
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.01em;
  color: #fff;
}

.sidebar nav {
  padding: 16px 14px;
  flex: 1;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  transition: all 140ms ease;
  position: relative;
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-size: 15px;
  opacity: 0.75;
  flex-shrink: 0;
}

.sidebar nav a:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-bright);
  text-decoration: none;
}

.sidebar nav a:hover .nav-icon {
  opacity: 1;
}

.sidebar nav a.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 600;
}

.sidebar nav a.active .nav-icon {
  opacity: 1;
  color: var(--primary-dim);
}

.sidebar nav a.active::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: var(--primary);
  border-radius: 0 4px 4px 0;
}

.sidebar .foot {
  padding: 16px 20px;
  border-top: 1px solid rgb(255 255 255 / 0.06);
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: var(--sidebar-hover);
  color: var(--sidebar-bright);
  font-size: 12px;
  font-weight: 700;
  border-radius: 50%;
  flex-shrink: 0;
  text-transform: uppercase;
}

.user-name {
  font-size: 13px;
  color: var(--sidebar-text);
  font-weight: 500;
}

.sidebar .foot a {
  display: block;
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--sidebar-text);
  font-weight: 500;
}

.sidebar .foot a:hover {
  color: #fff;
  text-decoration: none;
}

/* ---------------------------------------------------------
   Main
   --------------------------------------------------------- */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 22px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 {
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.content {
  padding: 32px;
  max-width: 1280px;
}

/* =========================================================
   Messages
   ========================================================= */
.messages {
  list-style: none;
  margin: 0 0 24px;
}

.messages li {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid transparent;
}

.msg-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.messages li.success {
  background: var(--green-bg);
  color: var(--green);
  border-color: var(--green-border);
}
.messages li.success .msg-icon { background: #d1fae5; }

.messages li.error {
  background: var(--red-bg);
  color: var(--red);
  border-color: var(--red-border);
}
.messages li.error .msg-icon { background: #fee2e2; }

.messages li.warning {
  background: var(--amber-bg);
  color: var(--amber);
  border-color: var(--amber-border);
}
.messages li.warning .msg-icon { background: #fef3c7; }

/* =========================================================
   Page Note
   ========================================================= */
.page-note {
  color: var(--muted);
  margin: 0 0 24px;
  font-size: 14.5px;
  line-height: 1.6;
  max-width: 720px;
}

/* =========================================================
   Cards
   ========================================================= */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 200ms ease, transform 200ms ease, border-color 200ms ease;
  position: relative;
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
  transform: translateY(-2px);
}

.card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary);
}

.card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--primary-faint);
  color: var(--primary);
  border-radius: 10px;
  font-size: 18px;
  margin-bottom: 16px;
}

.card .label {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.card .value {
  font-size: 30px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

/* Detail card (client profile) */
.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 560px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
}

.detail-row {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 14.5px;
}

.detail-row:last-child { margin-bottom: 0; }

.detail-row strong {
  color: var(--ink-soft);
  font-weight: 600;
  min-width: 80px;
}

.detail-notes {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

/* =========================================================
   Chooser
   ========================================================= */
.chooser {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.chooser a {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: all 200ms ease;
  position: relative;
  overflow: hidden;
}

.chooser a::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius) 0 0 var(--radius);
}

.chooser a:hover {
  background: var(--primary-faint);
  border-color: var(--primary-light);
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.chooser a .t {
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
}

.chooser a .d {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

/* =========================================================
   Section Title
   ========================================================= */
.section-title {
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 40px 0 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.section-title:first-child {
  margin-top: 0;
}

/* =========================================================
   Tables
   ========================================================= */
table.grid {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  font-size: 14px;
}

table.grid th,
table.grid td {
  text-align: left;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

table.grid th {
  background: #f8fafc;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  white-space: nowrap;
}

table.grid tbody tr {
  transition: background 120ms ease;
}

table.grid tbody tr:hover {
  background: var(--surface-hover);
}

table.grid tbody tr:last-child td {
  border-bottom: none;
}

td.num, th.num { text-align: right; }

.pos { color: var(--green); font-weight: 700; }
.neg { color: var(--red); font-weight: 700; }

/* Table actions */
table.grid td form { margin: 0; display: inline; }
table.grid td .btn {
  padding: 7px 14px;
  font-size: 13px;
}

/* =========================================================
   Filter Bar (Ledger)
   ========================================================= */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.filter-bar .btn {
  padding: 8px 16px;
  font-size: 13.5px;
}

.filter-bar .btn:not(.secondary) {
  box-shadow: var(--shadow-sm);
}

.filter-info {
  margin-left: 8px;
  color: var(--muted);
  font-size: 14px;
}

/* =========================================================
   Forms
   ========================================================= */
form.stack {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 560px;
  box-shadow: var(--shadow-sm);
}

form.stack .field {
  margin-bottom: 24px;
}

form.stack label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

form.stack input[type="text"],
form.stack input[type="number"],
form.stack input[type="date"],
form.stack input[type="email"],
form.stack input[type="password"],
form.stack select,
form.stack textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  font-family: inherit;
  color: var(--ink);
  background: var(--surface);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

form.stack input:focus,
form.stack select:focus,
form.stack textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

form.stack textarea {
  min-height: 100px;
  resize: vertical;
}

form.stack .help {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 6px;
  line-height: 1.4;
}

form.stack .errorlist {
  color: var(--red);
  list-style: none;
  padding: 0;
  margin: 6px 0 0;
  font-size: 13px;
  font-weight: 500;
}

form.stack .errorlist li {
  padding-left: 16px;
  position: relative;
}

form.stack .errorlist li::before {
  content: "•";
  position: absolute;
  left: 4px;
  color: var(--red);
}

/* Inline checkbox label */
form.stack label input[type="checkbox"] {
  margin-right: 8px;
  accent-color: var(--primary);
}

/* =========================================================
   Buttons
   ========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 150ms ease;
  line-height: 1;
}

.btn:hover {
  background: var(--primary-dark);
  text-decoration: none;
  color: #fff;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.btn.secondary {
  background: var(--surface);
  color: var(--primary);
  border: 1px solid var(--border-strong);
}

.btn.secondary:hover {
  background: var(--primary-faint);
  border-color: var(--primary-light);
  color: var(--primary-dark);
}

.btn.danger {
  background: var(--red);
}

.btn.danger:hover {
  background: #b91c1c;
}

/* =========================================================
   Pills
   ========================================================= */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1;
}

.pill::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

.pill.ok    { background: var(--green-bg); color: var(--green); }
.pill.ok::before    { background: var(--green); }

.pill.wait  { background: var(--amber-bg); color: var(--amber); }
.pill.wait::before  { background: var(--amber); }

.pill.muted { background: #f1f5f9; color: var(--muted); }
.pill.muted::before { background: var(--muted-light); }

/* =========================================================
   Empty State
   ========================================================= */
.empty {
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 44px 24px;
  text-align: center;
  font-size: 14.5px;
  box-shadow: var(--shadow-sm);
}

.empty::before {
  content: "◨";
  display: block;
  font-size: 36px;
  color: var(--border-strong);
  margin-bottom: 14px;
  opacity: 0.6;
}

/* =========================================================
   Login Page
   ========================================================= */
.login-body {
  background: var(--sidebar-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 420px;
  padding: 48px 40px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--primary);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.login-brand .logo-mark {
  width: 36px;
  height: 36px;
  font-size: 17px;
}

.login-brand .logo-text {
  color: var(--ink);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.login-sub {
  color: var(--muted);
  font-size: 14.5px;
  margin-bottom: 32px;
}

.login-error {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid var(--red-border);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 20px;
}

.login-form label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.login-form input[type="text"],
.login-form input[type="password"] {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  margin-bottom: 20px;
  font-family: inherit;
  color: var(--ink);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.login-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.login-form button {
  width: 100%;
  padding: 12px;
  font-size: 15px;
}

/* =========================================================
   Utilities
   ========================================================= */
.actions-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 768px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    flex-direction: row;
    align-items: center;
    padding: 0 16px;
  }
  .sidebar .brand { border-bottom: none; padding: 16px 0; }
  .sidebar nav { display: none; }
  .sidebar .foot { display: none; }
  .content { padding: 20px; }
  .topbar { padding: 16px 20px; }
  .cards { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 18px; }
  form.stack { padding: 24px; }
}


.logout-form { margin: 0; }
.logout-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-decoration: underline;
}
.logout-btn:hover { opacity: 0.85; }