
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  
  --primary: #ff6b35;
  --primary-dark: #e85a24;
  --primary-light: rgba(255, 107, 53, .1);
  --secondary: #004e89;
  --secondary-dark: #003d6b;
  --secondary-light: rgba(0, 78, 137, .08);
  --success: #06a77d;
  --success-dark: #058a6f;
  --success-light: rgba(6, 168, 125, .1);
  --danger: #d62828;
  --danger-dark: #af200f;
  --danger-light: rgba(214, 40, 40, .1);
  --warning: #f77f00;
  --warning-dark: #e07000;
  --warning-light: rgba(247, 127, 0, .1);
  --light-bg: #f4f6f8;
  --white: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6c757d;
  --border: #e0e4e8;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow: 0 2px 8px rgba(0,0,0,.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.12);
  --shadow-xl: 0 16px 48px rgba(0,0,0,.16);

  
  --sp-xs: .375rem;
  --sp-sm: .5rem;
  --sp: .75rem;
  --sp-md: 1rem;
  --sp-lg: 1.25rem;
  --sp-xl: 1.5rem;
  --sp-2xl: 2rem;
  --sp-3xl: 3rem;

  
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 999px;

  
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --fs-xs: .75rem;
  --fs-sm: .8125rem;
  --fs-base: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.375rem;
  --fs-2xl: 1.75rem;
  --fs-3xl: 2.25rem;

  
  --ease: cubic-bezier(.4, 0, .2, 1);
  --duration: .25s;

  
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);

  
  --bottom-nav-h: 64px;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.6;
  color: var(--text);
  background-color: var(--light-bg);
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  min-height: 100vh;
  min-height: 100dvh;
}


h1 { font-size: var(--fs-2xl); font-weight: 800; line-height: 1.2; margin-bottom: var(--sp-lg); }
h2 { font-size: var(--fs-xl); font-weight: 700; line-height: 1.3; margin-bottom: var(--sp-md); }
h3 { font-size: var(--fs-lg); font-weight: 600; margin-bottom: var(--sp-sm); }
h4 { font-size: var(--fs-base); font-weight: 600; margin-bottom: var(--sp-sm); }
p  { margin-bottom: var(--sp-md); color: var(--text-muted); }

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--duration) var(--ease);
}


.container {
  width: 100%;
  padding: 0 var(--sp-md);
  margin: 0 auto;
}


form { width: 100%; }

.form-group {
  margin-bottom: var(--sp-lg);
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
}

label {
  font-weight: 600;
  color: var(--text);
  font-size: var(--fs-sm);
  text-transform: uppercase;
  letter-spacing: .04em;
}

input,
textarea,
select {
  width: 100%;
  padding: var(--sp) var(--sp-md);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: var(--fs-base);
  color: var(--text);
  background-color: var(--white);
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
  min-height: 50px;
  -webkit-appearance: none;
  appearance: none;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
}

input::placeholder { color: var(--text-muted); opacity: .6; }
textarea { resize: vertical; min-height: 100px; }

select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23004e89' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-position: right 14px center;
  background-repeat: no-repeat;
  padding-right: 36px;
}


button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-sm);
  padding: var(--sp) var(--sp-lg);
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: var(--fs-base);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
  min-height: 48px;
  min-width: 48px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

button:active,
.btn:active {
  transform: scale(.96);
}

button:disabled,
.btn:disabled {
  opacity: .4;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:active:not(:disabled) { background: var(--primary-dark); }

.btn-secondary { background: var(--secondary); color: var(--white); }
.btn-secondary:active:not(:disabled) { background: var(--secondary-dark); }

.btn-success { background: var(--success); color: var(--white); }
.btn-success:active:not(:disabled) { background: var(--success-dark); }

.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:active:not(:disabled) { background: var(--danger-dark); }

.btn-warning { background: var(--warning); color: var(--white); }
.btn-warning:active:not(:disabled) { background: var(--warning-dark); }

.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border: 2px solid var(--border);
}
.btn-outline:active:not(:disabled) { background: var(--light-bg); }

.btn-ghost {
  background: transparent;
  color: var(--primary);
  padding: var(--sp-sm);
}
.btn-ghost:active:not(:disabled) { background: var(--primary-light); }

.btn-sm {
  min-height: 44px;
  padding: var(--sp-sm) var(--sp);
  font-size: var(--fs-sm);
}

.btn-lg {
  min-height: 56px;
  padding: var(--sp-md) var(--sp-2xl);
  font-size: var(--fs-lg);
  border-radius: var(--radius);
}

.btn-block { width: 100%; }

.btn-icon {
  min-width: 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--radius-sm);
}

.btn-fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  padding: 0;
  box-shadow: var(--shadow-lg);
  font-size: 1.5rem;
}


