/* =====================================================================
     SharedCss.html  (this is "css.html" from the spec, renamed because
     Apps Script only allows .gs / .html files - see README)
     Global variables + base layout + reusable components: Button,
     Textbox, Card, Toast, Loading, Modal. Loaded on every page.
     ===================================================================== */

  :root {
    --color-primary: #0066CC;
    --color-primary-dark: #0052a3;
    --color-success: #16A34A;
    --color-danger: #DC2626;
    --color-bg: #F5F7FA;
    --color-card: #FFFFFF;
    --color-text: #1A1A1A;
    --color-text-muted: #6B7280;
    --color-border: #E2E8F0;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    --container-max: 480px;
    --tap-min: 48px;
  }

  * { box-sizing: border-box; }

  html, body {
    margin: 0;
    padding: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: Roboto, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-tap-highlight-color: transparent;
  }

  .app-container {
    max-width: var(--container-max);
    margin: 0 auto;
    min-height: 100vh;
    padding: 16px 16px 32px;
    display: flex;
    flex-direction: column;
  }

  h1, h2, h3 { margin: 0 0 8px; font-weight: 700; }
  h1 { font-size: 22px; }
  h2 { font-size: 18px; }
  h3 { font-size: 15px; color: var(--color-text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .02em; }
  p { margin: 0 0 12px; }

  /* ---------- Card ---------- */
  .card {
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 18px;
    margin-bottom: 16px;
  }

  /* ---------- Form / Textbox ---------- */
  .field {
    margin-bottom: 14px;
  }
  .field label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: 6px;
  }
  .field .required { color: var(--color-danger); }

  input[type="text"],
  input[type="password"],
  input[type="date"],
  input[type="time"],
  input[type="number"],
  select,
  textarea {
    width: 100%;
    min-height: var(--tap-min);
    padding: 12px 14px;
    font-size: 16px;
    font-family: inherit;
    color: var(--color-text);
    background: var(--color-bg);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color .15s ease;
    -webkit-appearance: none;
    appearance: none;
  }
  textarea { min-height: 88px; resize: vertical; padding-top: 12px; }

  input:focus, select:focus, textarea:focus {
    border-color: var(--color-primary);
  }
  input.input-error, select.input-error, textarea.input-error {
    border-color: var(--color-danger);
  }
  .field-error {
    color: var(--color-danger);
    font-size: 13px;
    margin-top: 4px;
    display: none;
  }
  .field-error.show { display: block; }

  /* ---------- Buttons ---------- */
  .btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: var(--tap-min);
    padding: 12px 16px;
    font-size: 16px;
    font-weight: 700;
    font-family: inherit;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: opacity .15s ease, transform .05s ease;
    -webkit-appearance: none;
    appearance: none;
  }
  .btn:active { transform: scale(0.98); }
  .btn:disabled { opacity: .55; cursor: not-allowed; }

  .btn-primary { background: var(--color-primary); color: #fff; }
  .btn-success { background: var(--color-success); color: #fff; }
  .btn-danger  { background: var(--color-danger); color: #fff; }
  .btn-outline {
    background: transparent;
    color: var(--color-primary);
    border: 1.5px solid var(--color-primary);
  }
  .btn-ghost {
    background: transparent;
    color: var(--color-text-muted);
    font-weight: 600;
  }
  .btn-sm {
    min-height: 40px;
    padding: 8px 12px;
    font-size: 14px;
    width: auto;
  }
  .btn-block-group { display: flex; gap: 10px; }
  .btn-block-group .btn { flex: 1; }

  /* ---------- Toast ---------- */
  #toast-container {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: var(--container-max);
    margin: 0 auto;
    pointer-events: none;
  }
  .toast {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .2s ease, transform .2s ease;
  }
  .toast.show { opacity: 1; transform: translateY(0); }
  .toast-success { background: var(--color-success); }
  .toast-error { background: var(--color-danger); }
  .toast-info { background: var(--color-primary); }

  /* ---------- Loading ---------- */
  #loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(245, 247, 250, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    flex-direction: column;
    gap: 12px;
  }
  #loading-overlay.show { display: flex; }
  .spinner {
    width: 36px;
    height: 36px;
    border: 4px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }
  .loading-text { font-size: 14px; color: var(--color-text-muted); font-weight: 600; }

  /* ---------- Modal ---------- */
  .modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: none;
    align-items: flex-end;
    justify-content: center;
    z-index: 9500;
  }
  .modal-backdrop.show { display: flex; }
  .modal-sheet {
    background: var(--color-card);
    width: 100%;
    max-width: var(--container-max);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 20px 18px 28px;
    max-height: 85vh;
    overflow-y: auto;
  }
  .modal-sheet .modal-handle {
    width: 40px;
    height: 4px;
    background: var(--color-border);
    border-radius: 2px;
    margin: 0 auto 16px;
  }

  /* ---------- Misc ---------- */
  .row { display: flex; gap: 10px; }
  .row > * { flex: 1; }
  .muted { color: var(--color-text-muted); font-size: 13px; }
  .badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
  }
  .badge-active { background: #DCFCE7; color: var(--color-success); }
  .badge-locked { background: #FEE2E2; color: var(--color-danger); }
  .badge-admin { background: #DBEAFE; color: var(--color-primary); }
  .badge-user { background: #F1F5F9; color: var(--color-text-muted); }
  .divider { height: 1px; background: var(--color-border); margin: 14px 0; border: none; }
  .empty-state { text-align: center; padding: 40px 12px; color: var(--color-text-muted); }
