@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@500;600;700;800&family=Source+Sans+3:wght@400;500;600;700&display=swap');

:root {
  --bg: #eef1f4;
  --bg-soft: #f7f9fb;
  --surface: #ffffff;
  --ink: #15202b;
  --muted: #5f6b76;
  --line: #d7dde4;
  --line-strong: #b8c2cd;
  --accent: #0f6b66;
  --accent-2: #0a524e;
  --accent-soft: #e4f3f1;
  --warn: #9a6700;
  --warn-soft: #fff6dd;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --success: #067647;
  --success-soft: #e8f8ef;
  --charge: #fce8e6;
  --charge-ink: #912018;
  --pay: #e4f7eb;
  --pay-ink: #085d3a;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(21, 32, 43, .06), 0 8px 24px rgba(21, 32, 43, .05);
  --shadow-sm: 0 1px 2px rgba(21, 32, 43, .05);
  --font: "Source Sans 3", "Segoe UI", sans-serif;
  --display: "Manrope", "Source Sans 3", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 500px at 10% -10%, #d9ebe8 0%, transparent 55%),
    radial-gradient(900px 400px at 100% 0%, #e4eaf3 0%, transparent 50%),
    var(--bg);
  color: var(--ink);
  font: 400 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); text-decoration: underline; }
button { font: inherit; cursor: pointer; }
img { max-width: 100%; }

/* ——— Top bar ——— */
.app-title {
  background: linear-gradient(135deg, #12343b 0%, #0f6b66 58%, #1a8a82 100%);
  color: #fff;
  padding: 12px 18px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  box-shadow: 0 2px 12px rgba(15, 107, 102, .25);
}
.app-title > span:first-child {
  letter-spacing: .02em;
  font-size: 15px;
}
.app-title a {
  color: #fff;
  opacity: .92;
  text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,.35);
}
.app-title a:hover { opacity: 1; }

.menubar {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  background: rgba(255,255,255,.78);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 8px 12px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.menubar a {
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.menubar a:hover {
  background: var(--accent-soft);
  color: var(--accent-2);
  text-decoration: none;
}
.menubar a.active {
  background: var(--accent);
  color: #fff;
}

/* ——— Toolbar ——— */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: stretch;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 10px 14px;
  box-shadow: var(--shadow-sm);
}
.tool {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 72px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--ink);
  text-align: center;
  text-decoration: none;
  transition: border-color .15s, background .15s, transform .1s;
}
.tool:hover {
  background: #fff;
  border-color: var(--accent);
  color: var(--accent-2);
  text-decoration: none;
  transform: translateY(-1px);
}
.tool:active { transform: none; }
.tool .ico {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  font-size: 18px;
  line-height: 1;
}
.tool span {
  font-size: 11px;
  font-weight: 600;
  max-width: 84px;
  line-height: 1.15;
}
.tool.right { margin-left: auto; }
.tool.power {
  border-color: #b8d9d6;
  background: var(--accent-soft);
  color: var(--accent-2);
}

.wrap {
  padding: 16px;
  min-height: calc(100vh - 150px);
  max-width: 1440px;
  margin: 0 auto;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* ——— Dashboard ——— */
.dash-grid {
  display: grid;
  gap: 16px;
}
.dash-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px 18px;
}
.dash-section h2 {
  margin: 0 0 14px;
  font-family: var(--display);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.dash-icons {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 10px;
}
.dash-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #fff, var(--bg-soft));
  color: var(--ink);
  text-decoration: none;
  transition: border-color .15s, box-shadow .15s, transform .12s;
}
.dash-btn:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 20px rgba(15, 107, 102, .12);
  transform: translateY(-2px);
  text-decoration: none;
  color: var(--ink);
}
.dash-btn .big {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent-2);
  display: grid;
  place-items: center;
  font-size: 24px;
  border: 1px solid #c5e4e0;
}
.dash-btn .lbl {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  font-family: var(--display);
}
.dash-btn-alert {
  border-color: #c0392b;
  background: linear-gradient(180deg, #fff5f4, #ffe3e0);
  box-shadow: 0 0 0 2px rgba(192, 57, 43, .18);
  animation: dashPulse 1.6s ease-in-out infinite;
}
.dash-btn-alert .big {
  background: #fde8e6;
  color: #b71c1c;
  border-color: #f0b4ad;
}
.dash-btn-alert .lbl {
  color: #8b0000;
}
.dash-alert-count {
  display: inline-block;
  min-width: 18px;
  padding: 1px 6px;
  margin-top: 2px;
  border-radius: 999px;
  background: #c0392b;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
}
@keyframes dashPulse {
  0%, 100% { transform: translateY(0); box-shadow: 0 0 0 2px rgba(192, 57, 43, .18); }
  50% { transform: translateY(-1px); box-shadow: 0 0 0 4px rgba(192, 57, 43, .28); }
}

/* legacy dash-row support */
.dash-row {
  display: grid;
  grid-template-columns: 44px 1fr;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  min-height: 0;
}
.dash-label {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  background: linear-gradient(180deg, #1a4f4c, var(--accent));
  color: #fff;
  font-family: var(--display);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .08em;
  display: grid;
  place-items: center;
  padding: 8px 0;
}
.dash-row .dash-icons {
  padding: 12px;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
}

/* ——— Filters ——— */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
}
.filter-box {
  background: var(--warn-soft);
  border: 1px solid #f0d78c;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  min-width: 160px;
}
.filters-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}
.filters-toggle:hover { border-color: var(--accent); color: var(--accent-2); }
.filters-chevron { font-size: 10px; color: var(--muted); }
.filters-form {
  padding: 12px 14px 8px;
  border-top: 1px solid var(--line);
  background: #fff;
}
.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  align-items: end;
}
.filters-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-weight: 700;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.filters-grid input,
.filters-grid select {
  font: 500 13px/1.3 var(--font);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
}
.filters-actions {
  display: flex;
  gap: 8px;
  align-items: end;
  padding-bottom: 2px;
}

