:root {
    --ink: #1a1a2e;
    --paper: #faf8f4;
    --accent: #c85b2a;
    --accent-soft: #f0e6df;
    --line: #e0dbd3;
    --muted: #7a7570;
    --success: #2d6a4f;
    --success-soft: #d8f3dc;
    --warn: #c85b2a;
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }

  body {
    font-family: 'DM Sans', sans-serif;
    background: var(--paper);
    color: var(--ink);
    min-height: 100vh;
  }

  /* HEADER */
  header {
    background: var(--ink);
    color: var(--paper);
    padding: 28px 40px;
    display: flex;
    align-items: center;
    gap: 20px;
    border-bottom: 3px solid var(--accent);
  }
  .header-icon {
    width: 48px; height: 48px;
    background: var(--accent);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
  }
  header h1 {
    font-family: 'DM Serif Display', serif;
    font-size: 1.55rem;
    letter-spacing: -0.01em;
  }
  header p { font-size: 0.8rem; color: #a9a5a0; margin-top: 2px; }

  /* MAIN */
  main {
    max-width: 780px;
    margin: 0 auto;
    padding: 40px 24px 80px;
  }

  /* CONFIG BANNER */
  .config-banner {
    background: var(--ink);
    border-radius: 14px;
    padding: 22px 26px;
    margin-bottom: 32px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    position: relative;
    overflow: hidden;
  }
  .config-banner::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(200,91,42,0.15) 0%, transparent 60%);
    pointer-events: none;
  }
  .config-banner .dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--accent);
    margin-top: 5px;
    flex-shrink: 0;
    animation: pulse 2s infinite;
  }
  @keyframes pulse {
    0%,100% { opacity: 1; }
    50% { opacity: 0.4; }
  }
  .config-banner h3 { font-size: 0.9rem; color: #faf8f4; font-weight: 600; }
  .config-banner p { font-size: 0.8rem; color: #a9a5a0; margin-top: 4px; line-height: 1.5; }

  /* CONFIG SECTION */
  .config-section {
    background: white;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 28px;
    margin-bottom: 24px;
  }
  .config-section summary, .section-title {
    font-family: 'DM Serif Display', serif;
    font-size: 1rem;
    color: var(--ink);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    list-style: none;
    user-select: none;
  }
  .config-section summary::after {
    content: '▾';
    margin-left: auto;
    font-size: 0.85rem;
    color: var(--muted);
    transition: transform 0.2s;
  }
  details[open] summary::after { transform: rotate(180deg); }
  .config-section .badge {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 20px;
    background: var(--accent-soft);
    color: var(--accent);
  }
  .config-inner { margin-top: 20px; }

  /* FORM */
  .form-card {
    background: white;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 28px;
    margin-bottom: 24px;
  }
  .section-title { font-family: 'DM Serif Display', serif; font-size: 1.05rem; margin-bottom: 20px; }

  .form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
  .form-grid .full { grid-column: 1 / -1; }

  .field { display: flex; flex-direction: column; gap: 6px; }
  .field label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
  }
  .field label span { color: var(--accent); }

  .field input, .field select, .field textarea {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    padding: 10px 14px;
    border: 1.5px solid var(--line);
    border-radius: 8px;
    background: var(--paper);
    color: var(--ink);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
  }
  .field input:focus, .field select:focus, .field textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(200,91,42,0.12);
    background: white;
  }
  .field textarea { resize: vertical; min-height: 80px; }

  /* STATUS SELECT */
  .status-select { position: relative; }
  .status-select select { width: 100%; appearance: none; cursor: pointer; padding-right: 32px; }
  .status-select::after {
    content: '▾';
    position: absolute;
    right: 12px; top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--muted);
    font-size: 0.85rem;
  }

  /* DIVIDER */
  .divider { height: 1px; background: var(--line); margin: 24px 0; }

  /* ACTION BUTTONS */
  .actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
  }
  .btn {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.88rem;
    font-weight: 600;
    padding: 12px 22px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
  }
  .btn-primary {
    background: var(--accent);
    color: white;
  }
  .btn-primary:hover { background: #b04e23; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(200,91,42,0.3); }
  .btn-primary:active { transform: translateY(0); }

  .btn-secondary {
    background: var(--paper);
    color: var(--ink);
    border: 1.5px solid var(--line);
  }
  .btn-secondary:hover { border-color: var(--ink); background: white; }

  .btn-success {
    background: var(--success);
    color: white;
  }
  .btn-success:hover { background: #245c42; }

  .btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

  /* TOAST */
  #toast-container {
    position: fixed;
    bottom: 28px; right: 28px;
    z-index: 999;
    display: flex; flex-direction: column; gap: 10px;
  }
  .toast {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.85rem;
    padding: 14px 18px;
    border-radius: 12px;
    max-width: 360px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    animation: slideIn 0.25s ease;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  }
  @keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
  }
  .toast-success { background: var(--success); color: white; }
  .toast-error { background: #c0392b; color: white; }
  .toast-info { background: var(--ink); color: white; }
  .toast-icon { font-size: 1.1rem; flex-shrink: 0; }

  /* TABLE */
  .table-card {
    background: white;
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
    margin-bottom: 24px;
  }
  .table-header {
    padding: 18px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
  }
  .table-header h2 { font-family: 'DM Serif Display', serif; font-size: 1rem; }
  .count-badge {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--accent-soft);
    color: var(--accent);
  }
  table { width: 100%; border-collapse: collapse; }
  th {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    padding: 12px 16px;
    text-align: left;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
  }
  td {
    font-size: 0.83rem;
    padding: 13px 16px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
  }
  tr:last-child td { border-bottom: none; }
  tr:hover td { background: #fdf9f7; }
  .pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
  }
  .pill-agendado { background: #dbeafe; color: #1e40af; }
  .pill-realizado { background: var(--success-soft); color: var(--success); }
  .pill-cancelado { background: #fee2e2; color: #b91c1c; }
  .pill-pendente { background: #fef9c3; color: #854d0e; }

  .empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--muted);
  }
  .empty-state .emoji { font-size: 2.5rem; margin-bottom: 12px; }
  .empty-state p { font-size: 0.85rem; }

  /* SPINNER */
  .spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }

  /* GOOGLE AUTH */
  .auth-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 10px;
    border: 1.5px solid var(--line);
    font-size: 0.83rem;
    background: var(--paper);
    margin-bottom: 16px;
  }
  .auth-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
  }
  .auth-dot.connected { background: var(--success); }
  .auth-dot.disconnected { background: #dc2626; }

  @media (max-width: 580px) {
    header { padding: 20px; }
    main { padding: 24px 16px 60px; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .full { grid-column: 1; }
    table { font-size: 0.75rem; }
    th, td { padding: 10px 12px; }
  }