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

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: #ffffff;
  color: #111111;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

.container {
  max-width: 540px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

/* ---- Header ---- */
.app-header {
  text-align: center;
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 2px solid #1428A0;
}

.app-title {
  font-size: 22px;
  font-weight: 700;
  color: #1428A0;
  letter-spacing: -0.3px;
}

/* ---- Form ---- */
.form-group {
  margin-bottom: 20px;
}

label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #444444;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

input[type="text"] {
  width: 100%;
  padding: 14px 16px;
  font-size: 17px;
  border: 2px solid #cccccc;
  border-radius: 8px;
  background: #ffffff;
  color: #111111;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

input[type="text"]:focus {
  border-color: #1428A0;
}

input[type="text"].error {
  border-color: #d32f2f;
}

.field-error {
  color: #d32f2f;
  font-size: 13px;
  margin-top: 4px;
}

/* ---- Photo Section ---- */
.photo-section {
  margin-bottom: 24px;
}

.photo-section label {
  margin-bottom: 12px;
}

.photo-buttons {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}

.btn-photo {
  flex: 1;
  padding: 14px 10px;
  font-size: 15px;
  font-weight: 600;
  border: 2px solid #1428A0;
  border-radius: 8px;
  background: #ffffff;
  color: #1428A0;
  cursor: pointer;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
  min-height: 52px;
}

.btn-photo:active {
  background: #e8ecf8;
}

.photo-preview-wrap {
  display: none;
  background: #f5f5f5;
  border: 1px solid #dddddd;
  border-radius: 8px;
  padding: 10px;
  margin-top: 10px;
}

.photo-preview-wrap.visible {
  display: block;
}

.photo-preview-wrap img {
  width: 100%;
  border-radius: 6px;
  display: block;
}

.photo-info {
  font-size: 12px;
  color: #666666;
  margin-top: 6px;
  text-align: center;
}

.photo-status {
  font-size: 13px;
  color: #555555;
  margin-top: 6px;
  min-height: 18px;
}

.photo-status.compressing {
  color: #888888;
}

.photo-status.ready {
  color: #2e7d32;
  font-weight: 600;
}

.photo-status.error {
  color: #d32f2f;
}

/* ---- Submit Button ---- */
.btn-submit {
  width: 100%;
  padding: 18px 16px;
  font-size: 17px;
  font-weight: 700;
  background: #1428A0;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  letter-spacing: 0.2px;
  -webkit-tap-highlight-color: transparent;
  min-height: 58px;
}

.btn-submit:disabled {
  background: #aab0cc;
  cursor: not-allowed;
}

.btn-submit:not(:disabled):active {
  background: #0f1f7a;
}

/* ---- Status Message ---- */
.status-message {
  display: none;
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  text-align: center;
}

.status-message.success {
  display: block;
  background: #e8f5e9;
  border: 1px solid #a5d6a7;
  color: #1b5e20;
}

.status-message.error {
  display: block;
  background: #ffebee;
  border: 1px solid #ef9a9a;
  color: #b71c1c;
}

/* ---- Admin Link ---- */
.admin-link-wrap {
  text-align: center;
  margin-top: 48px;
}

.admin-link {
  font-size: 11px;
  color: #aaaaaa;
  text-decoration: none;
}

.admin-link:hover {
  color: #888888;
  text-decoration: underline;
}

/* ============================
   ADMIN PAGE
   ============================ */
.admin-login-wrap {
  max-width: 400px;
  margin: 80px auto 0;
  padding: 0 20px;
  text-align: center;
}

.admin-login-title {
  font-size: 20px;
  font-weight: 700;
  color: #1428A0;
  margin-bottom: 24px;
}

.admin-login-wrap input[type="password"] {
  width: 100%;
  padding: 14px 16px;
  font-size: 17px;
  border: 2px solid #cccccc;
  border-radius: 8px;
  margin-bottom: 14px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.admin-login-wrap input[type="password"]:focus {
  border-color: #1428A0;
}

.btn-login {
  width: 100%;
  padding: 15px;
  font-size: 16px;
  font-weight: 700;
  background: #1428A0;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.btn-login:active {
  background: #0f1f7a;
}

.login-error {
  color: #d32f2f;
  font-size: 13px;
  margin-top: 8px;
  min-height: 18px;
}

.admin-dashboard {
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.admin-top-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 2px solid #1428A0;
}

.admin-top-bar h1 {
  font-size: 20px;
  font-weight: 700;
  color: #1428A0;
  flex: 1;
  min-width: 200px;
}

.admin-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.search-input {
  padding: 9px 14px;
  font-size: 14px;
  border: 2px solid #cccccc;
  border-radius: 6px;
  outline: none;
  width: 200px;
  -webkit-appearance: none;
  appearance: none;
}

.search-input:focus {
  border-color: #1428A0;
}

.btn-sm {
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}

.btn-primary {
  background: #1428A0;
  color: #ffffff;
  border-color: #1428A0;
}

.btn-primary:active {
  background: #0f1f7a;
}

.btn-outline {
  background: #ffffff;
  color: #1428A0;
  border-color: #1428A0;
}

.btn-outline:active {
  background: #e8ecf8;
}

.btn-danger {
  background: #d32f2f;
  color: #ffffff;
  border-color: #d32f2f;
}

.btn-danger:active {
  background: #b71c1c;
}

.btn-logout {
  background: #ffffff;
  color: #888888;
  border-color: #cccccc;
}

.btn-logout:active {
  background: #f5f5f5;
}

.admin-status {
  font-size: 13px;
  color: #555555;
  margin-bottom: 12px;
  min-height: 18px;
}

.admin-status.error {
  color: #d32f2f;
}

.admin-status.success {
  color: #2e7d32;
  font-weight: 600;
}

/* ---- Table ---- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 860px;
}

th {
  background: #f5f7ff;
  padding: 10px 12px;
  text-align: left;
  font-weight: 700;
  color: #333333;
  border-bottom: 2px solid #e0e0e0;
  white-space: nowrap;
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid #eeeeee;
  color: #222222;
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: #f9f9ff;
}

.record-count {
  font-size: 12px;
  color: #888888;
  margin-bottom: 8px;
}

.btn-icon {
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 5px;
  cursor: pointer;
  border: 1px solid;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}

.btn-view {
  background: #e3f2fd;
  color: #1565c0;
  border-color: #90caf9;
}

.btn-view:active {
  background: #bbdefb;
}

.btn-download {
  background: #e8f5e9;
  color: #2e7d32;
  border-color: #a5d6a7;
  margin-left: 4px;
}

.btn-download:active {
  background: #c8e6c9;
}

.btn-del {
  background: #ffebee;
  color: #c62828;
  border-color: #ef9a9a;
  margin-left: 4px;
}

.btn-del:active {
  background: #ffcdd2;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.badge-submitted {
  background: #e8f5e9;
  color: #2e7d32;
}

.badge-uploaded {
  background: #e3f2fd;
  color: #1565c0;
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: #888888;
  font-size: 14px;
}

.hidden {
  display: none !important;
}

/* ---- Modal ---- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open {
  display: flex;
}

.modal-box {
  background: #ffffff;
  border-radius: 12px;
  padding: 24px;
  width: 90%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 14px;
  color: #111111;
}

.modal-box input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  border: 2px solid #cccccc;
  border-radius: 6px;
  margin-bottom: 12px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.modal-box input[type="password"]:focus {
  border-color: #1428A0;
}

.modal-error {
  color: #d32f2f;
  font-size: 13px;
  margin-bottom: 10px;
  min-height: 18px;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-actions button {
  flex: 1;
}

@media (max-width: 400px) {
  .photo-buttons {
    flex-direction: column;
  }
  .admin-top-bar h1 {
    font-size: 17px;
  }
}