/* ——— Forms ——— */
input[type=text],
input[type=email],
input[type=date],
input[type=number],
input[type=search],
input[type=password],
select,
textarea {
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font: 500 14px/1.3 var(--font);
  color: var(--ink);
  width: 100%;
  max-width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 72px; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 107, 102, .15);
}
label { font-weight: 600; }

/* ——— Data grid ——— */
table.grid {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
  font-size: 13px;
}
table.grid th {
  background: #f3f6f8;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
  font-family: var(--display);
  font-weight: 700;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .03em;
}
table.grid td {
  border-bottom: 1px solid #eef1f4;
  padding: 9px 12px;
  white-space: nowrap;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
}
table.grid tr:nth-child(even) td { background: #fafbfc; }
table.grid tr:hover td { background: var(--accent-soft); }
table.grid tr.selected td {
  background: var(--accent) !important;
  color: #fff;
}
table.grid tr.selected a { color: #fff; }
.grid-wrap {
  overflow: auto;
  max-height: calc(100vh - 240px);
  background: #fff;
}
.sort-th {
  color: inherit;
  font-weight: 700;
  text-decoration: none;
  display: block;
  white-space: nowrap;
}
.sort-th:hover { color: var(--accent); text-decoration: underline; }

/* ——— Contact card ——— */
.card-layout {
  display: grid;
  grid-template-columns: 1.35fr 1fr minmax(220px, 260px);
  gap: 12px;
}
@media (max-width: 1100px) {
  .card-layout { grid-template-columns: 1fr; }
}
.field-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 6px 10px;
  align-items: center;
  margin-bottom: 8px;
}
.field-row.two { grid-template-columns: 130px 1fr 70px 1fr; }
.field-row label {
  font-weight: 700;
  font-size: 12px;
  color: var(--muted);
}
.locked-field {
  background: #f0eee8 !important;
  color: #444;
  cursor: default;
}
.biz-select.biz-panorama {
  background: #e6f7ea !important;
  border-color: #8fce9b !important;
  font-weight: 700;
}
.biz-select.biz-photobooth {
  background: #e3f0ff !important;
  border-color: #8eb6e8 !important;
  font-weight: 700;
}
.tabs {
  display: flex;
  gap: 6px;
  margin-top: 4px;
  padding: 0 2px;
  border-bottom: 1px solid var(--line);
}
.tabs a.tab-btn,
.tabs button.tab-btn,
.tabs span {
  padding: 9px 14px;
  border: none;
  border-radius: 10px 10px 0 0;
  background: transparent;
  color: var(--muted);
  margin-bottom: -1px;
  font: 700 13px var(--display);
  cursor: pointer;
}
.tabs a.tab-btn.active,
.tabs button.tab-btn.active {
  background: #fff;
  color: var(--accent-2);
  border: 1px solid var(--line);
  border-bottom-color: #fff;
  position: relative;
  z-index: 1;
}
.tab-panel {
  margin-top: 0;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}
.notes-box {
  background: var(--warn-soft);
  border: 1px solid #f0d78c;
  border-radius: var(--radius-sm);
  min-height: 110px;
  width: 100%;
}
.relations {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
}
.relations label {
  display: flex;
  gap: 8px;
  align-items: center;
  font-weight: 500;
  color: var(--ink);
}
.sidebar-box {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.sidebar-box h3 {
  margin: 0;
  padding: 10px 12px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
  font-family: var(--display);
  font-size: 13px;
  font-weight: 800;
}
.sidebar-box .body { padding: 12px; }
.balance {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 800;
  margin: 4px 0 10px;
}
.tx-mini { font-size: 12px; line-height: 1.45; }
.tx-mini div { padding: 6px 0; border-bottom: 1px solid #eef1f4; }
.tx-mini a { color: var(--ink); }

.statusbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  padding: 8px 16px;
  background: rgba(255,255,255,.85);
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.nav-rec { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.nav-rec a {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  color: var(--ink);
  font-weight: 600;
  font-size: 12px;
  text-decoration: none;
}
.nav-rec a:hover { border-color: var(--accent); color: var(--accent-2); }
.brand-mark {
  font-family: var(--display);
  font-size: 12px;
  font-weight: 800;
  color: #9aa5b1;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.muted { color: var(--muted); }
.flash {
  margin: 12px 16px 0;
  padding: 10px 14px;
  border: 1px solid #abefc6;
  background: var(--success-soft);
  color: var(--success);
  border-radius: var(--radius-sm);
  font-weight: 600;
}
.flash-warn {
  border-color: #f0d080;
  background: #fff8e6;
  color: #7a5a00;
}
.flash-warn a {
  color: #0f6b66;
  font-weight: 700;
}
.section-title {
  background: linear-gradient(90deg, #1a4f4c, var(--accent));
  color: #fff;
  padding: 8px 12px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 12px;
  border-radius: var(--radius-sm);
}
.highlight-name {
  background: #e8f8ef !important;
  font-weight: 700;
}
.input-upper {
  text-transform: uppercase;
}
.contact-banner {
  margin: 12px 16px 0;
  padding: 12px 14px;
  background: linear-gradient(135deg, #e4f3f1, #edf4ff);
  border: 1px solid #c5e4e0;
  border-radius: var(--radius);
  font-size: 14px;
  box-shadow: var(--shadow-sm);
}
.btn-search, .btn {
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  display: inline-block;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover, .btn-search:hover {
  border-color: var(--accent);
  color: var(--accent-2);
  text-decoration: none;
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff !important;
}
.btn-primary:hover {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: #fff !important;
}

.running-bal {
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-weight: 600;
}
.bal-owed { color: var(--danger); font-weight: 700; }
.bal-credit { color: var(--success); font-weight: 700; }
.bal-zero { color: var(--ink); }
.bal-none { color: #9aa5b1; }

.amt-cell {
  font-size: 14px;
  font-weight: 700;
  padding: 8px 12px !important;
  text-align: right;
  white-space: nowrap;
  border-radius: 6px;
}
.amt-charge { background: var(--charge) !important; color: var(--charge-ink); }
.amt-pay { background: var(--pay) !important; color: var(--pay-ink); }
.desc-cell { white-space: normal !important; max-width: 360px; min-width: 160px; }

.biz-tabs { display: flex; gap: 8px; padding: 12px 0 8px; flex-wrap: wrap; }
.biz-tab {
  padding: 8px 14px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  font-size: 13px;
  border-radius: 999px;
}
.biz-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.biz-tab:hover { border-color: var(--accent); text-decoration: none; }

.photo-box { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.photo-frame {
  width: 104px;
  height: 104px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  border-radius: 14px;
  display: grid;
  place-items: center;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
}
.photo-frame img { width: 100%; height: 100%; object-fit: cover; }
.photo-zoom {
  position: absolute;
  right: 6px;
  bottom: 6px;
  border: none;
  background: rgba(255,255,255,.94);
  width: 28px;
  height: 28px;
  border-radius: 999px;
  padding: 0;
  cursor: pointer;
  font-size: 13px;
  box-shadow: var(--shadow-sm);
}
.file-list { list-style: none; margin: 0; padding: 0; }
.file-list li {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 8px 0;
  border-bottom: 1px solid #eef1f4;
  font-size: 13px;
}

.tool-stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-width: 72px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-soft);
}
.tool-label-on-icon {
  border: none !important;
  border-bottom: 1px solid var(--line) !important;
  border-radius: 0;
  padding: 6px 4px !important;
  gap: 2px !important;
  background: transparent;
}
.tool-label-on-icon span {
  order: 1;
  font-size: 11px;
  font-weight: 700;
}
.tool-label-on-icon .ico { order: 2; font-size: 18px; }
.tool-icon-only {
  border: none !important;
  border-radius: 0;
  padding: 4px !important;
  min-height: 0;
  background: transparent;
}
.side-btn-stack {
  display: flex;
  flex-direction: column;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-soft);
}
.side-tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 12px;
}
.side-tool:hover { background: #fff; text-decoration: none; }
.side-tool-sm { border-top: 1px solid var(--line); padding: 6px; }

/* ——— Login ——— */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(800px 400px at 20% 0%, #d9ebe8, transparent 60%),
    radial-gradient(700px 360px at 90% 100%, #dde5f0, transparent 55%),
    var(--bg);
}
.login-box {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 28px 24px;
}
.login-box h1 {
  margin: 0 0 6px;
  font-family: var(--display);
  font-size: 22px;
  font-weight: 800;
}
.login-box .sub {
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 14px;
}
.login-box input[type=password] {
  width: 100%;
  padding: 12px 12px;
  font-size: 16px;
  margin: 8px 0 14px;
}
.login-box button {
  width: 100%;
  padding: 12px;
  font-weight: 700;
  font-family: var(--display);
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.login-box button:hover { background: var(--accent-2); }
.err {
  background: var(--danger-soft);
  border: 1px solid #f3b0aa;
  color: var(--danger);
  padding: 10px 12px;
  margin-bottom: 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
}

@media (max-width: 720px) {
  .app-title { flex-direction: column; align-items: flex-start; }
  .toolbar .tool { min-width: 64px; }
  .field-row,
  .field-row.two { grid-template-columns: 1fr; }
  .wrap { padding: 10px; }
}
