/* Desktop UI — Stingray Accounting */

body {
  font-family: Arial, sans-serif;
  margin: 0;
  background: #f6f8fa;
  color: #111827;
}

.wrap { max-width: 960px; margin: 24px auto; padding: 0 16px; }

.card {
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

input, button, select, textarea { font-size: 14px; padding: 8px 10px; box-sizing: border-box; }
input, select, textarea { border: 1px solid #9ca3af; border-radius: 6px; }
textarea { font-family: Consolas, monospace; width: 100%; resize: vertical; }

button {
  border: 1px solid #374151;
  border-radius: 6px;
  background: #111827;
  color: #fff;
  cursor: pointer;
}
button.secondary { background: #fff; color: #111827; }
button.danger { background: #b91c1c; border-color: #b91c1c; color: #fff; }
a.button { text-decoration: none; display: inline-block; }

.muted { color: #6b7280; }

.status {
  white-space: pre-wrap;
  font-family: Consolas, monospace;
  font-size: 13px;
  background: #0f172a;
  color: #d1fae5;
  padding: 12px;
  border-radius: 8px;
  max-height: 360px;
  overflow: auto;
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: top;
}
th { background: #f9fafb; font-weight: 600; }

.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  background: #e5e7eb;
}
.badge-from    { background: #dbeafe; color: #1e40af; }
.badge-subject { background: #dcfce7; color: #166534; }
.badge-body    { background: #fef9c3; color: #92400e; }

.pat-list { font-family: Consolas, monospace; font-size: 12px; color: #374151; }
.dest-null { color: #9ca3af; font-style: italic; }

/* --- messages ---------------------------------------------------------- */

.msg-ok    { color: #065f46; }
.msg-error { color: #b91c1c; }
.msg-info  { color: #2563eb; }
.inline-error { color: #b91c1c; font-size: 14px; margin-left: 10px; }

/* --- navigation -------------------------------------------------------- */

.nav { margin-bottom: 4px; }
.nav-user { color: #374151; }
button.nav-active { border-color: #2563eb; color: #2563eb; }

/* --- forms ------------------------------------------------------------- */

.field { display: block; }
.field-label { font-size: 12px; color: #6b7280; }
.field-input { margin-top: 4px; }
.field-label-strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
  color: #9ca3af;
}
.stack > .row + .row { margin-top: 8px; }
.form-actions { margin-top: 12px; }

.entry-form {
  max-width: 36rem;
}
.entry-form .entry-row {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  align-items: center;
  column-gap: 12px;
  margin-top: 8px;
}
.entry-form .entry-row:first-of-type { margin-top: 0; }
.entry-form .field-label-strong {
  margin-bottom: 0;
  text-align: left;
}
.entry-form .entry-row input,
.entry-form .entry-row select,
.entry-form .entry-row textarea {
  width: 100%;
  max-width: 28rem;
  justify-self: start;
  text-align: left;
}
.entry-form .form-actions {
  display: flex;
  justify-content: flex-start;
}
.rule-form-row { align-items: flex-start; gap: 12px; flex-wrap: nowrap; }
.rule-dest { min-width: 180px; }
.rule-dest input { margin-top: 4px; width: 100%; }
.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.checkbox-label input { width: auto; margin: 0; }

.settings-table { border-collapse: collapse; width: 100%; }
.settings-table td { border-bottom: none; }
.settings-table .label {
  padding: 5px 12px 5px 0;
  white-space: nowrap;
  color: #9ca3af;
  font-size: 13px;
}
.settings-table .label-first { width: 120px; }
.settings-table .value { padding: 4px 0; }
.settings-table .value input { width: 100%; }
.settings-table .value input.port { width: 80px; }

/* --- tables ------------------------------------------------------------ */

.col-num   { width: 32px; }
.col-field { width: 80px; }
.col-actions { width: 130px; }
.row-index { color: #9ca3af; font-size: 12px; }
.nowrap { white-space: nowrap; }
button.btn-sm, a.btn-sm { font-size: 12px; padding: 4px 8px; }
form.inline { display: inline; }

/* --- rules page -------------------------------------------------------- */

.section-head { align-items: center; margin-bottom: 12px; gap: 12px; }
.section-head h3 { margin: 0; }
#ruleSearch { flex: 1; max-width: 360px; }
.no-match { display: none; color: #6b7280; font-style: italic; margin-top: 8px; }
.expand-btn {
  display: none;
  margin-top: 10px;
  background: none;
  border: 1px solid #4b5563;
  color: #9ca3af;
  font-size: 13px;
  padding: 5px 14px;
  border-radius: 6px;
  cursor: pointer;
}

/* --- processing page --------------------------------------------------- */

.autorun-row { align-items: center; gap: 12px; }
.autorun-row label { font-size: 14px; }
#intervalInput { width: 70px; }
#autoRunStatus { font-size: 13px; }
.status-head { align-items: center; margin-bottom: 8px; }
.status-head h3 { margin: 0; }
#runState { margin-right: auto; font-size: 13px; }

/* --- reports ----------------------------------------------------------- */

.report-company {
  margin: 0 0 4px 0;
  font-size: 13px;
  color: #6b7280;
}
.report-title { margin: 0 0 4px 0; }
.report-date { margin: 0 0 16px 0; }
.report-count { margin: 12px 0 0 0; }
.report-table th { white-space: nowrap; }

@media print {
  body { background: #fff; }
  .wrap { max-width: none; margin: 0; padding: 0; }
  .no-print { display: none !important; }
  .card {
    border: none;
    padding: 0;
    margin: 0;
  }
  .report-table th, .report-table td {
    border-bottom: 1px solid #d1d5db;
  }
}