@media (hover: hover) {
  .btn-primary:hover:not(:disabled) { background: var(--primary-dark); box-shadow: var(--shadow); transform: translateY(-1px); }
  .btn-secondary:hover:not(:disabled) { background: var(--secondary-dark); box-shadow: var(--shadow); transform: translateY(-1px); }
  .btn-success:hover:not(:disabled) { background: var(--success-dark); box-shadow: var(--shadow); transform: translateY(-1px); }
  .btn-danger:hover:not(:disabled) { background: var(--danger-dark); box-shadow: var(--shadow); transform: translateY(-1px); }
}


.toast-container {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + var(--sp-md));
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  pointer-events: none;
  width: 90%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}

.toast {
  background: var(--text);
  color: var(--white);
  border-radius: var(--radius-full);
  padding: var(--sp) var(--sp-lg);
  box-shadow: var(--shadow-lg);
  text-align: center;
  font-size: var(--fs-sm);
  font-weight: 500;
  animation: toastIn .35s var(--ease) forwards;
  pointer-events: all;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px) scale(.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(20px) scale(.9); }
}

.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.warning { background: var(--warning); }
.toast.info    { background: var(--secondary); }


.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
  padding: 0;
  animation: fadeIn .2s var(--ease);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--white);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--sp-lg) var(--sp-md) calc(var(--sp-lg) + var(--safe-bottom));
  width: 100%;
  max-height: 92vh;
  max-height: 92dvh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: slideUp .3s var(--ease);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}


.modal::before {
  content: '';
  display: block;
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: var(--radius-full);
  margin: 0 auto var(--sp-md);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-lg);
  padding-bottom: var(--sp);
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: var(--fs-lg);
  font-weight: 700;
  margin: 0;
}

.modal-close {
  background: var(--light-bg);
  border: none;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: auto;
  min-width: auto;
  font-size: 1.25rem;
  color: var(--text-muted);
  transition: background var(--duration);
}
.modal-close:active { background: var(--border); transform: none; }

.modal-body {
  padding: var(--sp-sm) 0;
}

.modal-footer {
  display: flex;
  gap: var(--sp-sm);
  margin-top: var(--sp-xl);
  padding-top: var(--sp-md);
  border-top: 1px solid var(--border);
}
.modal-footer .btn { flex: 1; }


.confirm-modal .modal {
  text-align: center;
  padding-top: var(--sp-xl);
}
.confirm-modal .confirm-icon {
  font-size: 3rem;
  margin-bottom: var(--sp-md);
}
.confirm-modal .confirm-message {
  font-size: var(--fs-base);
  color: var(--text);
  margin-bottom: var(--sp-xl);
  line-height: 1.5;
}


.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-3xl) var(--sp-md);
  text-align: center;
}
.empty-state-icon {
  font-size: 3rem;
  margin-bottom: var(--sp-md);
  opacity: .5;
}
.empty-state-text {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}


.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

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

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-md);
  padding: var(--sp-3xl);
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
.loading .spinner { width: 32px; height: 32px; }


.badge {
  display: inline-flex;
  align-items: center;
  gap: .25em;
  padding: .2em .65em;
  font-size: var(--fs-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  line-height: 1.4;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger  { background: var(--danger-light); color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-info    { background: var(--secondary-light); color: var(--secondary); }
.badge-primary { background: var(--primary-light); color: var(--primary); }


.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-xs);
  padding: var(--sp-xs) var(--sp);
  background: var(--light-bg);
  border-radius: var(--radius-full);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-muted);
}


.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: var(--sp-md);
  transition: box-shadow var(--duration) var(--ease);
}
.card:active { box-shadow: var(--shadow); }

@media (hover: hover) {
  .card:hover { box-shadow: var(--shadow); }
}


::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }


.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.fw-bold { font-weight: 700; }
.mt-sm { margin-top: var(--sp-sm); }
.mt-md { margin-top: var(--sp-md); }
.mt-lg { margin-top: var(--sp-lg); }
.mt-xl { margin-top: var(--sp-xl); }
.mb-sm { margin-bottom: var(--sp-sm); }
.mb-md { margin-bottom: var(--sp-md); }
.mb-lg { margin-bottom: var(--sp-lg); }
.flex-row { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-xs { gap: var(--sp-xs); }
.gap-sm { gap: var(--sp-sm); }
.gap-md { gap: var(--sp-md); }


.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}


@supports (padding-bottom: env(safe-area-inset-bottom)) {
  body { padding-bottom: var(--safe-bottom); }
}


@media (min-width: 768px) {
  :root {
    --bottom-nav-h: 0px;
  }

  .container { max-width: 720px; padding: 0 var(--sp-xl); }

  .modal-overlay {
    align-items: center;
    padding: var(--sp-xl);
  }
  .modal {
    border-radius: var(--radius-lg);
    max-width: 500px;
    padding: var(--sp-xl);
    animation: modalPop .25s var(--ease);
  }
  .modal::before { display: none; }

  @keyframes modalPop {
    from { opacity: 0; transform: scale(.95) translateY(10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
  }

  .toast-container {
    bottom: var(--sp-xl);
  }
}


@media (min-width: 1024px) {
  .container { max-width: 960px; }
  .modal { max-width: 560px; }
}
