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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #0f1117;
  color: #e0e0e0;
  min-height: 100vh;
}

.hidden { display: none !important; }

.card {
  background: #1a1d27;
  border-radius: 12px;
  padding: 2rem;
  border: 1px solid #2a2d3a;
}

.login-card {
  max-width: 360px;
  margin: 15vh auto;
}

.login-card h1 {
  text-align: center;
  margin-bottom: 1.5rem;
  color: #fff;
}

input, select, button {
  font-size: 1rem;
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  border: 1px solid #2a2d3a;
  background: #12141c;
  color: #e0e0e0;
  width: 100%;
}

input:focus, select:focus {
  outline: none;
  border-color: #4f8cff;
}

button {
  background: #4f8cff;
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 600;
  width: auto;
  padding: 0.6rem 1.4rem;
}

button:hover { background: #3a6fd8; }

form input, form select {
  margin-bottom: 0.8rem;
}

.error { color: #ff5c5c; margin-top: 0.5rem; font-size: 0.9rem; }
.success { color: #4caf50; margin-top: 0.5rem; font-size: 0.9rem; }

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  border-bottom: 1px solid #2a2d3a;
}

header h1 { font-size: 1.3rem; color: #fff; }

.header-actions { display: flex; gap: 0.5rem; align-items: center; }

.icon-btn {
  background: none;
  font-size: 1.2rem;
  padding: 0.4rem;
  color: #888;
}
.icon-btn:hover { color: #fff; background: none; }

#btn-logout {
  background: #333;
  font-size: 0.85rem;
  padding: 0.4rem 0.8rem;
}

.tabs {
  display: flex;
  gap: 0;
  padding: 0 2rem;
  border-bottom: 1px solid #2a2d3a;
}

.tab {
  background: none;
  color: #888;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 0.8rem 1.2rem;
  font-size: 0.95rem;
}
.tab:hover { color: #ccc; background: none; }
.tab.active { color: #4f8cff; border-bottom-color: #4f8cff; }

.tab-content { padding: 1.5rem 2rem; }
.tab-content h3 { margin-bottom: 1rem; font-size: 1.1rem; color: #fff; }

.entry-controls {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.entry-controls label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: #888;
}

.entry-controls select { width: 140px; }

#mac-buckets-container, #others-sites-container,
#amazon-entry-container, #adsense-entry-container,
#bh-entry-container, #partners-entry-container { margin-top: 1.5rem; }


#mac-buckets-container h4, #others-sites-container h4,
#amazon-entry-container h4, #adsense-entry-container h4,
#bh-entry-container h4, #partners-entry-container h4 { margin-bottom: 1rem; font-size: 1rem; color: #ccc; }

.bucket-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.bucket-row label {
  width: 140px;
  font-size: 0.9rem;
  color: #aaa;
  text-align: right;
  flex-shrink: 0;
}

.bucket-row input {
  width: 160px;
  text-align: right;
}

.buckets-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #2a2d3a;
}

.total {
  font-size: 1.2rem;
  font-weight: 700;
  color: #4caf50;
}

.your-cut { display: block; font-size: 0.95rem; color: #4f8cff; margin-top: 0.2rem; }

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

th, td {
  text-align: left;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid #2a2d3a;
}

th { color: #888; font-weight: 600; font-size: 0.85rem; text-transform: uppercase; }
td { font-size: 0.95rem; }

tfoot td { border-top: 2px solid #4f8cff; border-bottom: none; }

.clickable-row { cursor: pointer; transition: background 0.15s; }
.clickable-row:hover { background: #252836; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  overflow-y: auto;
  padding: 2rem;
}

.modal-content { max-width: 560px; width: 100%; }

.autosave-indicator {
  font-size: 0.75rem;
  color: #4caf50;
  opacity: 0;
  transition: opacity 0.2s;
  margin-left: 0.5rem;
}
.autosave-indicator.show { opacity: 1; }

.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: #1a1d27;
  border: 1px solid #4caf50;
  color: #4caf50;
  padding: 0.8rem 1.4rem;
  border-radius: 8px;
  font-weight: 600;
  z-index: 200;
  animation: toast-in 0.2s ease, toast-out 0.3s ease 1.5s forwards;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { from { opacity: 1; } to { opacity: 0; } }
.settings-card { max-height: 90vh; overflow-y: auto; }
.modal-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.modal-actions button:last-child { background: #333; }

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.settings-header h2 { margin: 0; }

.settings-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid #2a2d3a;
  margin-bottom: 1rem;
}

.settings-tab {
  background: none;
  color: #888;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  cursor: pointer;
}
.settings-tab:hover { color: #ccc; background: none; }
.settings-tab.active { color: #4f8cff; border-bottom-color: #4f8cff; }

.settings-tab-content { min-height: 200px; }

.settings-group { margin-bottom: 0.5rem; }
.settings-row { display: flex; gap: 0.8rem; align-items: flex-end; flex-wrap: wrap; }
.settings-row .settings-section { flex: 1; min-width: 100px; }
.settings-row input[type="color"] { width: 50px; height: 36px; padding: 2px; cursor: pointer; }

textarea {
  font-size: 0.9rem;
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  border: 1px solid #2a2d3a;
  background: #12141c;
  color: #e0e0e0;
  width: 100%;
  resize: vertical;
  font-family: inherit;
}
textarea:focus { outline: none; border-color: #4f8cff; }

.settings-hint { font-size: 0.75rem; color: #666; margin-top: 0.3rem; }

.danger-zone {
  border: 1px solid #ff5c5c33;
  border-radius: 8px;
  padding: 1rem;
  background: rgba(255, 92, 92, 0.05);
}
.danger-zone h3 { color: #ff5c5c; margin-bottom: 0.5rem; }
.danger-desc { font-size: 0.85rem; color: #888; margin-bottom: 0.8rem; }
.btn-danger { background: #d32f2f; }
.btn-danger:hover { background: #b71c1c; }
.settings-group h3 { margin-bottom: 0.8rem; font-size: 1rem; color: #fff; }
.settings-section { margin-bottom: 0.8rem; }
.settings-section label { display: block; font-size: 0.9rem; color: #aaa; margin-bottom: 0.4rem; }
.pct-row { display: flex; align-items: center; gap: 0.4rem; margin-top: 0.3rem; }
.pct-row input { width: 100px; text-align: right; }
.pct-row span { color: #888; }
.settings-divider { border: none; border-top: 1px solid #2a2d3a; margin: 1.2rem 0; }

.sites-list { margin-bottom: 0.8rem; }

.site-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.site-row input { flex: 1; }

.btn-remove-site {
  background: #ff5c5c;
  color: #fff;
  padding: 0.4rem 0.6rem;
  font-size: 0.8rem;
  flex-shrink: 0;
  width: auto;
}
.btn-remove-site:hover { background: #d44; }

.add-site-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.add-site-row input { flex: 1; }
.add-site-row button { flex-shrink: 0; }

/* Two-up entry layout */
.entry-twoup {
  gap: 1.5rem;
  align-items: flex-start;
}

.entry-main {
  flex: 1 1 50%;
  min-width: 0;
}

.entry-side {
  flex: 1 1 50%;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

@media (max-width: 700px) {
  .entry-twoup { flex-direction: column; }
  .entry-side { flex: none; width: 100%; }
}

/* Screenshots */
.screenshot-section {
  margin-top: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.screenshot-dropzone {
  flex: 1;
  min-height: 200px;
  border: 2px dashed #2a2d3a;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.25s, background 0.25s;
  margin-bottom: 0.8rem;
  position: relative;
  background: #12141c;
}

.screenshot-dropzone:hover {
  border-color: #4f8cff;
  background: rgba(79, 140, 255, 0.06);
}

.screenshot-dropzone.dragover {
  border-color: #4caf50;
  background: rgba(76, 175, 80, 0.1);
  border-style: solid;
}

.screenshot-dropzone .screenshot-file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.dropzone-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  opacity: 0.3;
  pointer-events: none;
}

.dropzone-label {
  font-size: 0.85rem;
  color: #555;
  pointer-events: none;
}

.dropzone-hint {
  font-size: 0.7rem;
  color: #444;
  margin-top: 0.3rem;
  pointer-events: none;
}

.screenshot-grid {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.screenshot-thumb {
  position: relative;
  border: 1px solid #2a2d3a;
  border-radius: 6px;
  overflow: hidden;
  width: 120px;
  cursor: pointer;
}

.screenshot-thumb img {
  width: 100%;
  height: 80px;
  object-fit: cover;
  display: block;
}

.screenshot-thumb .screenshot-name {
  font-size: 0.65rem;
  color: #888;
  padding: 0.2rem 0.4rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.screenshot-thumb .btn-delete-screenshot {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(0,0,0,0.7);
  color: #ff5c5c;
  border: none;
  font-size: 0.7rem;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  cursor: pointer;
}

.screenshot-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  cursor: pointer;
}

.screenshot-lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
}

.detail-screenshots {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.detail-screenshots img {
  width: 80px;
  height: 55px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid #2a2d3a;
  cursor: pointer;
}

.report-controls {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

.report-filter {
  display: flex;
  gap: 0.6rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.report-filter label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.8rem;
  color: #888;
}

.report-filter select { width: 110px; }

.report-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: #aaa;
  cursor: pointer;
  white-space: nowrap;
}

.toggle-label input[type="checkbox"] {
  width: auto;
  accent-color: #4f8cff;
}

.btn-secondary {
  background: #333;
  font-size: 0.8rem;
  padding: 0.4rem 0.8rem;
}
.btn-secondary:hover { background: #444; }

#yoy-container { margin-bottom: 1.5rem; }
#yoy-container h4 { margin-bottom: 0.8rem; color: #ccc; }

.chart-container {
  position: relative;
  height: 300px;
  margin-bottom: 1.5rem;
  background: #14161e;
  border: 1px solid #2a2d3a;
  border-radius: 8px;
  padding: 1rem;
}

/* Report cards */
.report-month-card {
  border: 1px solid #2a2d3a;
  border-radius: 8px;
  margin-bottom: 0.8rem;
  overflow: hidden;
}

.report-month-header {
  display: flex;
  flex-direction: column;
  padding: 0.8rem 1.2rem;
  cursor: pointer;
  transition: background 0.15s;
  gap: 0.4rem;
}
.report-month-header:hover { background: #252836; }

.report-month-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.report-month-title {
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
  white-space: nowrap;
}

.report-month-total {
  font-weight: 700;
  font-size: 1.05rem;
  color: #4caf50;
  white-space: nowrap;
  text-align: right;
}

.report-month-summary {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}

.report-source-pill {
  font-size: 0.75rem;
  color: #aaa;
  background: #12141c;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  white-space: nowrap;
}

.delta {
  font-size: 0.65rem;
  margin-left: 0.2rem;
  font-weight: 500;
}
.delta-up { color: #4caf50; }
.delta-down { color: #ff5c5c; }

.report-month-detail {
  border-top: 1px solid #2a2d3a;
  padding: 1rem 1.2rem;
  background: #14161e;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.detail-section {
  flex: 1 1 250px;
  min-width: 250px;
  max-width: 100%;
  margin-bottom: 0;
  background: #1a1d27;
  border: 1px solid #2a2d3a;
  border-radius: 8px;
  padding: 0.8rem 1rem;
}

.detail-combined { flex-basis: 100%; }

.detail-synopsis {
  flex-basis: 100%;
  background: #1a1d27;
  border: 1px solid #2a2d3a;
  border-radius: 8px;
  padding: 0.8rem 1rem;
}

.detail-synopsis-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.synopsis-header-text {
  color: #ccc;
  font-family: Helvetica, Arial, sans-serif;
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 0.6rem;
  white-space: pre-wrap;
}

.synopsis-text {
  color: #ccc;
  font-family: Helvetica, Arial, sans-serif;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  margin: 0;
}

.synopsis-signature-text {
  color: #ccc;
  font-family: Helvetica, Arial, sans-serif;
  font-size: 0.9rem;
  line-height: 1.5;
  margin-top: 0;
  white-space: pre-wrap;
}

.synopsis-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.synopsis-toggle {
  font-size: 0.8rem;
}

.synopsis-screenshots {
  margin-top: 1rem;
  border-top: 1px solid #2a2d3a;
  padding-top: 1rem;
}

.synopsis-screenshot-group {
  margin-bottom: 1.5rem;
}

.synopsis-screenshot-source {
  text-align: left;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
  color: #e0e0e0;
}

.synopsis-screenshot-img {
  width: 100%;
  max-width: 100%;
  border-radius: 6px;
  border: 1px solid #2a2d3a;
  margin-bottom: 0.8rem;
  cursor: pointer;
  display: block;
}

.detail-section-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.detail-pct {
  font-size: 0.8rem;
  color: #4f8cff;
  background: rgba(79, 140, 255, 0.1);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
}

.detail-edit-btn {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  background: #333;
  margin-left: auto;
}
.detail-edit-btn:hover { background: #444; }

.detail-table {
  width: 100%;
  border-collapse: collapse;
}
.detail-table td {
  padding: 0.3rem 0.8rem;
  border-bottom: 1px solid #1e2130;
  font-size: 0.9rem;
}
.detail-table td:last-child { text-align: right; }
.detail-table tfoot td { border-top: 1px solid #2a2d3a; border-bottom: none; font-size: 0.9rem; }
.detail-table tfoot tr:last-child td {
  color: #4caf50;
  font-size: 1rem;
  padding-top: 0.5rem;
  background: rgba(76, 175, 80, 0.08);
  border-radius: 0 0 4px 4px;
}

.detail-combined {
  margin-top: 0.8rem;
  padding-top: 0.8rem;
  border-top: 2px solid #4f8cff;
  font-size: 1rem;
  color: #4caf50;
}

.source-totals {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-top: 1.2rem;
  padding: 0.8rem 1rem;
  border-top: 1px solid #2a2d3a;
  justify-content: flex-end;
}

.source-total-item {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  background: #1a1d27;
  border: 1px solid #2a2d3a;
  border-radius: 6px;
  padding: 0.4rem 0.8rem;
}

.source-total-name { color: #888; font-size: 0.85rem; }
.source-total-amount { color: #e0e0e0; font-weight: 600; font-size: 0.95rem; }

.report-grand-total {
  margin-top: 1.2rem;
  padding: 1rem;
  border-top: 2px solid #4f8cff;
  font-size: 1.2rem;
  font-weight: 700;
  color: #4caf50;
  text-align: right;
}
