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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #242836;
  --border: #2e3345;
  --text: #e4e6ed;
  --text-dim: #8b8fa3;
  --primary: #4a7cff;
  --primary-hover: #3a6af0;
  --success: #34c759;
  --danger: #ff453a;
  --warning: #ff9f0a;
  --radius: 12px;
}

html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* Login */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 1rem;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  text-align: center;
  width: 100%;
  max-width: 380px;
}

.login-card h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.login-subtitle {
  color: var(--text-dim);
  margin-bottom: 2rem;
}

.btn-microsoft {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  background: #fff;
  color: #1a1a1a;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  text-decoration: none;
  transition: box-shadow 0.15s;
}

.btn-microsoft:hover { box-shadow: 0 2px 12px rgba(74, 124, 255, 0.3); }

.error-msg {
  margin-top: 1.5rem;
  color: var(--danger);
  font-size: 0.875rem;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header h1 { font-size: 1.125rem; font-weight: 700; display: flex; align-items: center; gap: 0.5rem; }
.header-logo { width: 24px; height: 24px; }

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
}

#user-name { color: var(--text-dim); }

.btn-logout {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}

/* Views */
.view { display: none; padding: 1rem; max-width: 600px; margin: 0 auto; }
.view.active { display: block; }

/* Section header */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.section-header h2 { font-size: 1.125rem; font-weight: 600; }

.btn-icon {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.25rem;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Cards */
.card-list { display: flex; flex-direction: column; gap: 0.75rem; }

.sc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  cursor: pointer;
  transition: border-color 0.15s;
}

.sc-card:hover, .sc-card:active { border-color: var(--primary); }

.sc-card .company { font-weight: 600; font-size: 1rem; margin-bottom: 0.25rem; }
.sc-card .time { color: var(--text-dim); font-size: 0.85rem; }
.sc-card .tickets { color: var(--text-dim); font-size: 0.8rem; margin-top: 0.25rem; }

/* Back button */
.btn-back {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.5rem 0;
  margin-bottom: 0.5rem;
}

/* Ticket header */
.ticket-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

.ticket-header .ticket-number { color: var(--primary); font-weight: 600; }
.ticket-header .ticket-title { font-size: 1rem; margin-top: 0.25rem; }
.ticket-header .ticket-company { color: var(--text-dim); font-size: 0.85rem; margin-top: 0.25rem; }
.ticket-search { margin-top: 0.75rem; }
.ticket-search .input { margin-bottom: 0.5rem; }

/* Form sections */
.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.form-section label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.hint { font-weight: 400; color: var(--text-dim); font-size: 0.8rem; }

.input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.5rem;
  font-family: inherit;
  -webkit-appearance: none;
}

.input:focus { outline: none; border-color: var(--primary); }
textarea.input { resize: vertical; }
select.input { cursor: pointer; }

.time-row { display: flex; gap: 0.5rem; }
.time-row .input { flex: 1; }

/* Buttons */
.btn {
  display: block;
  width: 100%;
  padding: 0.7rem;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  text-align: center;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--primary); }

/* Photo preview */
.photo-preview {
  margin: 0.5rem 0;
}

.photo-preview img {
  max-width: 100%;
  max-height: 200px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.75rem 1.25rem;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
  z-index: 200;
  max-width: 90%;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }

/* Loading */
.loading {
  text-align: center;
  color: var(--text-dim);
  padding: 2rem;
}

.empty-state {
  text-align: center;
  color: var(--text-dim);
  padding: 3rem 1rem;
}

/* Spinner on buttons */
.btn.loading-btn { position: relative; color: transparent; }
.btn.loading-btn::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 18px; height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
